SpringBoot + MyBatis+Vue +ElementUI 实现省市县组件封住
Posted 在奋斗的大道
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SpringBoot + MyBatis+Vue +ElementUI 实现省市县组件封住相关的知识,希望对你有一定的参考价值。
Spring Boot后台项目编写:
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.0</modelVersion>
<groupId>com.zzg</groupId>
<artifactId>sb-crm</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
<!-- MyBatis 生成器 -->
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.7</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.3</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>4.1.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
<!--redis依赖配置 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>compile</scope>
</dependency>
<!-- 本地导入到maven中jar -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.56</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<!--使用mockito进行测试 -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<!--导入swagger文档工具 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>1.9.6</version>
</dependency>
<!--swagger文档工具结束 -->
<!--
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency> -->
<!--JWT(Json Web Token)登录支持 -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.0</version>
</dependency>
<!--Hutool Java工具包 -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>4.5.7</version>
</dependency>
<!--日志工具 -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- 阿里云短信服务 -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.1.0</version>
</dependency>
<!-- 七牛云存储 -->
<dependency>
<groupId>com.qiniu</groupId>
<artifactId>qiniu-java-sdk</artifactId>
<version>[7.2.0, 7.2.99]</version>
</dependency>
</dependencies>
</project>
resources下,application.yml文件
spring:
datasource:
url: jdbc:mysql://192.168.1.73:3306/act?serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true&allowMultiQueries=true
username: root
password: digipower
driver-class-name: com.mysql.cj.jdbc.Driver
tomcat:
max-active: 20
max-idle: 8
min-idle: 8
initial-size: 10
hikari:
max-lifetime: 1200000
servlet:
multipart:
# 最大支持文件大小
max-file-size: 10MB
redis:
# Redis服务器地址
host: 192.168.1.73
# Redis数据库索引(默认为0)
database: 0
# Redis服务器连接端口
port: 6379
# Redis密码
password: abc123
# 连接超时时间(毫秒)
timeout: 10000ms
jedis:
pool:
# 连接池最大连接数(使用负值表示没有限制)
max-active: 1024
# 连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: 10000ms
# 连接池中的最大空闲连接
max-idle: 200
# 连接池中的最小空闲连接
min-idle: 0
mybatis:
# mybatis pageHelper 分页配置
config-location: classpath:/config/SqlMapConfig.xml
server:
port: 8081
servlet:
context-path: /crm
## 开启 Swagger的 Basic认证功能,默认是false
swagger:
# 是否关闭 swagger接口文档访问
# production: true
basic:
# 开启简单用户验证
enable: true
# 用户名
username: hospital
# 用户密码
password: hospital
# 自定义 JWT key
jwt:
# JWT存储的请求头
tokenHeader: Authorization
# JWT加解密使用的密钥
secret: hospital-ChlGPaNSit1wdUBQ0LXDfduI2mFZ
# JWT的超期限时间(60*60*24 = 一天)
expiration: 604800
# JWT负载中拿到开头
tokenHead: Bearer
# 阿里云短信服务配置
aliSms:
# 阿里云短信服务 key
accessKeyId: ""
# 阿里云短信服务 secret
accessSecret: ""
# 短信抬头
signName: ""
# 注册短信验证码模板
loginTemplate: "SMS_"
regionId: "cn-hangzhou"
domain: "dysmsapi.aliyuncs.com"
version: "2017-05-25"
# 自定义 redis key 用于存储短信验证码
redis:
key:
prefix:
authCode: "hospital:register:authCode:"
expire:
# 验证码超时时间,默认 5分钟
authCode: 300
# 七牛云文件存储
qiniu:
accessKey:
secretKey:
bucket: yujian-hospital
# 访问域名前缀
url: http://q59ifzu6u.bkt.clouddn.com/
# 小程序配置,用于调用官方API
wx:
appId:
appSecret:
编写省、市、县实体文件
package com.zzg.crm.entity;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
public class TAddressProvince implements Serializable {
/**
* 主键
*
* @mbg.generated
*/
@ApiModelProperty(value = "主键")
private Integer id;
/**
* 省份编码
*
* @mbg.generated
*/
@ApiModelProperty(value = "省份编码")
private String code;
/**
* 省份名称
*
* @mbg.generated
*/
@ApiModelProperty(value = "省份名称")
private String name;
private static final long serialVersionUID = 1L;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code == null ? null : code.trim();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", code=").append(code);
sb.append(", name=").append(name);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}
package com.zzg.crm.entity;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
public class TAddressCity implements Serializable {
/**
* 主键
*
* @mbg.generated
*/
@ApiModelProperty(value = "主键")
private Integer id;
/**
* 城市编码
*
* @mbg.generated
*/
@ApiModelProperty(value = "城市编码")
private String code;
/**
* 城市名称
*
* @mbg.generated
*/
@ApiModelProperty(value = "城市名称")
private String name;
/**
* 所属省份编码
*
* @mbg.generated
*/
@ApiModelProperty(value = "所属省份编码")
private String provincecode;
private static final long serialVersionUID = 1L;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code == null ? null : code.trim();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getProvincecode() {
return provincecode;
}
public void setProvincecode(String provincecode) {
this.provincecode = provincecode == null ? null : provincecode.trim();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", code=").append(code);
sb.append(", name=").append(name);
sb.append(", provincecode=").append(provincecode);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}
package com.zzg.crm.entity;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
public class TAddressTown implements Serializable {
/**
* 主键
*
* @mbg.generated
*/
@ApiModelProperty(value = "主键")
private Integer id;
/**
* 区县编码
*
* @mbg.generated
*/
@ApiModelProperty(value = "区县编码")
private String code;
/**
* 区县名称
*
* @mbg.generated
*/
@ApiModelProperty(value = "区县名称")
private String name;
/**
* 所属城市编码
*
* @mbg.generated
*/
@ApiModelProperty(value = "所属城市编码")
private String citycode;
private static final long serialVersionUID = 1L;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code == null ? null : code.trim();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getCitycode() {
return citycode;
}
public void setCitycode(String citycode) {
this.citycode = citycode == null ? null : citycode.trim();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", code=").append(code);
sb.append(", name=").append(name);
sb.append(", citycode=").append(citycode);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}
编写省、市、县Mapper文件
package com.zzg.crm.mapper;
import com.zzg.crm.entity.TAddressCity;
import com.zzg.crm.entity.TAddressCityExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface TAddressCityMapper {
long countByExample(TAddressCityExample example);
int deleteByExample(TAddressCityExample example);
int deleteByPrimaryKey(Integer id);
int insert(TAddressCity record);
int insertSelective(TAddressCity record);
List<TAddressCity> selectByExample(TAddressCityExample example);
TAddressCity selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") TAddressCity record, @Param("example") TAddressCityExample example);
int updateByExample(@Param("record") TAddressCity record, @Param("example") TAddressCityExample example);
int updateByPrimaryKeySelective(TAddressCity record);
int updateByPrimaryKey(TAddressCity record);
}
package com.zzg.crm.mapper;
import com.zzg.crm.entity.TAddressProvince;
import com.zzg.crm.entity.TAddressProvinceExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface TAddressProvinceMapper {
long countByExample(TAddressProvinceExample example);
int deleteByExample(TAddressProvinceExample example);
int deleteByPrimaryKey(Integer id);
int insert(TAddressProvince record);
int insertSelective(TAddressProvince record);
List<TAddressProvince> selectByExample(TAddressProvinceExample example);
TAddressProvince selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") TAddressProvince record, @Param("example") TAddressProvinceExample example);
int updateByExample(@Param("record") TAddressProvince record, @Param("example") TAddressProvinceExample example);
int updateByPrimaryKeySelective(TAddressProvince record);
int updateByPrimaryKey(TAddressProvince record);
}
package com.zzg.crm.mapper;
import com.zzg.crm.entity.TAddressTown;
import com.zzg.crm.entity.TAddressTownExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface TAddressTownMapper {
long countByExample(TAddressTownExample example);
int deleteByExample(TAddressTownExample example);
int deleteByPrimaryKey(Integer id);
int insert(TAddressTown record);
int insertSelective(TAddressTown record);
List<TAddressTown> selectByExample(TAddressTownExample example);
TAddressTown selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") TAddressTown record, @Param("example") TAddressTownExample example);
int updateByExample(@Param("record") TAddressTown record, @Param("example") TAddressTownExample example);
int updateByPrimaryKeySelective(TAddressTown record);
int updateByPrimaryKey(TAddressTown record);
}
编写省、市、县Service及其实现文件
package com.zzg.crm.service;
import java.util.List;
import com.zzg.crm.entity.TAddressProvince;
public interface IProvinceService {
List<TAddressProvince> findAll();
}
package com.zzg.crm.service;
import java.util.List;
import com.zzg.crm.entity.TAddressCity;
public interface ICityService {
List<TAddressCity> findByProvinceCode(String provinceCode);
}
package com.zzg.crm.service;
import java.util.List;
import com.zzg.crm.entity.TAddressTown;
public interface ITownService {
List<TAddressTown> findByCityCode(String cityCode);
}
package com.zzg.crm.service.impl;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.zzg.crm.entity.TAddressProvince;
import com.zzg.crm.entity.TAddressProvinceExample;
import com.zzg.crm.mapper.TAddressProvinceMapper;
import com.zzg.crm.service.IProvinceService;
@Service
public class ProvinceServiceImpl implements IProvinceService {
@Resource
private TAddressProvinceMapper provinceMapper;
@Override
public List<TAddressProvince> findAll() {
// TODO Auto-generated method stub
TAddressProvinceExample example = new TAddressProvinceExample();
return provinceMapper.selectByExample(example);
}
}
package com.zzg.crm.service.impl;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.zzg.crm.entity.TAddressCity;
import com.zzg.crm.entity.TAddressCityExample;
import com.zzg.crm.mapper.TAddressCityMapper;
import com.zzg.crm.service.ICityService;
@Service
public class CityServiceImpl implements ICityService {
@Resource
private TAddressCityMapper cityMapper;
@Override
public List<TAddressCity> findByProvinceCode(String provinceCode) {
// TODO Auto-generated method stub
TAddressCityExample example = new TAddressCityExample();
example.createCriteria().andProvincecodeEqualTo(provinceCode);
return cityMapper.selectByExample(example);
}
}
package com.zzg.crm.service.impl;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.zzg.crm.entity.TAddressTown;
import com.zzg.crm.entity.TAddressTownExample;
import com.zzg.crm.mapper.TAddressTownMapper;
import com.zzg.crm.service.ITownService;
@Service
public class TownServiceImpl implements ITownService {
@Resource
private TAddressTownMapper townMapper;
@Override
public List<TAddressTown> findByCityCode(String cityCode) {
// TODO Auto-generated method stub
TAddressTownExample example = new TAddressTownExample();
example.createCriteria().andCitycodeEqualTo(cityCode);
return townMapper.selectByExample(example);
}
}
编写省、市、县参数文件
package com.zzg.crm.entity;
import java.util.ArrayList;
import java.util.List;
public class TAddressProvinceExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public TAddressProvinceExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Integer value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Integer value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Integer value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Integer value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Integer value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Integer value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Integer> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Integer> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Integer value1, Integer value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Integer value1, Integer value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andCodeIsNull() {
addCriterion("code is null");
return (Criteria) this;
}
public Criteria andCodeIsNotNull() {
addCriterion("code is not null");
return (Criteria) this;
}
public Criteria andCodeEqualTo(String value) {
addCriterion("code =", value, "code");
return (Criteria) this;
}
public Criteria andCodeNotEqualTo(String value) {
addCriterion("code <>", value, "code");
return (Criteria) this;
}
public Criteria andCodeGreaterThan(String value) {
addCriterion("code >", value, "code");
return (Criteria) this;
}
public Criteria andCodeGreaterThanOrEqualTo(String value) {
addCriterion("code >=", value, "code");
return (Criteria) this;
}
public Criteria andCodeLessThan(String value) {
addCriterion("code <", value, "code");
return (Criteria) this;
}
public Criteria andCodeLessThanOrEqualTo(String value) {
addCriterion("code <=", value, "code");
return (Criteria) this;
}
public Criteria andCodeLike(String value) {
addCriterion("code like", value, "code");
return (Criteria) this;
}
public Criteria andCodeNotLike(String value) {
addCriterion("code not like", value, "code");
return (Criteria) this;
}
public Criteria andCodeIn(List<String> values) {
addCriterion("code in", values, "code");
return (Criteria) this;
}
public Criteria andCodeNotIn(List<String> values) {
addCriterion("code not in", values, "code");
return (Criteria) this;
}
public Criteria andCodeBetween(String value1, String value2) {
addCriterion("code between", value1, value2, "code");
return (Criteria) this;
}
public Criteria andCodeNotBetween(String value1, String value2) {
addCriterion("code not between", value1, value2, "code");
return (Criteria) this;
}
public Criteria andNameIsNull() {
addCriterion("name is null");
return (Criteria) this;
}
public Criteria andNameIsNotNull() {
addCriterion("name is not null");
return (Criteria) this;
}
public Criteria andNameEqualTo(String value) {
addCriterion("name =", value, "name");
return (Criteria) this;
}
public Criteria andNameNotEqualTo(String value) {
addCriterion("name <>", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThan(String value) {
addCriterion("name >", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThanOrEqualTo(String value) {
addCriterion("name >=", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThan(String value) {
addCriterion("name <", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThanOrEqualTo(String value) {
addCriterion("name <=", value, "name");
return (Criteria) this;
}
public Criteria andNameLike(String value) {
addCriterion("name like", value, "name");
return (Criteria) this;
}
public Criteria andNameNotLike(String value) {
addCriterion("name not like", value, "name");
return (Criteria) this;
}
public Criteria andNameIn(List<String> values) {
addCriterion("name in", values, "name");
return (Criteria) this;
}
public Criteria andNameNotIn(List<String> values) {
addCriterion("name not in", values, "name");
return (Criteria) this;
}
public Criteria andNameBetween(String value1, String value2) {
addCriterion("name between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andNameNotBetween(String value1, String value2) {
addCriterion("name not between", value1, value2, "name");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}
package com.zzg.crm.entity;
import java.util.ArrayList;
import java.util.List;
public class TAddressCityExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public TAddressCityExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Integer value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Integer value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Integer value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Integer value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Integer value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Integer value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Integer> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Integer> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Integer value1, Integer value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Integer value1, Integer value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andCodeIsNull() {
addCriterion("code is null");
return (Criteria) this;
}
public Criteria andCodeIsNotNull() {
addCriterion("code is not null");
return (Criteria) this;
}
public Criteria andCodeEqualTo(String value) {
addCriterion("code =", value, "code");
return (Criteria) this;
}
public Criteria andCodeNotEqualTo(String value) {
addCriterion("code <>", value, "code");
return (Criteria) this;
}
public Criteria andCodeGreaterThan(String value) {
addCriterion("code >", value, "code");
return (Criteria) this;
}
public Criteria andCodeGreaterThanOrEqualTo(String value) {
addCriterion("code >=", value, "code");
return (Criteria) this;
}
public Criteria andCodeLessThan(String value) {
addCriterion("code <", value, "code");
return (Criteria) this;
}
public Criteria andCodeLessThanOrEqualTo(String value) {
addCriterion("code <=", value, "code");
return (Criteria) this;
}
public Criteria andCodeLike(String value) {
addCriterion("code like", value, "code");
return (Criteria) this;
}
public Criteria andCodeNotLike(String value) {
addCriterion("code not like", value, "code");
return (Criteria) this;
}
public Criteria andCodeIn(List<String> values) {
addCriterion("code in", values, "code");
return (Criteria) this;
}
public Criteria andCodeNotIn(List<String> values) {
addCriterion("code not in", values, "code");
return (Criteria) this;
}
public Criteria andCodeBetween(String value1, String value2) {
addCriterion("code between", value1, value2, "code");
return (Criteria) this;
}
public Criteria andCodeNotBetween(String value1, String value2) {
addCriterion("code not between", value1, value2, "code");
return (Criteria) this;
}
public Criteria andNameIsNull() {
addCriterion("name is null");
return (Criteria) this;
}
public Criteria andNameIsNotNull() {
addCriterion("name is not null");
return (Criteria) this;
}
public Criteria andNameEqualTo(String value) {
addCriterion("name =", value, "name");
return (Criteria) this;
}
public Criteria andNameNotEqualTo(String value) {
addCriterion("name <>", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThan(String value) {
addCriterion("name >", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThanOrEqualTo(String value) {
addCriterion("name >=", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThan(String value) {
addCriterion("name <", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThanOrEqualTo(String value) {
addCriterion("name <=", value, "name");
return (Criteria) this;
}
public Criteria andNameLike(String value) {
addCriterion("name like", value, "name");
return (Criteria) this;
}
public Criteria andNameNotLike(String value) {
addCriterion("name not like", value, "name");
return (Criteria) this;
}
public Criteria andNameIn(List<String> values) {
addCriterion("name in", values, "name");
return (Criteria) this;
}
public Criteria andNameNotIn(List<String> values) {
addCriterion("name not in", values, "name");
return (Criteria) this;
}
public Criteria andNameBetween(String value1, String value2) {
addCriterion("name between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andNameNotBetween(String value1, String value2) {
addCriterion("name not between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andProvincecodeIsNull() {
addCriterion("provinceCode is null");
return (Criteria) this;
}
public Criteria andProvincecodeIsNotNull() {
addCriterion("provinceCode is not null");
return (Criteria) this;
}
public Criteria andProvincecodeEqualTo(String value) {
addCriterion("provinceCode =", value, "provincecode");
return (Criteria) this;
}
public Criteria andProvincecodeNotEqualTo(String value) {
addCriterion("provinceCode <>", value, "provincecode");
return (Criteria) this;
}
public Criteria andProvincecodeGreaterThan(String value) {
addCriterion("provinceCode >", value, "provincecode");
return (Criteria) this;
}
public Criteria andProvincecodeGreaterThanOrEqualTo(String value) {
addCriterion("provinceCode >=", value, "provincecode");
return (Criteria) this;
}
public Criteria andProvincecodeLessThan(String value) {
addCriterion("provinceCode <", value, "provincecode");
return (Criteria) this;
}
public Criteria andProvincecodeLessThanOrEqualTo(String value) {
addCriterion("provinceCode <=", value, "provincecode");
return (Criteria) this;
}
public Criteria andProvincecodeLike(String value) {
addCriterion("provinceCode like", value, "provincecode");
return (Criteria) this;
}
public Criteria andProvincecodeNotLike(String value) {
addCriterion("provinceCode not like", value, "provincecode");
return (Criteria) this;
}
public Criteria andProvincecodeIn(List<String> values) {
addCriterion("provinceCode in", values, "provincecode");
return (Criteria) this;
}
public Criteria andProvincecodeNotIn(List<String> values) {
addCriterion("provinceCode not in", values, "provincecode");
return (Criteria) this;
}
public Criteria andProvincecodeBetween(String value1, String value2) {
addCriterion("provinceCode between", value1, value2, "provincecode");
return (Criteria) this;
}
public Criteria andProvincecodeNotBetween(String value1, String value2) {
addCriterion("provinceCode not between", value1, value2, "provincecode");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}
package com.zzg.crm.entity;
import java.util.ArrayList;
import java.util.List;
public class TAddressTownExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public TAddressTownExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Integer value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Integer value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Integer value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Integer value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Integer value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Integer value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Integer> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Integer> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Integer value1, Integer value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Integer value1, Integer value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andCodeIsNull() {
addCriterion("code is null");
return (Criteria) this;
}
public Criteria andCodeIsNotNull() {
addCriterion("code is not null");
return (Criteria) this;
}
public Criteria andCodeEqualTo(String value) {
addCriterion("code =", value, "code");
return (Criteria) this;
}
public Criteria andCodeNotEqualTo(String value) {
addCriterion("code <>", value, "code");
return (Criteria) this;
}
public Criteria andCodeGreaterThan(String value) {
addCriterion("code >", value, "code");
return (Criteria) this;
}
public Criteria andCodeGreaterThanOrEqualTo(String value) {
addCriterion("code >=", value, "code");
return (Criteria) this;
}
public Criteria andCodeLessThan(String value) {
addCriterion("code <", value, "code");
return (Criteria) this;
}
public Criteria andCodeLessThanOrEqualTo(String value) {
addCriterion("code <=", value, "code");
return (Criteria) this;
}
public Criteria andCodeLike(String value) {
addCriterion("code like", value, "code");
return (Criteria) this;
}
public Criteria andCodeNotLike(String value) {
addCriterion("code not like", value, "code");
return (Criteria) this;
}
public Criteria andCodeIn(List<String> values) {
addCriterion("code in", values, "code");
return (Criteria) this;
}
public Criteria andCodeNotIn(List<String> values) {
addCriterion("code not in", values, "code");
return (Criteria) this;
}
public Criteria andCodeBetween(String value1, String value2) {
addCriterion("code between", value1, value2, "code");
return (Criteria) this;
}
public Criteria andCodeNotBetween(String value1, String value2) {
addCriterion("code not between", value1, value2, "code");
return (Criteria) this;
}
public Criteria andNameIsNull() {
addCriterion("name is null");
return (Criteria) this;
}
public Criteria andNameIsNotNull() {
addCriterion("name is not null");
return (Criteria) this;
}
public Criteria andNameEqualTo(String value) {
addCriterion("name =", value, "name");
return (Criteria) this;
}
public Criteria andNameNotEqualTo(String value) {
addCriterion("name <>", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThan(String value) {
addCriterion("name >", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThanOrEqualTo(String value) {
addCriterion("name >=", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThan(String value) {
addCriterion("name <", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThanOrEqualTo(String value) {
addCriterion("name <=", value, "name");
return (Criteria) this;
}
public Criteria andNameLike(String value) {
addCriterion("name like", value, "name");
return (Criteria) this;
}
public Criteria andNameNotLike(String value) {
addCriterion("name not like", value, "name");
return (Criteria) this;
}
public Criteria andNameIn(List<String> values) {
addCriterion("name in", values, "name");
return (Criteria) this;
}
public Criteria andNameNotIn(List<String> values) {
addCriterion("name not in", values, "name");
return (Criteria) this;
}
public Criteria andNameBetween(String value1, String value2) {
addCriterion("name between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andNameNotBetween(String value1, String value2) {
addCriterion("name not between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andCitycodeIsNull() {
addCriterion("cityCode is null");
return (Criteria) this;
}
public Criteria andCitycodeIsNotNull() {
addCriterion("cityCode is not null");
return (Criteria) this;
}
public Criteria andCitycodeEqualTo(String value) {
addCriterion("cityCode =", value, "citycode");
return (Criteria) this;
}
public Criteria andCitycodeNotEqualTo(String value) {
addCriterion("cityCode <>", value, "citycode");
return (Criteria) this;
}
public Criteria andCitycodeGreaterThan(String value) {
addCriterion("cityCode >", value, "citycode");
return (Criteria) this;
}
public Criteria andCitycodeGreaterThanOrEqualTo(String value) {
addCriterion("cityCode >=", value, "citycode");
return (Criteria) this;
}
public Criteria andCitycodeLessThan(String value) {
addCriterion("cityCode <", value, "citycode");
return (Criteria) this;
}
public Criteria andCitycodeLessThanOrEqualTo(String value) {
addCriterion("cityCode <=", value, "citycode");
return (Criteria) this;
}
public Criteria andCitycodeLike(String value) {
addCriterion("cityCode like", value, "citycode");
return (Criteria) this;
}
public Criteria andCitycodeNotLike(String value) {
addCriterion("cityCode not like", value, "citycode");
return (Criteria) this;
}
public Criteria andCitycodeIn(List<String> values) {
addCriterion("cityCode in", values, "citycode");
return (Criteria) this;
}
public Criteria andCitycodeNotIn(List<String> values) {
addCriterion("cityCode not in", values, "citycode");
return (Criteria) this;
}
public Criteria andCitycodeBetween(String value1, String value2) {
addCriterion("cityCode between", value1, value2, "citycode");
return (Criteria) this;
}
public Criteria andCitycodeNotBetween(String value1, String value2) {
addCriterion("cityCode not between", value1, value2, "citycode");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}
控制层接口
package com.zzg.crm.controller;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.zzg.crm.common.api.CommonResult;
import com.zzg.crm.dto.CustomerInfoDTO;
import com.zzg.crm.entity.TAddressCity;
import com.zzg.crm.entity.TAddressProvince;
import com.zzg.crm.entity.TAddressTown;
import com.zzg.crm.service.ICityService;
import com.zzg.crm.service.IProvinceService;
import com.zzg.crm.service.ITownService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
@Api(value = "地址模块", tags = "地址信息接口")
@RestController
@CrossOrigin
@RequestMapping("/address")
public class AddressController {
@Resource
private IProvinceService provinceService;
@Resource
private ICityService cityService;
@Resource
private ITownService townService;
@ApiOperation(value = "获取全部省份信息", notes = "")
@以上是关于SpringBoot + MyBatis+Vue +ElementUI 实现省市县组件封住的主要内容,如果未能解决你的问题,请参考以下文章
推荐一个SpringBoot + Vue + MyBatis 音乐网站项目
推荐一个SpringBoot + Vue + MyBatis 音乐网站项目
SpringBoot+Mybatis +vue 实现登录 注册 还有验证码的。
前后端分离博客项目(SpringBoot/Redis/Shiro/Swagger/MyBatis-Plus/Vue/ElementUI)