bean:

package com.baiwang.moirai.model.sys;

import com.fasterxml.jackson.annotation.JsonInclude;

/**
* 省市区三级
* ClassName: AreaInfo
* @author chengluchao
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SysProvCityDist {
private Integer id; private String province; private String type; private String city; private Integer provinceId; private String district; private Integer cityId; private String function; public String getFunction() {
return function;
} public void setFunction(String function) {
this.function = function;
} public Integer getId() {
return id;
} public void setId(Integer id) {
this.id = id;
} public String getProvince() {
return province;
} public void setProvince(String province) {
this.province = province == null ? null : province.trim();
} public String getType() {
return type;
} public void setType(String type) {
this.type = type == null ? null : type.trim();
} public String getCity() {
return city;
} public void setCity(String city) {
this.city = city == null ? null : city.trim();
} public Integer getProvinceId() {
return provinceId;
} public void setProvinceId(Integer provinceId) {
this.provinceId = provinceId;
} public String getDistrict() {
return district;
} public void setDistrict(String district) {
this.district = district == null ? null : district.trim();
} public Integer getCityId() {
return cityId;
} public void setCityId(Integer cityId) {
this.cityId = cityId;
}
}

mybatis文件:

package com.baiwang.moirai.mapper;

import com.baiwang.moirai.model.sys.SysProvCityDist;
import org.apache.ibatis.annotations.Mapper; import java.util.List;
@Mapper
public interface SysProvCityDistMapper { int deleteByPrimaryKey(Integer id); int insert(SysProvCityDist record); int insertSelective(SysProvCityDist record); SysProvCityDist selectByPrimaryKey(Integer id); List<SysProvCityDist> selectByBean(SysProvCityDist sysProvCityDist); List<SysProvCityDist> selectByBeanVague(SysProvCityDist sysProvCityDist); int updateByPrimaryKeySelective(SysProvCityDist record); int updateByPrimaryKey(SysProvCityDist record);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.baiwang.moirai.mapper.SysProvCityDistMapper">
<resultMap id="BaseResultMap" type="com.baiwang.moirai.model.sys.SysProvCityDist">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="province" jdbcType="VARCHAR" property="province" />
<result column="type" jdbcType="CHAR" property="type" />
<result column="city" jdbcType="VARCHAR" property="city" />
<result column="province_id" jdbcType="INTEGER" property="provinceId" />
<result column="district" jdbcType="VARCHAR" property="district" />
<result column="city_id" jdbcType="INTEGER" property="cityId" />
</resultMap>
<sql id="Base_Column_List">
id, province, type, city, province_id, district, city_id
</sql> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from sys_prov_city_dist
where id = #{id,jdbcType=INTEGER}
</select> <select id="selectByBean" parameterType="com.baiwang.moirai.model.sys.SysProvCityDist" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from sys_prov_city_dist
where 1=1
<if test="province != null">
AND province = #{province,jdbcType=VARCHAR}
</if>
<if test="type != null">
AND type = #{type,jdbcType=CHAR}
</if>
<if test="city != null">
AND city = #{city,jdbcType=VARCHAR}
</if>
<if test="provinceId != null">
AND province_id = #{provinceId,jdbcType=INTEGER}
</if>
<if test="district != null">
AND district = #{district,jdbcType=VARCHAR}
</if>
<if test="cityId != null">
AND city_id = #{cityId,jdbcType=INTEGER}
</if>
<if test="id != null">
AND id = #{id,jdbcType=INTEGER}
</if>
</select> <select id="selectByBeanVague" parameterType="com.baiwang.moirai.model.sys.SysProvCityDist" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from sys_prov_city_dist
where 1=1
<if test="province != null">
AND province LIKE CONCAT(#{province,jdbcType=VARCHAR},'%')
</if>
<if test="type != null">
AND type = #{type,jdbcType=CHAR}
</if>
<if test="city != null">
AND city LIKE CONCAT(#{city,jdbcType=VARCHAR},'%')
</if>
<if test="provinceId != null">
AND province_id = #{provinceId,jdbcType=INTEGER}
</if>
<if test="district != null">
AND district LIKE CONCAT(#{district,jdbcType=VARCHAR},'%')
</if>
<if test="cityId != null">
AND city_id = #{cityId,jdbcType=INTEGER}
</if>
<if test="id != null">
AND id = #{id,jdbcType=INTEGER}
</if>
</select> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from sys_prov_city_dist
where id = #{id,jdbcType=INTEGER}
</delete> <insert id="insert" parameterType="com.baiwang.moirai.model.sys.SysProvCityDist">
insert into sys_prov_city_dist (id, province, type,
city, province_id, district,
city_id)
values (#{id,jdbcType=INTEGER}, #{province,jdbcType=VARCHAR}, #{type,jdbcType=CHAR},
#{city,jdbcType=VARCHAR}, #{provinceId,jdbcType=INTEGER}, #{district,jdbcType=VARCHAR},
#{cityId,jdbcType=INTEGER})
</insert> <insert id="insertSelective" parameterType="com.baiwang.moirai.model.sys.SysProvCityDist">
insert into sys_prov_city_dist
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="province != null">
province,
</if>
<if test="type != null">
type,
</if>
<if test="city != null">
city,
</if>
<if test="provinceId != null">
province_id,
</if>
<if test="district != null">
district,
</if>
<if test="cityId != null">
city_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="province != null">
#{province,jdbcType=VARCHAR},
</if>
<if test="type != null">
#{type,jdbcType=CHAR},
</if>
<if test="city != null">
#{city,jdbcType=VARCHAR},
</if>
<if test="provinceId != null">
#{provinceId,jdbcType=INTEGER},
</if>
<if test="district != null">
#{district,jdbcType=VARCHAR},
</if>
<if test="cityId != null">
#{cityId,jdbcType=INTEGER},
</if>
</trim>
</insert> <update id="updateByPrimaryKeySelective" parameterType="com.baiwang.moirai.model.sys.SysProvCityDist">
update sys_prov_city_dist
<set>
<if test="province != null">
province = #{province,jdbcType=VARCHAR},
</if>
<if test="type != null">
type = #{type,jdbcType=CHAR},
</if>
<if test="city != null">
city = #{city,jdbcType=VARCHAR},
</if>
<if test="provinceId != null">
province_id = #{provinceId,jdbcType=INTEGER},
</if>
<if test="district != null">
district = #{district,jdbcType=VARCHAR},
</if>
<if test="cityId != null">
city_id = #{cityId,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update> <update id="updateByPrimaryKey" parameterType="com.baiwang.moirai.model.sys.SysProvCityDist">
update sys_prov_city_dist
set province = #{province,jdbcType=VARCHAR},
type = #{type,jdbcType=CHAR},
city = #{city,jdbcType=VARCHAR},
province_id = #{provinceId,jdbcType=INTEGER},
district = #{district,jdbcType=VARCHAR},
city_id = #{cityId,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

省市区三级-javabean和mybatis的更多相关文章

  1. javaweb--json--ajax--mysql实现省市区三级联动(附三级联动数据库)

    在web中,实现三级联动很常见,尤其是利用jquery+json.但是从根本上来说jquery并不是最能让人容易理解的,接下来从最基本的javascript开始,实现由javascript+json+ ...

  2. jQuery省市区三级联动插件

    体验效果:http://hovertree.com/texiao/bootstrap/4/支持PC和手机移动端. 手机扫描二维码体验效果: 代码如下: <!DOCTYPE html> &l ...

  3. 省市区三级联动 pickerView

    效果图 概述 关于 省市区 三级联动的 pickerView,我想大多数的 iOS 开发者应该都遇到过这样的需求.在遇到这样的需求的时候,大多数人都会觉的这个很复杂,一时无从下手.其实真的没那么复杂. ...

  4. JS省市区三级联动

    不需要访问后台服务器端,不使用Ajax,无刷新,纯JS实现的省市区三级联动. 当省市区数据变动是只需调正js即可. 使用方法: <!DOCTYPE html><html>< ...

  5. ajax省市区三级联动

    jdbc+servlet+ajax开发省市区三级联动 技术点:jdbc操作数据库,ajax提交,字符拦截器,三级联动 特点:局部刷新达到省市区三级联动,举一反三可以做商品分类等 宗旨:从实战中学习 博 ...

  6. QQ JS省市区三级联动

    如下图: 首先写一个静态的页面: <!DOCTYPE html> <html> <head> <title>QQ JS省市区三级联动</title ...

  7. 省市区三级联动(二)JS部分简单版

    通过对上一篇<省市区三级联动>的学习发现JScript部分省市区的填充代码几乎相同,所以可以写成一个函数. 注意:html部分和chuli.php部分不变 1.下拉列表填充可以写成带参数的 ...

  8. 从QQ网站中提取的纯JS省市区三级联动

    在 http://ip.qq.com/ 的网站中有QQ自己的JS省市区三级联动 QQ是使用引用外部JS来实现三级联动的.JS如下:http://ip.qq.com/js/geo.js <!DOC ...

  9. 基于ThinkPHP+AJAX的省市区三级联动

    练习,就当练习. 省市区三级联动,样式如下图所示: 1,导入两个js文件并且导入数据库文件. 两个js文件分别是jquery-2.1.4.min.js和jquery-1.js,数据库文件,见附件. 2 ...

随机推荐

  1. 【HIHOCODER 1320】压缩字符串(区间DP)

    描述 小Hi希望压缩一个只包含大写字母'A'-'Z'的字符串.他使用的方法是:如果某个子串 S 连续出现了 X 次,就用'X(S)'来表示.例如AAAAAAAAAABABABCCD可以用10(A)2( ...

  2. MySQL 慢查询优化

    为什么查询速度会慢 1.慢是指一个查询的响应时间长.一个查询的过程: 客户端发送一条查询给服务器 服务器端先检查查询缓存,如果命中了缓存,则立可返回存储在缓存中的结果.否则进入下一个阶段 服务器端进行 ...

  3. Haproxy配置文件详解

    #/usr/local/sbin/haproxy -f /etc/haproxy/haproxy.cfg -st `cat /var/run/haproxy.pid` ################ ...

  4. GO 语言周报【七月第 1 期】

    TIOBE 七月排名 Go 进入前十 TIOBE 七月头条:Go 语言达到历史最高并进入前十.对于 Go 语言来说,这是一个里程碑时刻,我们可以更大胆地想象,它下一步的发展会达到怎样的高度.Go 是否 ...

  5. PHP中的字符串替换(str_replace)

    /*替换 字符串处理  str_replace() */ $num = 0; $str = "http://www.phpbrother.net/php/demo.php";$st ...

  6. 使用HttpWebRequest post数据时要注意UrlEncode

    今天在用HttpWebResponse类向一个远程页面post数据时,遇到了一个怪问题:通过对比自己post的参数和服务器接收到的值,发现参数中的一个+号被替换成了空格. 造成这个错误的原因在于+号在 ...

  7. Javascript 检查字符串是否是数字的几种方法

    //判断是否是正整数 function IsNum(s) { if(s!=null){ var r,re; re = /\d*/i; //\d表示数字,*表示匹配多个数字 r = s.match(re ...

  8. HDU 2050 【dp】【简单数学】

    题意: 中文. 思路: 不难发现数学规律是这样的,每次增加的划分区域的数量是每次增加的交点的数量再加一.然后就总结出了递推公式. #include<stdio.h> ]; int main ...

  9. eclipse导入maven工程步骤

    转自:http://jingyan.baidu.com/article/cbf0e500a6e3252eaa2893c1.html 感谢作者 步骤一 : 选择 “Import”操作 有两个途径可以选择 ...

  10. linux下查看哪个进程占用内存多

    1.用top命令 1.top top命令是Linux下常用的性能分析工具,能够实时显示系统中各个进程的资源占用状况,类似于Windows的任务管理器 可以直接使用top命令后,查看%MEM的内容.可以 ...