微服务架构【技术点3】--- [初级] windows下zookeeper的配置+dubbo服务提供者端+dubbo消费者端配置

前言

要做微服务架构的话,比较好的方式是逐渐演变,就是说,分解为各个基本点进行实现然后逐渐演化成一套软件框架及开发体系—当然,如果之前有相关经验和部分体系的话,结合起来也是相当快的。

zookeeper在win下面的配置

对了,请参考这两篇东西
zookeeper安装和使用 windows环境

zookeeper报错 JAVA_HOME is not set

这里我做一下简单介绍—windows下的zookeeper不重要,在linux下的才重要,linux下的是正式生产环境,win下的只是一个玩具,开发时候玩玩而已。

先到zookeeper的官网:
https://zookeeper.apache.org/

微服务架构【技术点3】--- [初级] windows下zookeeper的配置+dubbo服务提供者端+dubbo消费者端配置_第1张图片

下载并且解压—跟教程的一样啊。

我解压到这个地址

微服务架构【技术点3】--- [初级] windows下zookeeper的配置+dubbo服务提供者端+dubbo消费者端配置_第2张图片

然后:

解压到指定目录下 D:\soft\zookeeper-3.4
修改zoo_sample.cfg 文件名(D:\soft\zookeeper-3.4\conf) 为 zoo.cfg
主要修改一下日志位置,具体配置文件如下:

好了,配置文件可以直接抄的:

# The number of milliseconds of each tick  
tickTime=2000  
# The number of ticks that the initial   
# synchronization phase can take  
initLimit=10  
# The number of ticks that can pass between   
# sending a request and getting an acknowledgement  
syncLimit=5  
# the directory where the snapshot is stored.  
# do not use /tmp for storage, /tmp here is just   
# example sakes.  
dataDir=D:\\zookeeper\\data  
dataLogDir=D:\\zookeeper\\log  
# the port at which the clients will connect  
clientPort=2181  
# the maximum number of client connections.  
# increase this if you need to handle more clients  
#maxClientCnxns=60  
#  
# Be sure to read the maintenance section of the   
# administrator guide before turning on autopurge.  
#  
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance  
#  
# The number of snapshots to retain in dataDir  
#autopurge.snapRetainCount=3  
# Purge task interval in hours  
# Set to "0" to disable auto purge feature  
#autopurge.purgeInterval=1  

注意,要设置一下java home的问题,打开:

微服务架构【技术点3】--- [初级] windows下zookeeper的配置+dubbo服务提供者端+dubbo消费者端配置_第3张图片

看到这一段没有?

微服务架构【技术点3】--- [初级] windows下zookeeper的配置+dubbo服务提供者端+dubbo消费者端配置_第4张图片

留意一下画出来的地方,那是要插入一段java home变量的,

set JAVA=C:\Program Files\Java\jdk1.8.0_161\bin\java
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_161

插入上面一段代码—注意,修改成你自己本机的jdk位置吧,

微服务架构【技术点3】--- [初级] windows下zookeeper的配置+dubbo服务提供者端+dubbo消费者端配置_第5张图片

然后,启动服务:

微服务架构【技术点3】--- [初级] windows下zookeeper的配置+dubbo服务提供者端+dubbo消费者端配置_第6张图片

D:
cd D:\software\zookeeper-3.4\bin
zkServer.cmd

三个命令即可。
win下面配置zookeeper完成,下面是比较相对难度大一点的内容。

配置前言

注意,这个项目你可以认为是一个实际的微服务项目,项目是一个完整的项目,只不过不是spring mvc这种web程序,而是java的application程序,所以如何将spring跟传统的java application结合是一个难点来的,而这个微服务项目涉及到数据库,涉及到spring及dubbo,涉及到mybatis及druid,还有就是需要将其分成两部分,一部分用于内部逻辑,一部分用于对外提供接口,所以无论从哪个角度来看这项目的难度是大一点的,需要仔细思考。

对了,里面很多代码用得类库都是内部使用的,是经过实际检验的,所以,即使抄下来代码也是无法运行的,然而,最重要是这个配置过程这个思路,一旦明白了怎么弄都可以。

数据库说明

对了,用到的数据库是postgresql,用到的其中一张表是:

CREATE TABLE "public"."member" (
"id" int4 DEFAULT nextval('member_id_seq'::regclass) NOT NULL,
"name" varchar(45) COLLATE "default" NOT NULL,
"email" varchar(255) COLLATE "default",
"mobile" char(11) COLLATE "default",
"password" char(32) COLLATE "default" NOT NULL,
"avatar" varchar(400) COLLATE "default" NOT NULL,
"regist_time" timestamp(6),
"token" varchar(255) COLLATE "default",
"longitude" numeric(10,6),
"latitude" numeric(10,6),
"wxopenid" varchar(200) COLLATE "default",
"unionid" varchar(200) COLLATE "default",
"qqkey" varchar(200) COLLATE "default",
"login_time" timestamp(6),
"last_login_time" timestamp(6),
"region_id" int4,
"address" varchar(100) COLLATE "default" NOT NULL,
"member_status" int2 DEFAULT 1 NOT NULL,
"data_completed" bool DEFAULT false NOT NULL,
CONSTRAINT "member_pkey" PRIMARY KEY ("id"),
CONSTRAINT "member_mobile_key" UNIQUE ("mobile")
)
;

dubbo的provider雏形项目配置

使用的是idea,新建一个maven程序,怎么新建maven程序这些就不说了,挑重点。

1、项目结构及说明
项目结构分成两部分贴出来:

微服务架构【技术点3】--- [初级] windows下zookeeper的配置+dubbo服务提供者端+dubbo消费者端配置_第7张图片

微服务架构【技术点3】--- [初级] windows下zookeeper的配置+dubbo服务提供者端+dubbo消费者端配置_第8张图片

项目的名称命名为:

MicroBase

里面包括一个子项目,MicroBaseApi,子项目里面有:
model层(可序列化),searcher搜索条件层(可序列化),vo层(可序列化),service服务接口层,还有就是dubbo的消费者配置文件MicroBase-consumer,至于为什么要这样设计等下解释。api层主要作用是将项目的对外接口及需要的pojo对象,接口对象及消费者需要明确知道的调用规则暴露出来,以供其他消费者甚至是服务提供者(必定出现的,就拿会员服务来说,无论订单系统支付系统还是招聘模块都必须调用会员服务)。
一个小提问,为什么会有model—数据库插入用模型及vo–viewobject 前台页面显示pojo的区分,两个都用同一个不行吗?—这个是见仁见智的,然而在我的实践中,两者压根会出现各种不同,无法统一为一个。
而父项目,MicroBase就包含了conf配置层,dao数据库操作层–就是mybatis的mapper接口层,serviceImpl层–就是具体实现service的层,还有资源文件夹,有dev,product,test三个环境下的配置文件,其中,有db.properties及dubbo.properties分别设定各个环境下的数据库及dubbo信息,还有spring的配置文件,当然mapper的xml映射文件都在,还有provider.xml设置及env环境设定文件。

下面逐个逐个文件说明:

MicroBase父项目说明

pom.xml


<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0modelVersion>

    <groupId>net.w2pgroupId>
    <artifactId>micro-baseartifactId>
    <packaging>pompackaging>
    <version>1.0-SNAPSHOTversion>
    <modules>
        <module>MicroBaseApimodule>
    modules>


    

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-compiler-pluginartifactId>
                <version>3.3version>
                <configuration>
                    <source>1.8source>
                    <target>1.8target>
                configuration>
            plugin>
        plugins>
    build>

    <dependencies>

        
        <dependency>
            
            
            <groupId>net.funfunlegroupId>
            <artifactId>baselibartifactId>
            <version>LATESTversion>
        dependency>

        


        
        <dependency>
            <groupId>com.alibabagroupId>
            <artifactId>fastjsonartifactId>
            <version>1.2.47version>
        dependency>

        
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-webmvcartifactId>
            <version>5.0.6.RELEASEversion>
        dependency>
        
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-txartifactId>
            <version>5.0.6.RELEASEversion>
        dependency>
        
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-jdbcartifactId>
            <version>5.0.6.RELEASEversion>
        dependency>

        
        <dependency>
            <groupId>org.mybatisgroupId>
            <artifactId>mybatisartifactId>
            <version>3.4.6version>
        dependency>
        
        <dependency>
            <groupId>org.mybatisgroupId>
            <artifactId>mybatis-springartifactId>
            <version>1.3.2version>
        dependency>

        
        
        
        
        
        
        

        
        <dependency>
            <groupId>org.postgresqlgroupId>
            <artifactId>postgresqlartifactId>
            <version>42.2.2version>
        dependency>


        
        <dependency>
            <groupId>com.alibabagroupId>
            <artifactId>druidartifactId>
            <version>1.1.10version>
        dependency>
        
        <dependency>
            <groupId>taglibsgroupId>
            <artifactId>standardartifactId>
            <version>1.1.2version>
        dependency>
        <dependency>
            <groupId>jstlgroupId>
            <artifactId>jstlartifactId>
            <version>1.2version>
            <scope>compilescope>
        dependency>
        <dependency>
            <groupId>javax.servletgroupId>
            <artifactId>javax.servlet-apiartifactId>
            <version>3.1.0version>
            <scope>providedscope>
        dependency>

        
        
        <dependency>
            <groupId>com.alibabagroupId>
            <artifactId>dubboartifactId>
            <version>2.5.3version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframeworkgroupId>
                    <artifactId>springartifactId>
                exclusion>
            exclusions>
        dependency>
        <dependency>
            <groupId>com.101tecgroupId>
            <artifactId>zkclientartifactId>
            <version>0.10version>
        dependency>
        

    dependencies>



project>

env.properties

# spring里面的profile参数。
# 有: development,test,production
spring.profile = development

这个文件是用来指定spring profile的,就是用来做环境切换,在正式部署时候,文件的更新列表中通常都会忽略这个文件,因为一旦指定了环境就不必改变了。

net.w2p.MicroBase.config下面的EnvConfig.java
环境配置文件:

package net.w2p.MicroBase.config;



import org.apache.log4j.Logger;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;

public class EnvConfig {
    private static Properties config;

    static {

        initConfig();
    }

    private static void initConfig(){
        InputStream in = ClassLoader.getSystemResourceAsStream("env.properties");
        //InputStream inputStream = MyClass.class.getClassLoader().getResourceAsStream("com/john/basis/conf.properties");
        config=new Properties();
        InputStream inputStream=null;
        try{
            config.load(new InputStreamReader(in, "UTF-8"));

//            config.load(inputStream);
        }
        catch (Exception ed){
            ed.printStackTrace();
        }
    }

    public static String getProfile(){
        if(config!=null){
            return config.getProperty("spring.profile");
        }

        return "";
    }


}

先说这个文件是因为这个文件挺重要的,读取env.properties的值。

接下来:
net.w2p.MicroBase下面的provider.java,这个就是入口程序了,

package net.w2p.MicroBase;

import com.alibaba.fastjson.JSONObject;
import net.w2p.MicroBase.config.EnvConfig;
import net.w2p.MicroBase.searcher.account.MemberCondition;
import net.w2p.MicroBase.service.account.MemberService;
import net.w2p.MicroBase.vo.account.Member;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.io.IOException;
import java.util.ArrayList;

public class Provider {
    public static void main(String[] args) throws IOException {
//        System.setProperty("-Dspring.profiles.active","development");
//        System.setProperty("spring.profiles.active", "development");
//--根据env.properties设定运行环境。
        System.setProperty("spring.profiles.active", EnvConfig.getProfile());
        //--加载spring的配置文件
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        System.out.println(context.getDisplayName() + ": here");
        context.start();
        //--加载完成以后,对了,从上下文拿一个服务来进行测试,看看能不能正常使用服务
        MemberService tmpService=context.getBean(MemberService.class);
        ArrayList nowMembers=tmpService.simpleSearch(new MemberCondition());
        String str= JSONObject.toJSONString(nowMembers);
        System.out.println("服务已经启动...");
        System.out.println(str);
        System.in.read();
    }
}

applicationContext.xml


<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
    http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd
    ">
       
       
       
       <beans profile="development">
              <context:property-placeholder
                      location="classpath:conf/dev/*.properties" />
           <import resource="classpath:conf/spring/spring-*.xml">import>
           <import resource="classpath:provider.xml">import>
       beans>

       
       <beans profile="test">
              <context:property-placeholder
                      location="classpath:conf/test/*.properties" />
           <import resource="classpath:conf/spring/spring-*.xml">import>
           <import resource="classpath:provider.xml">import>
       beans>

       
       <beans profile="production">
              <context:property-placeholder
                      location=" classpath:conf/product/*.properties" />
           <import resource="classpath:conf/spring/spring-*.xml">import>
           <import resource="classpath:provider.xml">import>
       beans>
       

    





beans>

provider.xml的配置:


<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://code.alibabatech.com/schema/dubbo
       http://code.alibabatech.com/schema/dubbo/dubbo.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-2.5.xsd
       ">
    
    <dubbo:application name="demotest-provider" owner="programmer" organization="dubbox"/>
    
    <dubbo:registry address="${dubbo.address}"/>
    
    <dubbo:protocol name="${dubbo.protocol}" port="${dubbo.port}" />

    <import resource="classpath:conf/dubbo/MicroBase-provider.xml">import>

beans>

那么配置文件会导入某个环境下面的properties文件,我们就看其中一个环境的properties文件内容:

