省市区三级-javabean和mybatis

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文件:文章来源地址https://www.yii666.com/article/758394.html文章地址https://www.yii666.com/article/758394.html网址:yii666.com<网址:yii666.com文章来源地址:https://www.yii666.com/article/758394.html

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>

版权声明:本文内容来源于网络,版权归原作者所有,此博客不拥有其著作权,亦不承担相应法律责任。文本页已经标记具体来源原文地址,请点击原文查看来源网址,站内文章以及资源内容站长不承诺其正确性,如侵犯了您的权益,请联系站长如有侵权请联系站长,将立刻删除

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信图片_20190322181744_03.jpg

微信扫一扫打赏

请作者喝杯咖啡吧~

支付宝扫一扫领取红包,优惠每天领

二维码1

zhifubaohongbao.png

二维码2

zhifubaohongbao2.png