db.properties:

druid.driverClassName=org.postgresql.Driver
druid.jdbcUrl = jdbc:postgresql://你自己的服务器:5432/数据库名称
druid.username = 数据库用户名称
druid.password = 数据库密码
druid.initialSize=10
druid.minIdle=6
druid.maxActive=50
druid.maxWait=60000
druid.timeBetweenEvictionRunsMillis=60000
druid.minEvictableIdleTimeMillis=300000
druid.validationQuery=SELECT 'x'
druid.testWhileIdle=true
druid.testOnBorrow=false
druid.testOnReturn=false
druid.poolPreparedStatements=false
druid.maxPoolPreparedStatementPerConnectionSize=20
druid.filters=wall,stat

dubbo.properties:

dubbo.address = zookeeper://localhost:2181
dubbo.protocol = dubbo
dubbo.port = 20880

MicroBase-provider.xml配置文件内容是:


<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://code.alibabatech.com/schema/dubbo
       http://code.alibabatech.com/schema/dubbo/dubbo.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-2.5.xsd
       ">

       <dubbo:service interface="net.w2p.MicroBase.service.account.MemberService"
                      ref="MicroBase.account.MemberService"
                      protocol="dubbo" />
       <bean id="MicroBase.account.MemberService"
             class="net.w2p.MicroBase.serviceImpl.account.MemberServiceImpl"/>


beans>

主要是用来配置dubbo对外开放的接口。

spring-db.xml


<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
       xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:jpa="http://www.springframework.org/schema/data/jpa"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-4.2.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
    http://www.springframework.org/schema/data/jpa
    http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">




    <context:component-scan base-package="net.w2p.MicroBase.dao" >
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
    context:component-scan>

    
    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
          init-method="init" destroy-method="close">
        
        <property name="url" value="${druid.jdbcUrl}" />

        <property name="username" value="${druid.username}" />
        <property name="password" value="${druid.password}" />
        <property name = "driverClassName" value = "${druid.driverClassName}" />

        
        <property name="initialSize" value="${druid.initialSize}" />
        
        <property name="minIdle" value="${druid.minIdle}" />
        
        <property name="maxActive" value="${druid.maxActive}" />
        
        <property name="maxWait" value="${druid.maxWait}" />

        
        <property name="timeBetweenEvictionRunsMillis" value="${druid.timeBetweenEvictionRunsMillis}" />

        
        <property name="minEvictableIdleTimeMillis" value="${druid.minEvictableIdleTimeMillis}" />
        <property name="validationQuery" value="${druid.validationQuery}" />
        <property name="testWhileIdle" value="${druid.testWhileIdle}" />
        <property name="testOnBorrow" value="${druid.testOnBorrow}" />
        <property name="testOnReturn" value="${druid.testOnReturn}" />

        
        <property name="poolPreparedStatements" value="${druid.poolPreparedStatements}" />
        <property name="maxPoolPreparedStatementPerConnectionSize"
                  value="${druid.maxPoolPreparedStatementPerConnectionSize}" />

        
        <property name="filters" value="${druid.filters}" />



    bean>


    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="configLocation" value="classpath:/conf/mybatis.xml"/>
        <property name="mapperLocations">
            <list>
                
                <value>classpath*:mapper/**/*Mapper.xmlvalue>
            list>
        property>
        

    bean>


    
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="net.w2p.MicroBase.dao" />
        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
    bean>
    
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
    bean>

    
    <tx:annotation-driven transaction-manager="transactionManager" />
    
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            
            <tx:method name="save*" propagation="REQUIRED" />
            <tx:method name="insert*" propagation="REQUIRED" />
            <tx:method name="delete*" propagation="REQUIRED" />
            <tx:method name="update*" propagation="REQUIRED" />
            <tx:method name="find*" propagation="SUPPORTS" read-only="true" />
            <tx:method name="get*" propagation="SUPPORTS" read-only="true" />
        tx:attributes>
    tx:advice>
beans>

spring-service.xml


<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">


    
    <context:component-scan base-package="net.w2p.MicroBase.serviceImpl" >
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
    context:component-scan>



    
beans>

MemberMapper.xml
mybatis的xml文件:
注意,这份文件是用自定义工具生成的,可以满足80%的需求,当然,也有点长就是了。




<mapper namespace="net.w2p.MicroBase.dao.account.MemberMapper">

    <select id="simpleSearch" resultType="net.w2p.MicroBase.vo.account.Member">
        select
        *
        from member
        <if test="condition != null">
            <trim prefix="where" prefixOverrides="and |or">
                <include refid="base_where_condition_for_Member"/>
            trim>
        if>
        <choose>
            <when test="condition != null and condition.orderConditions!=null and condition.orderConditions.size() > 0">
                <trim prefix=" order by " suffixOverrides=",">
                    <foreach collection="condition.orderConditions" index="index" item="item" open="" separator=""
                             close="">
                        <if test='item.columnName!=null and item.columnName=="id"'>
                            "id"
                            <choose>
                                <when test='item.orderType=="desc"'>descwhen>
                                <otherwise>ascotherwise>
                            choose>
                            ,
                        if>
                        <if test='item.columnName!=null and item.columnName=="name"'>
                            "name"
                            <choose>
                                <when test='item.orderType=="desc"'>descwhen>
                                <otherwise>ascotherwise>
                            choose>
                            ,
                        if>
                        <if test='item.columnName!=null and item.columnName=="email"'>
                            "email"
                            <choose>
                                <when test='item.orderType=="desc"'>descwhen>
                                <otherwise>ascotherwise>
                            choose>
                            ,
                        if>
                        <if test='item.columnName!=null and item.columnName=="mobile"'>
                            "mobile"
                            <choose>
                                <when test='item.orderType=="desc"'>descwhen>
                                <otherwise>ascotherwise>
                            choose>
                            ,
                        if>
                        <if test='item.columnName!=null and item.columnName=="password"'>
                            "password"
                            <choose>
                                <when test='item.orderType=="desc"'>descwhen>
                                <otherwise>ascotherwise>
                            choose>
                            ,
                        if>
                        <if test='item.columnName!=null and item.columnName=="avatar"'>
                            "avatar"
                            <choose>
                                <when test='item.orderType=="desc"'>descwhen>
                                <otherwise>ascotherwise>
                            choose>
                            ,
                        if>
                        <if test='item.columnName!=null and item.columnName=="regist_time"'>
                            "regist_time"
                            <choose>
                                <when test='item.orderType=="desc"'>descwhen>
                                <otherwise>ascotherwise>
                            choose>
                            ,
                        if>
                        <if test='item.columnName!=null and item.columnName=="token"'>
                            "token"
                            <choose>
                                <when test='item.orderType=="desc"'>descwhen>
                                <otherwise>ascotherwise>
                            choose>
                            ,
                        if>
                        <if test='item.columnName!=null and item.columnName=="longitude"'>
                            "longitude"
                            <choose>
                                <when test='item.orderType=="desc"'>descwhen>
                                <otherwise>ascotherwise>
                            choose>
                            ,
                        if>
                        <if test='item.columnName!=null and item.columnName=="latitude"'>
                            "latitude"
                            <choose>
                                <when test='item.orderType=="desc"'>descwhen>
                                <otherwise>ascotherwise>
                            choose>
                            ,
                        if>
                        <if test='item.columnName!=null and item.columnName=="wxopenid"'>
                            "wxopenid"
                            <choose>
                                <when test='item.orderType=="desc"'>descwhen>
                                <otherwise>ascotherwise>
                            choose>
                            ,
                        if>
                        <if test='item.columnName!=null and item.columnName=="unionid"'>
                            "unionid"
                            <choose>
                                <when test='item.orderType=="desc"'>descwhen>
                                <otherwise>ascotherwise>
                            choose>
                            ,
                        if>
                        <if test='item.columnName!=null and item.columnName=="qqkey"'>
                            "qqkey"
                            <choose>
                                <when test='item.orderType=="desc"'>descwhen>
                                <otherwise>ascotherwise>
                            choose>
                            ,
                        if>
                        <if test='item.columnName!=null and item.columnName=="login_time"'>
                            "login_time"
                            <choose>
                                <when test='item.orderType=="desc"'>descwhen>
                                <otherwise>ascotherwise>
                            choose>
                            ,
                        if>
                        <if test='item.columnName!=null and item.columnName=="last_login_time"'>
                            "last_login_time"
                            <choose>
                                <when test='item.orderType=="desc"'>descwhen>
                                <otherwise>ascotherwise>
                            choose>
                            ,
                        if>
                        <if test='item.columnName!=null and item.columnName=="region_id"'>
                            "region_id"
                            <choose>
                                <when test='item.orderType=="desc"'>descwhen>
                                <otherwise>ascotherwise>
                            choose>
                            ,
                        if>
                        <if test='item.columnName!=null and item.columnName=="address"'>
                            "address"
                            <choose>
                                <when test='item.orderType=="desc"'>descwhen>
                                <otherwise>ascotherwise>
                            choose>
                            ,
                        if>
                        <if test='item.columnName!=null and item.columnName=="member_status"'>
                            "member_status"
                            <choose>
                                <when test='item.orderType=="desc"'>descwhen>
                                <otherwise>ascotherwise>
                            choose>
                            ,
                        if>
                        <if test='item.columnName!=null and item.columnName=="data_completed"'>
                            "data_completed"
                            <choose>
                                <when test='item.orderType=="desc"'>descwhen>
                                <otherwise>ascotherwise>
                            choose>
                            ,
                        if>
                    foreach>
                trim>
            when>
            <otherwise>
                order by "id" desc
            otherwise>
        choose>

        <if test="_parameter !=null">
            <if test="condition.pager_begin_index != null and condition.pager_limit !=null">
                limit #{condition.pager_limit} offset #{condition.pager_begin_index}
            if>
        if>
    select>

    <select id="fetchSize" resultType="Integer">
        select

        count(*)

        from member

        <if test="condition != null">
            <trim prefix="where" prefixOverrides="and |or">
                <include refid="base_where_condition_for_Member"/>
            trim>
        if>
    select>


    
    <insert id="writeEntireRecord">
        insert into member
        <include refid="base_write_entire_values_for_Member"/>
    insert>


    <update id="updateRecordByCondition">
        UPDATE member
        <trim prefix="set" suffixOverrides=",">
            <include refid="base_update_set_values_for_Member"/>
        trim>
        WHERE
        <trim prefix="" prefixOverrides="and |or">
            <include refid="base_where_condition_for_Member"/>
        trim>

    update>

    <update id="clearColumnByCondition">
        UPDATE member
        set
        <trim prefix="" suffixOverrides=",">
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="name"'>"name"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="email"'>"email"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="mobile"'>"mobile"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="password"'>"password"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="avatar"'>"avatar"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="regist_time"'>"regist_time"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="token"'>"token"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="longitude"'>"longitude"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="latitude"'>"latitude"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="wxopenid"'>"wxopenid"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="unionid"'>"unionid"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="qqkey"'>"qqkey"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="login_time"'>"login_time"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="last_login_time"'>"last_login_time"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="region_id"'>"region_id"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="address"'>"address"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="member_status"'>"member_status"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="data_completed"'>"data_completed"=null,if>
            foreach>
        trim>
        WHERE
        <trim prefix="" prefixOverrides="and |or">
            <include refid="base_where_condition_for_Member"/>
        trim>
    update>


    <delete id="deleteByCondition">
        delete from member
        WHERE
        <if test="_parameter != null">
            <trim prefix="" prefixOverrides="and |or">
                <include refid="base_where_condition_for_Member"/>
            trim>
        if>
    delete>


    

    

    <insert id="insertRecord">

        <selectKey keyProperty="model.id" resultType="java.lang.Long" order="AFTER">
            
            SELECT currval('member_id_seq')
        selectKey>


        insert into member
        <include refid="base_insert_values_for_Member"/>
    insert>
    
    <update id="updateRecord">
        UPDATE member
        <trim prefix="set" suffixOverrides=",">
            <include refid="base_update_set_values_for_Member"/>
        trim>
        WHERE "id"=#{model.id}
    update>

    <update id="clearColumnById">
        UPDATE member
        set
        <trim prefix="" suffixOverrides=",">
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="name"'>"name"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="email"'>"email"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="mobile"'>"mobile"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="password"'>"password"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="avatar"'>"avatar"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="regist_time"'>"regist_time"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="token"'>"token"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="longitude"'>"longitude"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="latitude"'>"latitude"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="wxopenid"'>"wxopenid"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="unionid"'>"unionid"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="qqkey"'>"qqkey"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="login_time"'>"login_time"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="last_login_time"'>"last_login_time"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="region_id"'>"region_id"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="address"'>"address"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="member_status"'>"member_status"=null,if>
            foreach>
            <foreach item="item" index="index" collection="list" open="" separator="," close="">
                <if test='item=="data_completed"'>"data_completed"=null,if>
            foreach>
        trim>
        WHERE "id"=#{id}
    update>

    <select id="fetchDetail" resultType="net.w2p.MicroBase.vo.account.Member"
            parameterType="int">
        select
        *
        from member
        <trim prefix="where" prefixOverrides="and |or">
            id = #{id}
        trim>
    select>


    <delete id="deleteRecord" parameterType="Long">
            delete from member
            WHERE "id"=#{id}
        delete>
    


    
    <sql id="base_where_condition_for_Member">
        
        <if test="condition.id!=null and condition.id.EQUAL_TO!=null">
            
        if>
        <if test="condition.id!=null and condition.id.NOT_EQUAL_TO!=null">
             #{condition.id.NOT_EQUAL_TO} ]]>
        if>
        <if test="condition.id!=null and condition.id.MORE_THAN!=null">
             #{condition.id.MORE_THAN}]]>
        if>
        <if test="condition.id!=null and condition.id.LESS_THAN!=null">
            
        if>
        <if test="condition.id!=null and condition.id.IN!=null">
            and "id" in
            <foreach collection="condition.id.IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>
        <if test="condition.id!=null and condition.id.NOT_IN!=null">
            and "id" not in
            <foreach collection="condition.id.NOT_IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>

        <if test="condition.name!=null and condition.name.EQUAL_TO!=null">
            
        if>
        <if test="condition.name!=null and condition.name.NOT_EQUAL_TO!=null">
             #{condition.name.NOT_EQUAL_TO} ]]>
        if>
        <if test="condition.name!=null and condition.name.LIKE!=null">
            and "name" LIKE CONCAT('%',#{condition.name.LIKE},'%')
        if>
        <if test="condition.name!=null and condition.name.IN!=null">
            and "name" in
            <foreach collection="condition.name.IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>
        <if test="condition.name!=null and condition.name.NOT_IN!=null">
            and "name" not in
            <foreach collection="condition.name.NOT_IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>
        <if test="condition.email!=null and condition.email.EQUAL_TO!=null">
            
        if>
        <if test="condition.email!=null and condition.email.NOT_EQUAL_TO!=null">
             #{condition.email.NOT_EQUAL_TO} ]]>
        if>
        <if test="condition.email!=null and condition.email.LIKE!=null">
            and "email" LIKE CONCAT('%',#{condition.email.LIKE},'%')
        if>
        <if test="condition.email!=null and condition.email.IN!=null">
            and "email" in
            <foreach collection="condition.email.IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>
        <if test="condition.email!=null and condition.email.NOT_IN!=null">
            and "email" not in
            <foreach collection="condition.email.NOT_IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>
        <if test="condition.mobile!=null and condition.mobile.EQUAL_TO!=null">
            
        if>
        <if test="condition.mobile!=null and condition.mobile.NOT_EQUAL_TO!=null">
             #{condition.mobile.NOT_EQUAL_TO} ]]>
        if>
        <if test="condition.mobile!=null and condition.mobile.LIKE!=null">
            and "mobile" LIKE CONCAT('%',#{condition.mobile.LIKE},'%')
        if>
        <if test="condition.mobile!=null and condition.mobile.IN!=null">
            and "mobile" in
            <foreach collection="condition.mobile.IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>
        <if test="condition.mobile!=null and condition.mobile.NOT_IN!=null">
            and "mobile" not in
            <foreach collection="condition.mobile.NOT_IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>
        <if test="condition.password!=null and condition.password.EQUAL_TO!=null">
            
        if>
        <if test="condition.password!=null and condition.password.NOT_EQUAL_TO!=null">
             #{condition.password.NOT_EQUAL_TO} ]]>
        if>
        <if test="condition.password!=null and condition.password.LIKE!=null">
            and "password" LIKE CONCAT('%',#{condition.password.LIKE},'%')
        if>
        <if test="condition.password!=null and condition.password.IN!=null">
            and "password" in
            <foreach collection="condition.password.IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>
        <if test="condition.password!=null and condition.password.NOT_IN!=null">
            and "password" not in
            <foreach collection="condition.password.NOT_IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>
        <if test="condition.avatar!=null and condition.avatar.EQUAL_TO!=null">
            
        if>
        <if test="condition.avatar!=null and condition.avatar.NOT_EQUAL_TO!=null">
             #{condition.avatar.NOT_EQUAL_TO} ]]>
        if>
        <if test="condition.avatar!=null and condition.avatar.LIKE!=null">
            and "avatar" LIKE CONCAT('%',#{condition.avatar.LIKE},'%')
        if>
        <if test="condition.avatar!=null and condition.avatar.IN!=null">
            and "avatar" in
            <foreach collection="condition.avatar.IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>
        <if test="condition.avatar!=null and condition.avatar.NOT_IN!=null">
            and "avatar" not in
            <foreach collection="condition.avatar.NOT_IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>
        <if test="condition.regist_time!=null and condition.regist_time.EQUAL_TO!=null">
            
        if>
        <if test="condition.regist_time!=null and condition.regist_time.NOT_EQUAL_TO!=null">
             #{condition.regist_time.NOT_EQUAL_TO} ]]>
        if>
        <if test="condition.regist_time!=null and condition.regist_time.MORE_THAN!=null">
             #{condition.regist_time.MORE_THAN}]]>
        if>
        <if test="condition.regist_time!=null and condition.regist_time.LESS_THAN!=null">
            
        if>
        <if test="condition.token!=null and condition.token.EQUAL_TO!=null">
            
        if>
        <if test="condition.token!=null and condition.token.NOT_EQUAL_TO!=null">
             #{condition.token.NOT_EQUAL_TO} ]]>
        if>
        <if test="condition.token!=null and condition.token.LIKE!=null">
            and "token" LIKE CONCAT('%',#{condition.token.LIKE},'%')
        if>
        <if test="condition.token!=null and condition.token.IN!=null">
            and "token" in
            <foreach collection="condition.token.IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>
        <if test="condition.token!=null and condition.token.NOT_IN!=null">
            and "token" not in
            <foreach collection="condition.token.NOT_IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>
        <if test="condition.longitude!=null and condition.longitude.EQUAL_TO!=null">
            
        if>
        <if test="condition.longitude!=null and condition.longitude.NOT_EQUAL_TO!=null">
             #{condition.longitude.NOT_EQUAL_TO} ]]>
        if>
        <if test="condition.longitude!=null and condition.longitude.MORE_THAN!=null">
             #{condition.longitude.MORE_THAN}]]>
        if>
        <if test="condition.longitude!=null and condition.longitude.LESS_THAN!=null">
            
        if>
        <if test="condition.longitude!=null and condition.longitude.IN!=null">
            and "longitude" in
            <foreach collection="condition.longitude.IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>
        <if test="condition.longitude!=null and condition.longitude.NOT_IN!=null">
            and "longitude" not in
            <foreach collection="condition.longitude.NOT_IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>

        <if test="condition.latitude!=null and condition.latitude.EQUAL_TO!=null">
            
        if>
        <if test="condition.latitude!=null and condition.latitude.NOT_EQUAL_TO!=null">
             #{condition.latitude.NOT_EQUAL_TO} ]]>
        if>
        <if test="condition.latitude!=null and condition.latitude.MORE_THAN!=null">
             #{condition.latitude.MORE_THAN}]]>
        if>
        <if test="condition.latitude!=null and condition.latitude.LESS_THAN!=null">
            
        if>
        <if test="condition.latitude!=null and condition.latitude.IN!=null">
            and "latitude" in
            <foreach collection="condition.latitude.IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>
        <if test="condition.latitude!=null and condition.latitude.NOT_IN!=null">
            and "latitude" not in
            <foreach collection="condition.latitude.NOT_IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>

        <if test="condition.wxopenid!=null and condition.wxopenid.EQUAL_TO!=null">
            
        if>
        <if test="condition.wxopenid!=null and condition.wxopenid.NOT_EQUAL_TO!=null">
             #{condition.wxopenid.NOT_EQUAL_TO} ]]>
        if>
        <if test="condition.wxopenid!=null and condition.wxopenid.LIKE!=null">
            and "wxopenid" LIKE CONCAT('%',#{condition.wxopenid.LIKE},'%')
        if>
        <if test="condition.wxopenid!=null and condition.wxopenid.IN!=null">
            and "wxopenid" in
            <foreach collection="condition.wxopenid.IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>
        <if test="condition.wxopenid!=null and condition.wxopenid.NOT_IN!=null">
            and "wxopenid" not in
            <foreach collection="condition.wxopenid.NOT_IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>
        <if test="condition.unionid!=null and condition.unionid.EQUAL_TO!=null">
            
        if>
        <if test="condition.unionid!=null and condition.unionid.NOT_EQUAL_TO!=null">
             #{condition.unionid.NOT_EQUAL_TO} ]]>
        if>
        <if test="condition.unionid!=null and condition.unionid.LIKE!=null">
            and "unionid" LIKE CONCAT('%',#{condition.unionid.LIKE},'%')
        if>
        <if test="condition.unionid!=null and condition.unionid.IN!=null">
            and "unionid" in
            <foreach collection="condition.unionid.IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>
        <if test="condition.unionid!=null and condition.unionid.NOT_IN!=null">
            and "unionid" not in
            <foreach collection="condition.unionid.NOT_IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>
        <if test="condition.qqkey!=null and condition.qqkey.EQUAL_TO!=null">
            
        if>
        <if test="condition.qqkey!=null and condition.qqkey.NOT_EQUAL_TO!=null">
             #{condition.qqkey.NOT_EQUAL_TO} ]]>
        if>
        <if test="condition.qqkey!=null and condition.qqkey.LIKE!=null">
            and "qqkey" LIKE CONCAT('%',#{condition.qqkey.LIKE},'%')
        if>
        <if test="condition.qqkey!=null and condition.qqkey.IN!=null">
            and "qqkey" in
            <foreach collection="condition.qqkey.IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>
        <if test="condition.qqkey!=null and condition.qqkey.NOT_IN!=null">
            and "qqkey" not in
            <foreach collection="condition.qqkey.NOT_IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>
        <if test="condition.login_time!=null and condition.login_time.EQUAL_TO!=null">
            
        if>
        <if test="condition.login_time!=null and condition.login_time.NOT_EQUAL_TO!=null">
             #{condition.login_time.NOT_EQUAL_TO} ]]>
        if>
        <if test="condition.login_time!=null and condition.login_time.MORE_THAN!=null">
             #{condition.login_time.MORE_THAN}]]>
        if>
        <if test="condition.login_time!=null and condition.login_time.LESS_THAN!=null">
            
        if>
        <if test="condition.last_login_time!=null and condition.last_login_time.EQUAL_TO!=null">
            
        if>
        <if test="condition.last_login_time!=null and condition.last_login_time.NOT_EQUAL_TO!=null">
             #{condition.last_login_time.NOT_EQUAL_TO} ]]>
        if>
        <if test="condition.last_login_time!=null and condition.last_login_time.MORE_THAN!=null">
             #{condition.last_login_time.MORE_THAN}]]>
        if>
        <if test="condition.last_login_time!=null and condition.last_login_time.LESS_THAN!=null">
            
        if>
        <if test="condition.region_id!=null and condition.region_id.EQUAL_TO!=null">
            
        if>
        <if test="condition.region_id!=null and condition.region_id.NOT_EQUAL_TO!=null">
             #{condition.region_id.NOT_EQUAL_TO} ]]>
        if>
        <if test="condition.region_id!=null and condition.region_id.MORE_THAN!=null">
             #{condition.region_id.MORE_THAN}]]>
        if>
        <if test="condition.region_id!=null and condition.region_id.LESS_THAN!=null">
            
        if>
        <if test="condition.region_id!=null and condition.region_id.IN!=null">
            and "region_id" in
            <foreach collection="condition.region_id.IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>
        <if test="condition.region_id!=null and condition.region_id.NOT_IN!=null">
            and "region_id" not in
            <foreach collection="condition.region_id.NOT_IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>

        <if test="condition.address!=null and condition.address.EQUAL_TO!=null">
            
        if>
        <if test="condition.address!=null and condition.address.NOT_EQUAL_TO!=null">
             #{condition.address.NOT_EQUAL_TO} ]]>
        if>
        <if test="condition.address!=null and condition.address.LIKE!=null">
            and "address" LIKE CONCAT('%',#{condition.address.LIKE},'%')
        if>
        <if test="condition.address!=null and condition.address.IN!=null">
            and "address" in
            <foreach collection="condition.address.IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>
        <if test="condition.address!=null and condition.address.NOT_IN!=null">
            and "address" not in
            <foreach collection="condition.address.NOT_IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>
        <if test="condition.member_status!=null and condition.member_status.EQUAL_TO!=null">
            
        if>
        <if test="condition.member_status!=null and condition.member_status.NOT_EQUAL_TO!=null">
             #{condition.member_status.NOT_EQUAL_TO} ]]>
        if>
        <if test="condition.member_status!=null and condition.member_status.MORE_THAN!=null">
             #{condition.member_status.MORE_THAN}]]>
        if>
        <if test="condition.member_status!=null and condition.member_status.LESS_THAN!=null">
            
        if>
        <if test="condition.member_status!=null and condition.member_status.IN!=null">
            and "member_status" in
            <foreach collection="condition.member_status.IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>
        <if test="condition.member_status!=null and condition.member_status.NOT_IN!=null">
            and "member_status" not in
            <foreach collection="condition.member_status.NOT_IN" index="index"
                     item="item" open="(" separator="," close=")">#{item}
            foreach>
        if>

        <if test="condition.data_completed!=null and condition.data_completed.EQUAL_TO!=null">
            
        if>
        <if test="condition.data_completed!=null and condition.data_completed.NOT_EQUAL_TO!=null">
             #{condition.data_completed.NOT_EQUAL_TO} ]]>
        if>

    sql>

    <sql id="base_update_set_values_for_Member">
        <if test="model.name!=null">"name"=#{model.name},if>

        <if test="model.email!=null">"email"=#{model.email},if>

        <if test="model.mobile!=null">"mobile"=#{model.mobile},if>

        <if test="model.password!=null">"password"=#{model.password},if>

        <if test="model.avatar!=null">"avatar"=#{model.avatar},if>

        <if test="model.regist_time!=null">"regist_time"=#{model.regist_time},if>

        <if test="model.token!=null">"token"=#{model.token},if>

        <if test="model.longitude!=null">"longitude"=#{model.longitude},if>

        <if test="model.latitude!=null">"latitude"=#{model.latitude},if>

        <if test="model.wxopenid!=null">"wxopenid"=#{model.wxopenid},if>

        <if test="model.unionid!=null">"unionid"=#{model.unionid},if>

        <if test="model.qqkey!=null">"qqkey"=#{model.qqkey},if>

        <if test="model.login_time!=null">"login_time"=#{model.login_time},if>

        <if test="model.last_login_time!=null">"last_login_time"=#{model.last_login_time},if>

        <if test="model.region_id!=null">"region_id"=#{model.region_id},if>

        <if test="model.address!=null">"address"=#{model.address},if>

        <if test="model.member_status!=null">"member_status"=#{model.member_status},if>

        <if test="model.data_completed!=null">"data_completed"=#{model.data_completed},if>

    sql>


    <sql id="base_insert_values_for_Member">
        (

        <trim prefix="" suffixOverrides=",">
            "name",
            "email",
            "mobile",
            "password",
            "avatar",
            "regist_time",
            "token",
            "longitude",
            "latitude",
            "wxopenid",
            "unionid",
            "qqkey",
            "login_time",
            "last_login_time",
            "region_id",
            "address",
            "member_status",
            "data_completed",
        trim>
        )
        values
        (
        <trim prefix="" suffixOverrides=",">
            #{model.name},

            #{model.email},

            #{model.mobile},

            #{model.password},

            #{model.avatar},

            #{model.regist_time},

            #{model.token},

            #{model.longitude},

            #{model.latitude},

            #{model.wxopenid},

            #{model.unionid},

            #{model.qqkey},

            #{model.login_time},

            #{model.last_login_time},

            #{model.region_id},

            #{model.address},

            #{model.member_status},

            #{model.data_completed},


        trim>
        )
    sql>

    <sql id="base_write_entire_values_for_Member">
        (

        <trim prefix="" suffixOverrides=",">
            "id",
            "name",
            "email",
            "mobile",
            "password",
            "avatar",
            "regist_time",
            "token",
            "longitude",
            "latitude",
            "wxopenid",
            "unionid",
            "qqkey",
            "login_time",
            "last_login_time",
            "region_id",
            "address",
            "member_status",
            "data_completed",
        trim>
        )
        values
        (
        <trim prefix="" suffixOverrides=",">
            #{model.id},
            #{model.name},

            #{model.email},

            #{model.mobile},

            #{model.password},

            #{model.avatar},

            #{model.regist_time},

            #{model.token},

            #{model.longitude},

            #{model.latitude},

            #{model.wxopenid},

            #{model.unionid},

            #{model.qqkey},

            #{model.login_time},

            #{model.last_login_time},

            #{model.region_id},

            #{model.address},

            #{model.member_status},

            #{model.data_completed},


        trim>
        )
    sql>

mapper>

dao层的MemberMapper.java

package net.w2p.MicroBase.dao.account;
import net.w2p.MicroBase.dao.account.MemberMapper;
import net.w2p.MicroBase.model.account.MemberModel;
import net.w2p.MicroBase.vo.account.Member;
import net.w2p.MicroBase.searcher.account.MemberCondition;
import org.apache.ibatis.annotations.Param;

import java.util.ArrayList;
import java.util.List;
public interface MemberMapper {

    //--通用方法
    public ArrayList simpleSearch(@Param(value="condition")MemberCondition condition);
    public Integer fetchSize(@Param(value="condition")MemberCondition condition);
    public int writeEntireRecord(@Param(value="model")MemberModel model);
    public int updateRecordByCondition(@Param(value="model")MemberModel model,@Param(value="condition")MemberCondition condition);
    public int deleteByCondition(@Param(value = "condition") MemberCondition condition);
    public int clearColumnByCondition(@Param(value="condition")MemberCondition condition,@Param(value="list")ArrayList columns);

            //--以下方法只有拥有主键的表才能使用。
        public Member fetchDetail(@Param(value="id")Long id);
        public int insertRecord(@Param(value="model")MemberModel model);
        public int updateRecord(@Param(value="model")MemberModel model);
        public int deleteRecord(@Param(value = "id") Long id);
        public int clearColumnById(@Param(value="id")Long id,@Param(value="list")ArrayList columns);


    }

服务实现层serviceImpl,虽然这个层是先继承service层,但service层等下跟子项目一起说。

package net.w2p.MicroBase.serviceImpl.account;
import net.w2p.MicroBase.dao.account.MemberMapper;
import net.w2p.MicroBase.model.account.MemberModel;
import net.w2p.MicroBase.service.account.MemberService;
import net.w2p.MicroBase.vo.account.Member;
import net.w2p.MicroBase.searcher.account.MemberCondition;
import net.funfunle.common.PagerResult;
import net.funfunle.common.ValidateUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import net.funfunle.common.WebTools;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.SqlSession;
import net.funfunle.queries.BooleanCondition;
import net.funfunle.queries.NumberCondition;
import org.apache.commons.lang.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.funfunle.common.OpResult;
import org.apache.log4j.Logger;
import net.funfunle.common.IdentifyGenerator;
import net.funfunle.queries.StringCondition;
import java.sql.Timestamp;
import net.funfunle.queries.*;
import java.util.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
//import org.springframework.stereotype.Service;
import org.springframework.stereotype.Component;
import com.alibaba.dubbo.config.annotation.Service;

public class MemberServiceImpl implements MemberService {

private static final String serial_name="member";
private Logger logger=Logger.getLogger(this.getClass());
@Autowired
private MemberMapper mapper;

/**
* 获取搜索分页列表
* @param condition 条件。
* ***/
public PagerResult getPager(Integer pageIndex,Integer pageSize,MemberCondition condition){
PagerResult pager=new PagerResult();
//--获取总条数。
Integer total = mapper.fetchSize(condition);
pager=WebTools.calculatePages(pageIndex,pageSize,total);
condition.setPager_begin_index(pager.getBegin_index());
condition.setPager_limit(pager.getLimit());
//--获取记录。
ArrayList list= simpleSearch(condition);
pager.setData(list);
return pager;
}

/**
* 获取搜索分页列表
* @param condition 条件。
* ***/
public Integer  getSize(MemberCondition condition){
Integer total = mapper.fetchSize(condition);
return total;
}

public ArrayList simpleSearch(MemberCondition condition){
return simpleSearch(condition,true);
}
/**
* 获取搜索分页列表
* @param condition 条件。
* ***/
public ArrayList simpleSearch(MemberCondition condition,Boolean needCompleteInfo){

//--获取记录。
ArrayList list= mapper.simpleSearch(condition);
if(needCompleteInfo){
completeInfo(list);
}

return list;
}


/**
* 更新记录
* 更新满足条件的记录--请注意,该方法需要手动提交,sqlSession.commit
* @param condition 条件
* ***/
public OpResult writeEntireRecord(MemberModel model,Boolean
autoCommit) throws Exception {
OpResult opResult=new OpResult();
//--获取记录。

int effs= mapper.writeEntireRecord(model);
if(autoCommit){
}
if(effs<=0){
WebTools.setOpError(opResult,"无法插入记录");
return opResult;
}
WebTools.setOpSuccess(opResult,"成功插入记录");
return opResult;

}


/**
* 更新记录
* 更新满足条件的记录--请注意,该方法需要手动提交,sqlSession.commit
* @param condition 条件
* ***/
public OpResult updateByCondition(MemberModel model,MemberCondition condition,Boolean
autoCommit) throws Exception {
OpResult opResult=new OpResult();
//--获取记录。

int effs= mapper.updateRecordByCondition(model, condition);

if(effs<=0){
WebTools.setOpError(opResult,"无法更新记录");
return opResult;
}
WebTools.setOpSuccess(opResult,"成功更新记录");
return opResult;

}

/**
* 根据条件清空某些数据记录的列为null
*
* @param condition 条件
* ***/
public OpResult clearColumnByCondition(MemberCondition condition,ArrayList
 columns,Boolean autoCommit) throws Exception{

    OpResult opResult=new OpResult();

    //--获取记录。

    int effs= mapper.clearColumnByCondition(condition,columns);
    if(autoCommit){
    }
    if(effs<=0){
    WebTools.setOpError(opResult,"无法保存");
    return opResult;
    }
    WebTools.setOpSuccess(opResult,"成功保存");
    return opResult;
    }

    /**
    * 删除记录
    * 删除满足条件的记录--请注意,该方法需要手动提交,sqlSession.commit
    * @param condition 删除条件
    * ***/
    public OpResult deleteByCondition(MemberCondition condition,Boolean
    autoCommit) throws Exception {

    OpResult opResult=new OpResult();

    //--获取记录。

    int effs= mapper.deleteByCondition(condition);
    if(autoCommit){

    }
    if(effs<=0){
    WebTools.setOpError(opResult, "无法删除记录");
    return opResult;
    }
    WebTools.setOpSuccess(opResult,"成功删除记录");
    return opResult;

    }


    /***crud模式生成 begin***/

    /**
    * 获取记录详情
    * @param id 主键id
    * ***/
    public Member getDetail(Long id){
    return getDetail(id,true);
    }

    public Member getDetail(Long id,Boolean needCompleteInfo){

    Member model;
    model= mapper.fetchDetail(id);
    if(model!=null){
    ArrayList list=new ArrayList();
    list.add(model);
    if(needCompleteInfo){
    completeInfo(list);
    }

    }
    return model;
    }
    /**
    * 获取对应几条记录。是getPager的简化版。
    * @param ids 主键条件

    * ***/
    public PagerResult fetchListByIds(List ids){

    String ids_str=StringUtils.join(ids,",");
    PagerResult pager=new PagerResult();
    //--获取总条数。
    //--获取记录。
    MemberCondition condition=new MemberCondition();
            condition.setId(new NumberCondition().condition_in(WebTools.getObjectListByLongArr(ids)));

    ArrayList list= mapper.simpleSearch(condition);
    pager.setData(list);
    return pager;
    }


    /**
    * 添加记录
    * @param model 模型
    * ***/
    public OpResult insertRecord(MemberModel model) throws Exception{
    return insertRecord(model, true);
    }


    /**
    * 添加记录
    * @param model 模型
    * ***/
    public OpResult insertRecord(MemberModel model,Boolean autoCommit) throws Exception{
    OpResult opResult=new OpResult();


    //--获取记录。

    int effs= mapper.insertRecord(model);
    if(autoCommit){
    }
    if(effs<=0){
    WebTools.setOpError(opResult,"无法插入记录");
    return opResult;
    }
    WebTools.setOpSuccess(opResult,"成功保存记录");
    opResult.setData(model);
    return opResult;

    }

    /**
    * 更新模型,更新一条记录,请注意,这是根据id主键来更新模型的,
    * 假如字段为null就不更新。
    * @param model 模型
    * ***/
    public OpResult updateRecord(MemberModel model) throws Exception{
    return updateRecord(model,true);
    }


    /**
    * 更新模型,更新一条记录,请注意,这是根据id主键来更新模型的,
    * 假如字段为null就不更新。
    * @param model 模型
    * ***/
    public OpResult updateRecord(MemberModel model,Boolean autoCommit) throws Exception {

    OpResult opResult=new OpResult();


    //--获取记录。

    int effs= mapper.updateRecord(model);
    if(autoCommit){
    }
    if(effs<=0){
    WebTools.setOpError(opResult,"无法插入记录");
    return opResult;
    }
    WebTools.setOpSuccess(opResult,"成功保存记录");
    opResult.setData(model);
    return opResult;

    }
    /**
    * 清空某一行数据记录的列为null
    * 某个id的记录
    * @param id 模型id
    * ***/
    public OpResult clearColumnById(Long id,ArrayList
 columns,Boolean autoCommit) throws Exception{

    OpResult opResult=new OpResult();

    //--获取记录。

    int effs= mapper.clearColumnById(id,columns);
    if(autoCommit){
    }
    if(effs<=0){
    WebTools.setOpError(opResult,"无法保存");
    return opResult;
    }
    WebTools.setOpSuccess(opResult, "成功保存");
    return opResult;
    }


    /**
    * 删除记录
    * 删除某个id的记录
    * @param id 模型id
    * ***/
    public OpResult deleteRecord(Long id,Boolean
    autoCommit) throws Exception{

    OpResult opResult=new OpResult();



    //--获取记录。

    int effs= mapper.deleteRecord(id);
    if(autoCommit){

    }
    if(effs<=0){
    WebTools.setOpError(opResult,"无法删除记录");
    return opResult;
    }
    WebTools.setOpSuccess(opResult,"成功删除记录");
    return opResult;


    }

    /***crud模式生成 end***/






        private void completeInfo(ArrayList list){
        if(list==null||list.size()<1){

        return;
        }


        }

        }

父项目配置大体介绍完毕。

MicroBaseApi子项目结构解释

model层:

package net.w2p.MicroBase.model.account;
import java.util.Date;
import java.sql.*;
import java.util.List;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import java.sql.Timestamp;
public class MemberModel  implements java.io.Serializable {

public MemberModel(){
this.setNULL();
}

public   Long  id=0L;
public void setId(Long id){
    this.id=id;
}
public Long getId(){
    return this.id;
}
public   String  name="";
public void setName(String name){
    this.name=name;
}
public String getName(){
    return this.name;
}
public   String  email="";
public void setEmail(String email){
    this.email=email;
}
public String getEmail(){
    return this.email;
}
public   String  mobile="";
public void setMobile(String mobile){
    this.mobile=mobile;
}
public String getMobile(){
    return this.mobile;
}
public   String  password="";
public void setPassword(String password){
    this.password=password;
}
public String getPassword(){
    return this.password;
}
public   String  avatar="";
public void setAvatar(String avatar){
    this.avatar=avatar;
}
public String getAvatar(){
    return this.avatar;
}
public   Timestamp  regist_time=new Timestamp(new Date().getTime());
public void setRegist_time(Timestamp regist_time){
    this.regist_time=regist_time;
}
public Timestamp getRegist_time(){
    return this.regist_time;
}
public   String  token="";
public void setToken(String token){
    this.token=token;
}
public String getToken(){
    return this.token;
}
public   Double  longitude=0.0;
public void setLongitude(Double longitude){
    this.longitude=longitude;
}
public Double getLongitude(){
    return this.longitude;
}
public   Double  latitude=0.0;
public void setLatitude(Double latitude){
    this.latitude=latitude;
}
public Double getLatitude(){
    return this.latitude;
}
public   String  wxopenid="";
public void setWxopenid(String wxopenid){
    this.wxopenid=wxopenid;
}
public String getWxopenid(){
    return this.wxopenid;
}
public   String  unionid="";
public void setUnionid(String unionid){
    this.unionid=unionid;
}
public String getUnionid(){
    return this.unionid;
}
public   String  qqkey="";
public void setQqkey(String qqkey){
    this.qqkey=qqkey;
}
public String getQqkey(){
    return this.qqkey;
}
public   Timestamp  login_time=new Timestamp(new Date().getTime());
public void setLogin_time(Timestamp login_time){
    this.login_time=login_time;
}
public Timestamp getLogin_time(){
    return this.login_time;
}
public   Timestamp  last_login_time=new Timestamp(new Date().getTime());
public void setLast_login_time(Timestamp last_login_time){
    this.last_login_time=last_login_time;
}
public Timestamp getLast_login_time(){
    return this.last_login_time;
}
public   Long  region_id=0L;
public void setRegion_id(Long region_id){
    this.region_id=region_id;
}
public Long getRegion_id(){
    return this.region_id;
}
public   String  address="";
public void setAddress(String address){
    this.address=address;
}
public String getAddress(){
    return this.address;
}
public   Integer  member_status=0;
public void setMember_status(Integer member_status){
    this.member_status=member_status;
}
public Integer getMember_status(){
    return this.member_status;
}
public   Boolean  data_completed=false;
public void setData_completed(Boolean data_completed){
    this.data_completed=data_completed;
}
public Boolean getData_completed(){
    return this.data_completed;
}


public void setNULL(){
    this.id=null;
    this.name=null;
    this.email=null;
    this.mobile=null;
    this.password=null;
    this.avatar=null;
    this.regist_time=null;
    this.token=null;
    this.longitude=null;
    this.latitude=null;
    this.wxopenid=null;
    this.unionid=null;
    this.qqkey=null;
    this.login_time=null;
    this.last_login_time=null;
    this.region_id=null;
    this.address=null;
    this.member_status=null;
    this.data_completed=null;
}

public void resetDefaultVal(){
    this.id=0L;
    this.name="";
    this.email="";
    this.mobile="";
    this.password="";
    this.avatar="";
    this.regist_time=new Timestamp(new Date().getTime());
    this.token="";
    this.longitude=0.0;
    this.latitude=0.0;
    this.wxopenid="";
    this.unionid="";
    this.qqkey="";
    this.login_time=new Timestamp(new Date().getTime());
    this.last_login_time=new Timestamp(new Date().getTime());
    this.region_id=0L;
    this.address="";
    this.member_status=0;
    this.data_completed=false;
}


}

vo层:

package net.w2p.MicroBase.vo.account;
import java.util.Date;
import java.sql.*;
import java.util.List;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import java.sql.Timestamp;

public class Member implements java.io.Serializable {

public   Long  id=0L;
public void setId(Long id){
this.id=id;
}
public Long getId(){
return this.id;
}
public   String  name="";
public void setName(String name){
this.name=name;
}
public String getName(){
return this.name;
}
public   String  email="";
public void setEmail(String email){
this.email=email;
}
public String getEmail(){
return this.email;
}
public   String  mobile="";
public void setMobile(String mobile){
this.mobile=mobile;
}
public String getMobile(){
return this.mobile;
}
public   String  password="";
public void setPassword(String password){
this.password=password;
}
public String getPassword(){
return this.password;
}
public   String  avatar="";
public void setAvatar(String avatar){
this.avatar=avatar;
}
public String getAvatar(){
return this.avatar;
}
public   Timestamp  regist_time=new Timestamp(new Date().getTime());
public void setRegist_time(Timestamp regist_time){
this.regist_time=regist_time;
}
public Timestamp getRegist_time(){
return this.regist_time;
}
public   String  token="";
public void setToken(String token){
this.token=token;
}
public String getToken(){
return this.token;
}
public   Double  longitude=0.0;
public void setLongitude(Double longitude){
this.longitude=longitude;
}
public Double getLongitude(){
return this.longitude;
}
public   Double  latitude=0.0;
public void setLatitude(Double latitude){
this.latitude=latitude;
}
public Double getLatitude(){
return this.latitude;
}
public   String  wxopenid="";
public void setWxopenid(String wxopenid){
this.wxopenid=wxopenid;
}
public String getWxopenid(){
return this.wxopenid;
}
public   String  unionid="";
public void setUnionid(String unionid){
this.unionid=unionid;
}
public String getUnionid(){
return this.unionid;
}
public   String  qqkey="";
public void setQqkey(String qqkey){
this.qqkey=qqkey;
}
public String getQqkey(){
return this.qqkey;
}
public   Timestamp  login_time=new Timestamp(new Date().getTime());
public void setLogin_time(Timestamp login_time){
this.login_time=login_time;
}
public Timestamp getLogin_time(){
return this.login_time;
}
public   Timestamp  last_login_time=new Timestamp(new Date().getTime());
public void setLast_login_time(Timestamp last_login_time){
this.last_login_time=last_login_time;
}
public Timestamp getLast_login_time(){
return this.last_login_time;
}
public   Long  region_id=0L;
public void setRegion_id(Long region_id){
this.region_id=region_id;
}
public Long getRegion_id(){
return this.region_id;
}
public   String  address="";
public void setAddress(String address){
this.address=address;
}
public String getAddress(){
return this.address;
}
public   Integer  member_status=0;
public void setMember_status(Integer member_status){
this.member_status=member_status;
}
public Integer getMember_status(){
return this.member_status;
}
public   Boolean  data_completed=false;
public void setData_completed(Boolean data_completed){
this.data_completed=data_completed;
}
public Boolean getData_completed(){
return this.data_completed;
}


public void setNULL(){
this.id=null;
this.name=null;
this.email=null;
this.mobile=null;
this.password=null;
this.avatar=null;
this.regist_time=null;
this.token=null;
this.longitude=null;
this.latitude=null;
this.wxopenid=null;
this.unionid=null;
this.qqkey=null;
this.login_time=null;
this.last_login_time=null;
this.region_id=null;
this.address=null;
this.member_status=null;
this.data_completed=null;
}

public void resetDefaultVal(){
this.id=0L;
this.name="";
this.email="";
this.mobile="";
this.password="";
this.avatar="";
this.regist_time=new Timestamp(new Date().getTime());
this.token="";
this.longitude=0.0;
this.latitude=0.0;
this.wxopenid="";
this.unionid="";
this.qqkey="";
this.login_time=new Timestamp(new Date().getTime());
this.last_login_time=new Timestamp(new Date().getTime());
this.region_id=0L;
this.address="";
this.member_status=0;
this.data_completed=false;
}


}

service接口层:

package net.w2p.MicroBase.service.account;
import net.w2p.MicroBase.model.account.MemberModel;
import net.w2p.MicroBase.vo.account.Member;
import net.w2p.MicroBase.searcher.account.MemberCondition;
import net.funfunle.common.PagerResult;
import net.funfunle.common.ValidateUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import net.funfunle.common.WebTools;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.SqlSession;
import net.funfunle.queries.BooleanCondition;
import net.funfunle.queries.NumberCondition;
import org.apache.commons.lang.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.funfunle.common.OpResult;
import org.apache.log4j.Logger;
import net.funfunle.common.IdentifyGenerator;
import net.funfunle.queries.StringCondition;
import java.sql.Timestamp;
import net.funfunle.queries.*;
import java.util.*;

public interface MemberService {
/**
* 获取搜索分页列表
* @param condition 条件。
* ***/
public PagerResult getPager(Integer pageIndex,Integer pageSize,MemberCondition condition);

/**
* 获取搜索分页列表
* @param condition 条件。
* ***/
public Integer  getSize(MemberCondition condition);

public ArrayList simpleSearch(MemberCondition condition);
/**
* 获取搜索分页列表
* @param condition 条件。
* ***/
public ArrayList simpleSearch(MemberCondition condition,Boolean needCompleteInfo);


/**
* 更新记录
* 更新满足条件的记录--请注意,该方法需要手动提交,sqlSession.commit
* @param condition 条件
* ***/
public OpResult writeEntireRecord(MemberModel model,Boolean
autoCommit) throws Exception ;

/**
* 更新记录
* 更新满足条件的记录--请注意,该方法需要手动提交,sqlSession.commit
* @param condition 条件
* ***/
public OpResult updateByCondition(MemberModel model,MemberCondition condition,Boolean
autoCommit) throws Exception ;

/**
* 根据条件清空某些数据记录的列为null
*
* @param condition 条件
* ***/
public OpResult clearColumnByCondition(MemberCondition condition,ArrayList
 columns,Boolean autoCommit) throws Exception;

    /**
    * 删除记录
    * 删除满足条件的记录--请注意,该方法需要手动提交,sqlSession.commit
    * @param condition 删除条件
    * ***/
    public OpResult deleteByCondition(MemberCondition condition,Boolean
    autoCommit) throws Exception ;

            /**
        * 获取对应几条记录。是getPager的简化版。
        * @param ids 主键条件

        * ***/
        public PagerResult fetchListByIds(List ids);


        /**
        * 添加记录
        * @param model 模型
        * ***/
        public OpResult insertRecord(MemberModel model) throws Exception;


        /**
        * 添加记录
        * @param model 模型
        * ***/
        public OpResult insertRecord(MemberModel model,Boolean autoCommit) throws Exception;

        /**
        * 更新模型,更新一条记录,请注意,这是根据id主键来更新模型的,
        * 假如字段为null就不更新。
        * @param model 模型
        * ***/
        public OpResult updateRecord(MemberModel model) throws Exception;


        /**
        * 更新模型,更新一条记录,请注意,这是根据id主键来更新模型的,
        * 假如字段为null就不更新。
        * @param model 模型
        * ***/
        public OpResult updateRecord(MemberModel model,Boolean autoCommit) throws Exception ;
        /**
        * 清空某一行数据记录的列为null
        * 某个id的记录
        * @param id 模型id
        * ***/
        public OpResult clearColumnById(Long id,ArrayList columns,
        Boolean autoCommit) throws Exception;

        /**
        * 删除记录
        * 删除某个id的记录
        * @param id 模型id
        * ***/
        public OpResult deleteRecord(Long id,Boolean
        autoCommit) throws Exception;

}

sercher复杂搜索条件层。
值得注意的是,这个搜索条件是用来对单表进行各种复杂搜索的。

package net.w2p.MicroBase.searcher.account;

import net.w2p.MicroBase.model.account.MemberModel;
import net.w2p.MicroBase.vo.account.Member;

import net.funfunle.queries.ArrayCondition;
import net.funfunle.common.WebTools;
import java.io.Serializable;
import java.util.ArrayList;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import java.sql.Timestamp;
import net.funfunle.queries.*;
import org.apache.commons.lang.StringUtils;
import net.funfunle.common.RequestEnhance;
import net.funfunle.common.ValidateUtils;
import java.util.HashMap;
public class MemberCondition implements Serializable {
public static final String column_id="id";
public static final String column_name="name";
public static final String column_email="email";
public static final String column_mobile="mobile";
public static final String column_password="password";
public static final String column_avatar="avatar";
public static final String column_regist_time="regist_time";
public static final String column_token="token";
public static final String column_longitude="longitude";
public static final String column_latitude="latitude";
public static final String column_wxopenid="wxopenid";
public static final String column_unionid="unionid";
public static final String column_qqkey="qqkey";
public static final String column_login_time="login_time";
public static final String column_last_login_time="last_login_time";
public static final String column_region_id="region_id";
public static final String column_address="address";
public static final String column_member_status="member_status";
public static final String column_data_completed="data_completed";

/**
*分页相关。
**/
private Integer pager_begin_index=null;
private Integer pager_limit=null;

public Integer getPager_begin_index() {
return pager_begin_index;
}

public void setPager_begin_index(Integer pager_begin_index) {
this.pager_begin_index = pager_begin_index;
}

public Integer getPager_limit() {
return pager_limit;
}

public void setPager_limit(Integer pager_limit) {
this.pager_limit = pager_limit;
}
public ArrayList orderConditions=new ArrayList();

    public ArrayList getOrderConditions() {
        return orderConditions;
        }

        public void setOrderConditions(ArrayList orderConditions) {
            this.orderConditions = orderConditions;
            }



            private NumberCondition id;
        public void setId(NumberCondition id){
        this.id=id;
        }
        public NumberCondition getId(){
        return this.id;
        }
                private StringCondition name;
        public void setName(StringCondition name){
        this.name=name;
        }
        public StringCondition getName(){
        return this.name;
        }
                private StringCondition email;
        public void setEmail(StringCondition email){
        this.email=email;
        }
        public StringCondition getEmail(){
        return this.email;
        }
                private StringCondition mobile;
        public void setMobile(StringCondition mobile){
        this.mobile=mobile;
        }
        public StringCondition getMobile(){
        return this.mobile;
        }
                private StringCondition password;
        public void setPassword(StringCondition password){
        this.password=password;
        }
        public StringCondition getPassword(){
        return this.password;
        }
                private StringCondition avatar;
        public void setAvatar(StringCondition avatar){
        this.avatar=avatar;
        }
        public StringCondition getAvatar(){
        return this.avatar;
        }
                private TimeStampCondition regist_time;
        public void setRegist_time(TimeStampCondition regist_time){
        this.regist_time=regist_time;
        }
        public TimeStampCondition getRegist_time(){
        return this.regist_time;
        }
                private StringCondition token;
        public void setToken(StringCondition token){
        this.token=token;
        }
        public StringCondition getToken(){
        return this.token;
        }
                private NumberCondition longitude;
        public void setLongitude(NumberCondition longitude){
        this.longitude=longitude;
        }
        public NumberCondition getLongitude(){
        return this.longitude;
        }
                private NumberCondition latitude;
        public void setLatitude(NumberCondition latitude){
        this.latitude=latitude;
        }
        public NumberCondition getLatitude(){
        return this.latitude;
        }
                private StringCondition wxopenid;
        public void setWxopenid(StringCondition wxopenid){
        this.wxopenid=wxopenid;
        }
        public StringCondition getWxopenid(){
        return this.wxopenid;
        }
                private StringCondition unionid;
        public void setUnionid(StringCondition unionid){
        this.unionid=unionid;
        }
        public StringCondition getUnionid(){
        return this.unionid;
        }
                private StringCondition qqkey;
        public void setQqkey(StringCondition qqkey){
        this.qqkey=qqkey;
        }
        public StringCondition getQqkey(){
        return this.qqkey;
        }
                private TimeStampCondition login_time;
        public void setLogin_time(TimeStampCondition login_time){
        this.login_time=login_time;
        }
        public TimeStampCondition getLogin_time(){
        return this.login_time;
        }
                private TimeStampCondition last_login_time;
        public void setLast_login_time(TimeStampCondition last_login_time){
        this.last_login_time=last_login_time;
        }
        public TimeStampCondition getLast_login_time(){
        return this.last_login_time;
        }
                private NumberCondition region_id;
        public void setRegion_id(NumberCondition region_id){
        this.region_id=region_id;
        }
        public NumberCondition getRegion_id(){
        return this.region_id;
        }
                private StringCondition address;
        public void setAddress(StringCondition address){
        this.address=address;
        }
        public StringCondition getAddress(){
        return this.address;
        }
                private NumberCondition member_status;
        public void setMember_status(NumberCondition member_status){
        this.member_status=member_status;
        }
        public NumberCondition getMember_status(){
        return this.member_status;
        }
                private BooleanCondition data_completed;
        public void setData_completed(BooleanCondition data_completed){
        this.data_completed=data_completed;
        }
        public BooleanCondition getData_completed(){
        return this.data_completed;
        }

            public String toString() {
            // TODO Auto-generated method stub
            return null;
            }

            public boolean equals(Object o) {
            // TODO Auto-generated method stub
            return false;
            }

            public int hashCode() {
            // TODO Auto-generated method stub
            return 0;
            }

            public void setNULL(){

                                                this.id=null;
                                                                this.name=null;
                                                                this.email=null;
                                                                this.mobile=null;
                                                                this.password=null;
                                                                this.avatar=null;
                                                                this.regist_time=null;
                                                                this.token=null;
                                                                this.longitude=null;
                                                                this.latitude=null;
                                                                this.wxopenid=null;
                                                                this.unionid=null;
                                                                this.qqkey=null;
                                                                this.login_time=null;
                                                                this.last_login_time=null;
                                                                this.region_id=null;
                                                                this.address=null;
                                                                this.member_status=null;
                                                                this.data_completed=null;


          }
            public void resetDefaultVal(){
                                                this.id=new NumberCondition();
                                                                this.name=new StringCondition();
                                                                this.email=new StringCondition();
                                                                this.mobile=new StringCondition();
                                                                this.password=new StringCondition();
                                                                this.avatar=new StringCondition();
                                                                this.regist_time=new TimeStampCondition();
                                                                this.token=new StringCondition();
                                                                this.longitude=new NumberCondition();
                                                                this.latitude=new NumberCondition();
                                                                this.wxopenid=new StringCondition();
                                                                this.unionid=new StringCondition();
                                                                this.qqkey=new StringCondition();
                                                                this.login_time=new TimeStampCondition();
                                                                this.last_login_time=new TimeStampCondition();
                                                                this.region_id=new NumberCondition();
                                                                this.address=new StringCondition();
                                                                this.member_status=new NumberCondition();
                                                                this.data_completed=new BooleanCondition();

            }

            //--从请求中组装搜索条件。
            public static MemberCondition fetchConditionInfo(RequestEnhance req){
            HashMap map=new HashMap(2);
            StringBuilder sb_tips=new StringBuilder();
            ArrayList tipsList=new ArrayList();
                MemberCondition condition=new MemberCondition();




                                                    //--【id】条件
                            NumberCondition id_condition=new NumberCondition();

                            condition.setId(id_condition);

                            String str_id_EQUAL_TO=req.getParam("c.id.EQUAL_TO");

                            if(ValidateUtils.isEmpty(str_id_EQUAL_TO)==false&&ValidateUtils.isRealNumber(str_id_EQUAL_TO)==true){
                            id_condition.EQUAL_TO=Long.parseLong(str_id_EQUAL_TO);
                            tipsList.add("【id】等于" + str_id_EQUAL_TO + ";");
                            }

                            String str_id_LESS_THAN=req.getParam("c.id.LESS_THAN");
                            if(ValidateUtils.isEmpty(str_id_LESS_THAN)==false&&ValidateUtils.isRealNumber(str_id_LESS_THAN)==true){
                            id_condition.LESS_THAN=Long.parseLong(str_id_LESS_THAN);
                            tipsList.add("【id】不大于" + str_id_LESS_THAN + ";");
                            }

                            String str_id_MORE_THAN=req.getParam("c.id.MORE_THAN");
                            if(ValidateUtils.isEmpty(str_id_MORE_THAN)==false&&ValidateUtils.isRealNumber(str_id_MORE_THAN)==true){
                            id_condition.MORE_THAN=Long.parseLong(str_id_MORE_THAN);
                            tipsList.add("【id】不小于" + str_id_MORE_THAN + ";");
                            }






                                                    //--【name】条件
                            StringCondition name_condition=new StringCondition();
                            condition.setName(name_condition);

                            String str_name_EQUAL_TO=req.getParam("c.name.EQUAL_TO");
                            if(ValidateUtils.isEmpty(str_name_EQUAL_TO)==false){
                            name_condition.EQUAL_TO=StringUtils.trim(str_name_EQUAL_TO);
                            tipsList.add("【name】等于" + str_name_EQUAL_TO + ";");
                            }

                            String str_name_LIKE=req.getParam("c.name.LIKE");
                            if(ValidateUtils.isEmpty(str_name_LIKE)==false){
                            name_condition.LIKE=StringUtils.trim(str_name_LIKE);
                            tipsList.add("【name】包含" + str_name_LIKE + ";");
                            }

                            String str_name_IN=req.getParam("c.name.IN");
                            if(ValidateUtils.isEmpty(str_name_IN)==false){
                            name_condition.IN=WebTools.getObjectArray(StringUtils.trim(str_name_IN),",");
                            tipsList.add("【name】包含" + str_name_IN + ";");
                            }
                            String str_name_NOT_IN=req.getParam("c.name.NOT_IN");
                            if(ValidateUtils.isEmpty(str_name_NOT_IN)==false){
                            name_condition.NOT_IN=WebTools.getObjectArray(StringUtils.trim(str_name_NOT_IN),",");
                            tipsList.add("【name】包含" + str_name_NOT_IN + ";");
                            }






                                                    //--【email】条件
                            StringCondition email_condition=new StringCondition();
                            condition.setEmail(email_condition);

                            String str_email_EQUAL_TO=req.getParam("c.email.EQUAL_TO");
                            if(ValidateUtils.isEmpty(str_email_EQUAL_TO)==false){
                            email_condition.EQUAL_TO=StringUtils.trim(str_email_EQUAL_TO);
                            tipsList.add("【email】等于" + str_email_EQUAL_TO + ";");
                            }

                            String str_email_LIKE=req.getParam("c.email.LIKE");
                            if(ValidateUtils.isEmpty(str_email_LIKE)==false){
                            email_condition.LIKE=StringUtils.trim(str_email_LIKE);
                            tipsList.add("【email】包含" + str_email_LIKE + ";");
                            }

                            String str_email_IN=req.getParam("c.email.IN");
                            if(ValidateUtils.isEmpty(str_email_IN)==false){
                            email_condition.IN=WebTools.getObjectArray(StringUtils.trim(str_email_IN),",");
                            tipsList.add("【email】包含" + str_email_IN + ";");
                            }
                            String str_email_NOT_IN=req.getParam("c.email.NOT_IN");
                            if(ValidateUtils.isEmpty(str_email_NOT_IN)==false){
                            email_condition.NOT_IN=WebTools.getObjectArray(StringUtils.trim(str_email_NOT_IN),",");
                            tipsList.add("【email】包含" + str_email_NOT_IN + ";");
                            }






                                                    //--【mobile】条件
                            StringCondition mobile_condition=new StringCondition();
                            condition.setMobile(mobile_condition);

                            String str_mobile_EQUAL_TO=req.getParam("c.mobile.EQUAL_TO");
                            if(ValidateUtils.isEmpty(str_mobile_EQUAL_TO)==false){
                            mobile_condition.EQUAL_TO=StringUtils.trim(str_mobile_EQUAL_TO);
                            tipsList.add("【mobile】等于" + str_mobile_EQUAL_TO + ";");
                            }

                            String str_mobile_LIKE=req.getParam("c.mobile.LIKE");
                            if(ValidateUtils.isEmpty(str_mobile_LIKE)==false){
                            mobile_condition.LIKE=StringUtils.trim(str_mobile_LIKE);
                            tipsList.add("【mobile】包含" + str_mobile_LIKE + ";");
                            }

                            String str_mobile_IN=req.getParam("c.mobile.IN");
                            if(ValidateUtils.isEmpty(str_mobile_IN)==false){
                            mobile_condition.IN=WebTools.getObjectArray(StringUtils.trim(str_mobile_IN),",");
                            tipsList.add("【mobile】包含" + str_mobile_IN + ";");
                            }
                            String str_mobile_NOT_IN=req.getParam("c.mobile.NOT_IN");
                            if(ValidateUtils.isEmpty(str_mobile_NOT_IN)==false){
                            mobile_condition.NOT_IN=WebTools.getObjectArray(StringUtils.trim(str_mobile_NOT_IN),",");
                            tipsList.add("【mobile】包含" + str_mobile_NOT_IN + ";");
                            }






                                                    //--【password】条件
                            StringCondition password_condition=new StringCondition();
                            condition.setPassword(password_condition);

                            String str_password_EQUAL_TO=req.getParam("c.password.EQUAL_TO");
                            if(ValidateUtils.isEmpty(str_password_EQUAL_TO)==false){
                            password_condition.EQUAL_TO=StringUtils.trim(str_password_EQUAL_TO);
                            tipsList.add("【password】等于" + str_password_EQUAL_TO + ";");
                            }

                            String str_password_LIKE=req.getParam("c.password.LIKE");
                            if(ValidateUtils.isEmpty(str_password_LIKE)==false){
                            password_condition.LIKE=StringUtils.trim(str_password_LIKE);
                            tipsList.add("【password】包含" + str_password_LIKE + ";");
                            }

                            String str_password_IN=req.getParam("c.password.IN");
                            if(ValidateUtils.isEmpty(str_password_IN)==false){
                            password_condition.IN=WebTools.getObjectArray(StringUtils.trim(str_password_IN),",");
                            tipsList.add("【password】包含" + str_password_IN + ";");
                            }
                            String str_password_NOT_IN=req.getParam("c.password.NOT_IN");
                            if(ValidateUtils.isEmpty(str_password_NOT_IN)==false){
                            password_condition.NOT_IN=WebTools.getObjectArray(StringUtils.trim(str_password_NOT_IN),",");
                            tipsList.add("【password】包含" + str_password_NOT_IN + ";");
                            }






                                                    //--【avatar】条件
                            StringCondition avatar_condition=new StringCondition();
                            condition.setAvatar(avatar_condition);

                            String str_avatar_EQUAL_TO=req.getParam("c.avatar.EQUAL_TO");
                            if(ValidateUtils.isEmpty(str_avatar_EQUAL_TO)==false){
                            avatar_condition.EQUAL_TO=StringUtils.trim(str_avatar_EQUAL_TO);
                            tipsList.add("【avatar】等于" + str_avatar_EQUAL_TO + ";");
                            }

                            String str_avatar_LIKE=req.getParam("c.avatar.LIKE");
                            if(ValidateUtils.isEmpty(str_avatar_LIKE)==false){
                            avatar_condition.LIKE=StringUtils.trim(str_avatar_LIKE);
                            tipsList.add("【avatar】包含" + str_avatar_LIKE + ";");
                            }

                            String str_avatar_IN=req.getParam("c.avatar.IN");
                            if(ValidateUtils.isEmpty(str_avatar_IN)==false){
                            avatar_condition.IN=WebTools.getObjectArray(StringUtils.trim(str_avatar_IN),",");
                            tipsList.add("【avatar】包含" + str_avatar_IN + ";");
                            }
                            String str_avatar_NOT_IN=req.getParam("c.avatar.NOT_IN");
                            if(ValidateUtils.isEmpty(str_avatar_NOT_IN)==false){
                            avatar_condition.NOT_IN=WebTools.getObjectArray(StringUtils.trim(str_avatar_NOT_IN),",");
                            tipsList.add("【avatar】包含" + str_avatar_NOT_IN + ";");
                            }






                                                    //--【regist_time】条件
                            TimeStampCondition regist_time_condition=new TimeStampCondition();
                            condition.setRegist_time(regist_time_condition);
                            String str_regist_time_EQUAL_TO=req.getParam("c.regist_time.EQUAL_TO");

                            if(ValidateUtils.isEmpty(str_regist_time_EQUAL_TO)==false&&ValidateUtils.isDateTime(str_regist_time_EQUAL_TO)==true){
                            regist_time_condition.EQUAL_TO=WebTools.toTimeStamp(str_regist_time_EQUAL_TO);
                            tipsList.add("【regist_time】等于" + str_regist_time_EQUAL_TO + ";");
                            }

                            String str_regist_time_LESS_THAN=req.getParam("c.regist_time.LESS_THAN");
                            if(ValidateUtils.isEmpty(str_regist_time_LESS_THAN)==false&&ValidateUtils.isDateTime(str_regist_time_LESS_THAN)==true){
                            regist_time_condition.LESS_THAN=WebTools.toTimeStamp(str_regist_time_LESS_THAN);
                            tipsList.add("【regist_time】不大于" + str_regist_time_LESS_THAN + ";");
                            }

                            String str_regist_time_MORE_THAN=req.getParam("c.regist_time.MORE_THAN");
                            if(ValidateUtils.isEmpty(str_regist_time_MORE_THAN)==false&&ValidateUtils.isDateTime(str_regist_time_MORE_THAN)==true){
                            regist_time_condition.MORE_THAN=WebTools.toTimeStamp(str_regist_time_MORE_THAN);
                            tipsList.add("【regist_time】不小于" + str_regist_time_MORE_THAN + ";");
                            }







                                                    //--【token】条件
                            StringCondition token_condition=new StringCondition();
                            condition.setToken(token_condition);

                            String str_token_EQUAL_TO=req.getParam("c.token.EQUAL_TO");
                            if(ValidateUtils.isEmpty(str_token_EQUAL_TO)==false){
                            token_condition.EQUAL_TO=StringUtils.trim(str_token_EQUAL_TO);
                            tipsList.add("【token】等于" + str_token_EQUAL_TO + ";");
                            }

                            String str_token_LIKE=req.getParam("c.token.LIKE");
                            if(ValidateUtils.isEmpty(str_token_LIKE)==false){
                            token_condition.LIKE=StringUtils.trim(str_token_LIKE);
                            tipsList.add("【token】包含" + str_token_LIKE + ";");
                            }

                            String str_token_IN=req.getParam("c.token.IN");
                            if(ValidateUtils.isEmpty(str_token_IN)==false){
                            token_condition.IN=WebTools.getObjectArray(StringUtils.trim(str_token_IN),",");
                            tipsList.add("【token】包含" + str_token_IN + ";");
                            }
                            String str_token_NOT_IN=req.getParam("c.token.NOT_IN");
                            if(ValidateUtils.isEmpty(str_token_NOT_IN)==false){
                            token_condition.NOT_IN=WebTools.getObjectArray(StringUtils.trim(str_token_NOT_IN),",");
                            tipsList.add("【token】包含" + str_token_NOT_IN + ";");
                            }






                                                    //--【longitude】条件
                            NumberCondition longitude_condition=new NumberCondition();

                            condition.setLongitude(longitude_condition);

                            String str_longitude_EQUAL_TO=req.getParam("c.longitude.EQUAL_TO");

                            if(ValidateUtils.isEmpty(str_longitude_EQUAL_TO)==false&&ValidateUtils.isRealNumber(str_longitude_EQUAL_TO)==true){
                            longitude_condition.EQUAL_TO=Double.parseDouble(str_longitude_EQUAL_TO);
                            tipsList.add("【longitude】等于" + str_longitude_EQUAL_TO + ";");
                            }

                            String str_longitude_LESS_THAN=req.getParam("c.longitude.LESS_THAN");
                            if(ValidateUtils.isEmpty(str_longitude_LESS_THAN)==false&&ValidateUtils.isRealNumber(str_longitude_LESS_THAN)==true){
                            longitude_condition.LESS_THAN=Double.parseDouble(str_longitude_LESS_THAN);
                            tipsList.add("【longitude】不大于" + str_longitude_LESS_THAN + ";");
                            }

                            String str_longitude_MORE_THAN=req.getParam("c.longitude.MORE_THAN");
                            if(ValidateUtils.isEmpty(str_longitude_MORE_THAN)==false&&ValidateUtils.isRealNumber(str_longitude_MORE_THAN)==true){
                            longitude_condition.MORE_THAN=Double.parseDouble(str_longitude_MORE_THAN);
                            tipsList.add("【longitude】不小于" + str_longitude_MORE_THAN + ";");
                            }






                                                    //--【latitude】条件
                            NumberCondition latitude_condition=new NumberCondition();

                            condition.setLatitude(latitude_condition);

                            String str_latitude_EQUAL_TO=req.getParam("c.latitude.EQUAL_TO");

                            if(ValidateUtils.isEmpty(str_latitude_EQUAL_TO)==false&&ValidateUtils.isRealNumber(str_latitude_EQUAL_TO)==true){
                            latitude_condition.EQUAL_TO=Double.parseDouble(str_latitude_EQUAL_TO);
                            tipsList.add("【latitude】等于" + str_latitude_EQUAL_TO + ";");
                            }

                            String str_latitude_LESS_THAN=req.getParam("c.latitude.LESS_THAN");
                            if(ValidateUtils.isEmpty(str_latitude_LESS_THAN)==false&&ValidateUtils.isRealNumber(str_latitude_LESS_THAN)==true){
                            latitude_condition.LESS_THAN=Double.parseDouble(str_latitude_LESS_THAN);
                            tipsList.add("【latitude】不大于" + str_latitude_LESS_THAN + ";");
                            }

                            String str_latitude_MORE_THAN=req.getParam("c.latitude.MORE_THAN");
                            if(ValidateUtils.isEmpty(str_latitude_MORE_THAN)==false&&ValidateUtils.isRealNumber(str_latitude_MORE_THAN)==true){
                            latitude_condition.MORE_THAN=Double.parseDouble(str_latitude_MORE_THAN);
                            tipsList.add("【latitude】不小于" + str_latitude_MORE_THAN + ";");
                            }






                                                    //--【wxopenid】条件
                            StringCondition wxopenid_condition=new StringCondition();
                            condition.setWxopenid(wxopenid_condition);

                            String str_wxopenid_EQUAL_TO=req.getParam("c.wxopenid.EQUAL_TO");
                            if(ValidateUtils.isEmpty(str_wxopenid_EQUAL_TO)==false){
                            wxopenid_condition.EQUAL_TO=StringUtils.trim(str_wxopenid_EQUAL_TO);
                            tipsList.add("【wxopenid】等于" + str_wxopenid_EQUAL_TO + ";");
                            }

                            String str_wxopenid_LIKE=req.getParam("c.wxopenid.LIKE");
                            if(ValidateUtils.isEmpty(str_wxopenid_LIKE)==false){
                            wxopenid_condition.LIKE=StringUtils.trim(str_wxopenid_LIKE);
                            tipsList.add("【wxopenid】包含" + str_wxopenid_LIKE + ";");
                            }

                            String str_wxopenid_IN=req.getParam("c.wxopenid.IN");
                            if(ValidateUtils.isEmpty(str_wxopenid_IN)==false){
                            wxopenid_condition.IN=WebTools.getObjectArray(StringUtils.trim(str_wxopenid_IN),",");
                            tipsList.add("【wxopenid】包含" + str_wxopenid_IN + ";");
                            }
                            String str_wxopenid_NOT_IN=req.getParam("c.wxopenid.NOT_IN");
                            if(ValidateUtils.isEmpty(str_wxopenid_NOT_IN)==false){
                            wxopenid_condition.NOT_IN=WebTools.getObjectArray(StringUtils.trim(str_wxopenid_NOT_IN),",");
                            tipsList.add("【wxopenid】包含" + str_wxopenid_NOT_IN + ";");
                            }






                                                    //--【unionid】条件
                            StringCondition unionid_condition=new StringCondition();
                            condition.setUnionid(unionid_condition);

                            String str_unionid_EQUAL_TO=req.getParam("c.unionid.EQUAL_TO");
                            if(ValidateUtils.isEmpty(str_unionid_EQUAL_TO)==false){
                            unionid_condition.EQUAL_TO=StringUtils.trim(str_unionid_EQUAL_TO);
                            tipsList.add("【unionid】等于" + str_unionid_EQUAL_TO + ";");
                            }

                            String str_unionid_LIKE=req.getParam("c.unionid.LIKE");
                            if(ValidateUtils.isEmpty(str_unionid_LIKE)==false){
                            unionid_condition.LIKE=StringUtils.trim(str_unionid_LIKE);
                            tipsList.add("【unionid】包含" + str_unionid_LIKE + ";");
                            }

                            String str_unionid_IN=req.getParam("c.unionid.IN");
                            if(ValidateUtils.isEmpty(str_unionid_IN)==false){
                            unionid_condition.IN=WebTools.getObjectArray(StringUtils.trim(str_unionid_IN),",");
                            tipsList.add("【unionid】包含" + str_unionid_IN + ";");
                            }
                            String str_unionid_NOT_IN=req.getParam("c.unionid.NOT_IN");
                            if(ValidateUtils.isEmpty(str_unionid_NOT_IN)==false){
                            unionid_condition.NOT_IN=WebTools.getObjectArray(StringUtils.trim(str_unionid_NOT_IN),",");
                            tipsList.add("【unionid】包含" + str_unionid_NOT_IN + ";");
                            }






                                                    //--【qqkey】条件
                            StringCondition qqkey_condition=new StringCondition();
                            condition.setQqkey(qqkey_condition);

                            String str_qqkey_EQUAL_TO=req.getParam("c.qqkey.EQUAL_TO");
                            if(ValidateUtils.isEmpty(str_qqkey_EQUAL_TO)==false){
                            qqkey_condition.EQUAL_TO=StringUtils.trim(str_qqkey_EQUAL_TO);
                            tipsList.add("【qqkey】等于" + str_qqkey_EQUAL_TO + ";");
                            }

                            String str_qqkey_LIKE=req.getParam("c.qqkey.LIKE");
                            if(ValidateUtils.isEmpty(str_qqkey_LIKE)==false){
                            qqkey_condition.LIKE=StringUtils.trim(str_qqkey_LIKE);
                            tipsList.add("【qqkey】包含" + str_qqkey_LIKE + ";");
                            }

                            String str_qqkey_IN=req.getParam("c.qqkey.IN");
                            if(ValidateUtils.isEmpty(str_qqkey_IN)==false){
                            qqkey_condition.IN=WebTools.getObjectArray(StringUtils.trim(str_qqkey_IN),",");
                            tipsList.add("【qqkey】包含" + str_qqkey_IN + ";");
                            }
                            String str_qqkey_NOT_IN=req.getParam("c.qqkey.NOT_IN");
                            if(ValidateUtils.isEmpty(str_qqkey_NOT_IN)==false){
                            qqkey_condition.NOT_IN=WebTools.getObjectArray(StringUtils.trim(str_qqkey_NOT_IN),",");
                            tipsList.add("【qqkey】包含" + str_qqkey_NOT_IN + ";");
                            }






                                                    //--【login_time】条件
                            TimeStampCondition login_time_condition=new TimeStampCondition();
                            condition.setLogin_time(login_time_condition);
                            String str_login_time_EQUAL_TO=req.getParam("c.login_time.EQUAL_TO");

                            if(ValidateUtils.isEmpty(str_login_time_EQUAL_TO)==false&&ValidateUtils.isDateTime(str_login_time_EQUAL_TO)==true){
                            login_time_condition.EQUAL_TO=WebTools.toTimeStamp(str_login_time_EQUAL_TO);
                            tipsList.add("【login_time】等于" + str_login_time_EQUAL_TO + ";");
                            }

                            String str_login_time_LESS_THAN=req.getParam("c.login_time.LESS_THAN");
                            if(ValidateUtils.isEmpty(str_login_time_LESS_THAN)==false&&ValidateUtils.isDateTime(str_login_time_LESS_THAN)==true){
                            login_time_condition.LESS_THAN=WebTools.toTimeStamp(str_login_time_LESS_THAN);
                            tipsList.add("【login_time】不大于" + str_login_time_LESS_THAN + ";");
                            }

                            String str_login_time_MORE_THAN=req.getParam("c.login_time.MORE_THAN");
                            if(ValidateUtils.isEmpty(str_login_time_MORE_THAN)==false&&ValidateUtils.isDateTime(str_login_time_MORE_THAN)==true){
                            login_time_condition.MORE_THAN=WebTools.toTimeStamp(str_login_time_MORE_THAN);
                            tipsList.add("【login_time】不小于" + str_login_time_MORE_THAN + ";");
                            }







                                                    //--【last_login_time】条件
                            TimeStampCondition last_login_time_condition=new TimeStampCondition();
                            condition.setLast_login_time(last_login_time_condition);
                            String str_last_login_time_EQUAL_TO=req.getParam("c.last_login_time.EQUAL_TO");

                            if(ValidateUtils.isEmpty(str_last_login_time_EQUAL_TO)==false&&ValidateUtils.isDateTime(str_last_login_time_EQUAL_TO)==true){
                            last_login_time_condition.EQUAL_TO=WebTools.toTimeStamp(str_last_login_time_EQUAL_TO);
                            tipsList.add("【last_login_time】等于" + str_last_login_time_EQUAL_TO + ";");
                            }

                            String str_last_login_time_LESS_THAN=req.getParam("c.last_login_time.LESS_THAN");
                            if(ValidateUtils.isEmpty(str_last_login_time_LESS_THAN)==false&&ValidateUtils.isDateTime(str_last_login_time_LESS_THAN)==true){
                            last_login_time_condition.LESS_THAN=WebTools.toTimeStamp(str_last_login_time_LESS_THAN);
                            tipsList.add("【last_login_time】不大于" + str_last_login_time_LESS_THAN + ";");
                            }

                            String str_last_login_time_MORE_THAN=req.getParam("c.last_login_time.MORE_THAN");
                            if(ValidateUtils.isEmpty(str_last_login_time_MORE_THAN)==false&&ValidateUtils.isDateTime(str_last_login_time_MORE_THAN)==true){
                            last_login_time_condition.MORE_THAN=WebTools.toTimeStamp(str_last_login_time_MORE_THAN);
                            tipsList.add("【last_login_time】不小于" + str_last_login_time_MORE_THAN + ";");
                            }







                                                    //--【region_id】条件
                            NumberCondition region_id_condition=new NumberCondition();

                            condition.setRegion_id(region_id_condition);

                            String str_region_id_EQUAL_TO=req.getParam("c.region_id.EQUAL_TO");

                            if(ValidateUtils.isEmpty(str_region_id_EQUAL_TO)==false&&ValidateUtils.isRealNumber(str_region_id_EQUAL_TO)==true){
                            region_id_condition.EQUAL_TO=Long.parseLong(str_region_id_EQUAL_TO);
                            tipsList.add("【region_id】等于" + str_region_id_EQUAL_TO + ";");
                            }

                            String str_region_id_LESS_THAN=req.getParam("c.region_id.LESS_THAN");
                            if(ValidateUtils.isEmpty(str_region_id_LESS_THAN)==false&&ValidateUtils.isRealNumber(str_region_id_LESS_THAN)==true){
                            region_id_condition.LESS_THAN=Long.parseLong(str_region_id_LESS_THAN);
                            tipsList.add("【region_id】不大于" + str_region_id_LESS_THAN + ";");
                            }

                            String str_region_id_MORE_THAN=req.getParam("c.region_id.MORE_THAN");
                            if(ValidateUtils.isEmpty(str_region_id_MORE_THAN)==false&&ValidateUtils.isRealNumber(str_region_id_MORE_THAN)==true){
                            region_id_condition.MORE_THAN=Long.parseLong(str_region_id_MORE_THAN);
                            tipsList.add("【region_id】不小于" + str_region_id_MORE_THAN + ";");
                            }






                                                    //--【address】条件
                            StringCondition address_condition=new StringCondition();
                            condition.setAddress(address_condition);

                            String str_address_EQUAL_TO=req.getParam("c.address.EQUAL_TO");
                            if(ValidateUtils.isEmpty(str_address_EQUAL_TO)==false){
                            address_condition.EQUAL_TO=StringUtils.trim(str_address_EQUAL_TO);
                            tipsList.add("【address】等于" + str_address_EQUAL_TO + ";");
                            }

                            String str_address_LIKE=req.getParam("c.address.LIKE");
                            if(ValidateUtils.isEmpty(str_address_LIKE)==false){
                            address_condition.LIKE=StringUtils.trim(str_address_LIKE);
                            tipsList.add("【address】包含" + str_address_LIKE + ";");
                            }

                            String str_address_IN=req.getParam("c.address.IN");
                            if(ValidateUtils.isEmpty(str_address_IN)==false){
                            address_condition.IN=WebTools.getObjectArray(StringUtils.trim(str_address_IN),",");
                            tipsList.add("【address】包含" + str_address_IN + ";");
                            }
                            String str_address_NOT_IN=req.getParam("c.address.NOT_IN");
                            if(ValidateUtils.isEmpty(str_address_NOT_IN)==false){
                            address_condition.NOT_IN=WebTools.getObjectArray(StringUtils.trim(str_address_NOT_IN),",");
                            tipsList.add("【address】包含" + str_address_NOT_IN + ";");
                            }






                                                    //--【member_status】条件
                            NumberCondition member_status_condition=new NumberCondition();

                            condition.setMember_status(member_status_condition);

                            String str_member_status_EQUAL_TO=req.getParam("c.member_status.EQUAL_TO");

                            if(ValidateUtils.isEmpty(str_member_status_EQUAL_TO)==false&&ValidateUtils.isRealNumber(str_member_status_EQUAL_TO)==true){
                            member_status_condition.EQUAL_TO=Integer.parseInt(str_member_status_EQUAL_TO);
                            tipsList.add("【member_status】等于" + str_member_status_EQUAL_TO + ";");
                            }

                            String str_member_status_LESS_THAN=req.getParam("c.member_status.LESS_THAN");
                            if(ValidateUtils.isEmpty(str_member_status_LESS_THAN)==false&&ValidateUtils.isRealNumber(str_member_status_LESS_THAN)==true){
                            member_status_condition.LESS_THAN=Integer.parseInt(str_member_status_LESS_THAN);
                            tipsList.add("【member_status】不大于" + str_member_status_LESS_THAN + ";");
                            }

                            String str_member_status_MORE_THAN=req.getParam("c.member_status.MORE_THAN");
                            if(ValidateUtils.isEmpty(str_member_status_MORE_THAN)==false&&ValidateUtils.isRealNumber(str_member_status_MORE_THAN)==true){
                            member_status_condition.MORE_THAN=Integer.parseInt(str_member_status_MORE_THAN);
                            tipsList.add("【member_status】不小于" + str_member_status_MORE_THAN + ";");
                            }






                                                    //--【data_completed】条件
                            BooleanCondition data_completed_condition=new BooleanCondition();
                            condition.setData_completed(data_completed_condition);

                            String str_data_completed_EQUAL_TO=req.getParam("c.data_completed.EQUAL_TO");
                            if(ValidateUtils.isEmpty(str_data_completed_EQUAL_TO)==false){
                            data_completed_condition.EQUAL_TO=WebTools.toBoolean(str_data_completed_EQUAL_TO);
                            tipsList.add("【data_completed】等于" + str_data_completed_EQUAL_TO + ";");
                            }

                            String str_data_completed_NOT_EQUAL_TO=req.getParam("c.data_completed.NOT_EQUAL_TO");
                            if(ValidateUtils.isEmpty(str_data_completed_NOT_EQUAL_TO)==false){
                            data_completed_condition.NOT_EQUAL_TO=WebTools.toBoolean(str_data_completed_NOT_EQUAL_TO);

                            }







                //--好了,来看看排序处理。
                String str_default_order_column=req.getParam("c.order.columnName","");

                String str_default_order_type=req.getParam("c.order.orderType");
                if(ValidateUtils.isEmpty(str_default_order_type)){
                str_default_order_type="asc";
                }

                if(!ValidateUtils.isEmpty(str_default_order_column)){
                OrderCondition orderTmp=new OrderCondition();
                orderTmp.orderType=str_default_order_type;
                orderTmp.columnName=str_default_order_column;
                condition.getOrderConditions().add(orderTmp);
                }

                map.put("condition",condition);
                map.put("tips",tipsList);
                return condition;
                }

}

MicroBase-consumer.xml
消费者配置:


<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://code.alibabatech.com/schema/dubbo
       http://code.alibabatech.com/schema/dubbo/dubbo.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-2.5.xsd
       ">

       
       <dubbo:reference id="MicroBase.account.MemberService" interface="net.w2p.MicroBase.service.account.MemberService"/>
       
beans>

这个是用来配置需要使用的接口的,给消费者用。

当然还有很重要的pom.xml文件了:


<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>micro-baseartifactId>
        <groupId>net.w2pgroupId>
        <version>1.0-SNAPSHOTversion>
        
    parent>
    <modelVersion>4.0.0modelVersion>
    

    <artifactId>micro-base-apiartifactId>




    <distributionManagement>
        <repository>
            <id>nexus-releasesid>
            <name>Nexus Release Repositoryname>
            <url>http://你的内部仓库地址/repository/maven-releases/url>
        repository>
        <snapshotRepository>
            <id>nexus-snapshotsid>
            <name>Nexus Snapshot Repositoryname>
            <url>http://你的内部仓库地址/repository/maven-snapshots/url>
        snapshotRepository>
    distributionManagement>

project>

还记得之前的文章吗,已经有文章是描述如何搭建内部maven环境的了,你必须先搭建好内部maven—-因为微服务有通用的接口service,需要暴露到外面给消费者用,这时候直接发布到内部maven让其他微服务模块调用这个jar就可以了,省心省力。

提醒一下,子项目可是要部署到内部maven上面直接给消费者调用的,可以点击deploy部署。

微服务架构【技术点3】--- [初级] windows下zookeeper的配置+dubbo服务提供者端+dubbo消费者端配置_第9张图片

消费者端(最原始项目)配置

消费者端的话,用比较简单的技术来搭建说明一下问题即可。

项目结构:

微服务架构【技术点3】--- [初级] windows下zookeeper的配置+dubbo服务提供者端+dubbo消费者端配置_第10张图片

很简单的一个消费者项目,因为单纯的一个消费者不需要连接数据库,不需要连接池,不需要mybatis,不需要服务层等等,它只需要能够调用远程的微服务的接口就可以了。

好了,说明一下各个文件。

pom.xml


<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>testdubboartifactId>
        <groupId>org.test.dubbogroupId>
        <version>1.0-SNAPSHOTversion>
    parent>
    <modelVersion>4.0.0modelVersion>

    <artifactId>dubbo-customerartifactId>
    <dependencies>

    
    <dependency>
        
        
        <groupId>net.w2pgroupId>
        <artifactId>micro-base-apiartifactId>
        <version>1.0-SNAPSHOTversion>
    dependency>

    dependencies>

project>

解释一下,消费者需要调用哪个微服务的接口就在内部maven上面引入哪个微服务的api打包成的jar,

    <dependency>
        
        
        <groupId>net.w2pgroupId>
        <artifactId>micro-base-apiartifactId>
        <version>1.0-SNAPSHOTversion>
    dependency>

刚才的api的内部maven地址是这个。

cosumer.xml配置


<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-2.5.xsd
       ">
       <dubbo:application name="demotest-consumer" owner="programmer" organization="dubbox"/>
       
       <dubbo:registry address="zookeeper://localhost:2181"/>


       <import resource="classpath*:conf/dubbo/MicroBase-consumer.xml">import>

beans>

可执行入口函数 consumer.java

package com.alibaba.dubbo.consumer;
import com.alibaba.fastjson.JSONObject;
import com.just4service.testService;
import net.w2p.MicroBase.searcher.account.MemberCondition;
import net.w2p.MicroBase.service.account.MemberService;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Consumer {
    public static void main(String[] args) {
        //测试常规服务
        ClassPathXmlApplicationContext context =
                new ClassPathXmlApplicationContext("consumer.xml");
        context.start();
        System.out.println("consumer start");
        MemberService demoService = context.getBean(MemberService.class);
        System.out.println("consumer");
        String str= JSONObject.toJSONString(demoService.simpleSearch(new MemberCondition()));
        System.out.println(str);
//        testService ts=new testService();
//        ts.hello();
    }
}

至此,基本配置完毕。

结语

看到这里是不是感觉微服务+spring+dubbo+mybatis+druid等等项目很复杂呢?所以,一般这种项目这种代码都必须有配套工具来生成代码什么的。一张表从dao,model,vo,mapper.xml,service,serviceImpl,dubbo的provider注册,consumer注册,而且如果算上mvc的话,还有控制器controller,列表模板,编辑模板,人工的话,要新建一张表及对应的增删改查,想想心都慌了。

你可能感兴趣的:(设计架构,微服务,微服务,微服务,dubbo,消费者,提供者)