Commit d94a7ceae3d835586feb76e4c6aa46bb087af1ff
1 parent
10b04f384f
Exists in
master
and in
1 other branch
platform permission
Showing 2 changed files with 85 additions and 70 deletions
platform-biz-service/src/main/java/com/lyms/platform/permission/dao/RegionsMapper.java
View file @
d94a7ce
| 1 | 1 | package com.lyms.platform.permission.dao; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | - | |
| 5 | 4 | import com.lyms.platform.permission.model.Regions; |
| 6 | 5 | import com.lyms.platform.permission.model.RegionsQuery; |
| 7 | 6 | |
| 8 | 7 | import java.util.List; |
| 9 | 8 | |
| 10 | -public interface RegionsMapper {public void addRegions(Regions obj);public void updateRegions(Regions obj);public void deleteRegions(Integer id);public Regions getRegions(Integer id);public int queryRegionsCount(RegionsQuery query);public List<Regions> queryRegions(RegionsQuery query); | |
| 9 | +public interface RegionsMapper { | |
| 10 | + public void addRegions(Regions obj); | |
| 11 | + | |
| 12 | + public void updateRegions(Regions obj); | |
| 13 | + | |
| 14 | + public void deleteRegions(Integer id); | |
| 15 | + | |
| 16 | + public Regions getRegions(Integer id); | |
| 17 | + | |
| 18 | + public int queryRegionsCount(RegionsQuery query); | |
| 19 | + | |
| 20 | + public List<Regions> queryRegions(RegionsQuery query); | |
| 11 | 21 | |
| 12 | 22 | } |
platform-biz-service/src/main/resources/mainOrm/Regions.xml
View file @
d94a7ce
| 1 | 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
| 3 | -<mapper namespace="com.lymsh.mommybaby.maindata.dao.RegionsMapper"> | |
| 3 | +<mapper namespace="com.lyms.platform.permission.dao.RegionsMapper"> | |
| 4 | 4 | |
| 5 | - <resultMap id="RegionsResultMap" type="com.lyms.platform.permission.model.Regions"> | |
| 6 | - <id column="id" property="id" jdbcType="INTEGER"/> | |
| 7 | - <result column="parent_id" property="parentId" jdbcType="INTEGER"/> | |
| 8 | - <result column="region_name" property="regionName" jdbcType="VARCHAR"/> | |
| 9 | - <result column="level" property="level" jdbcType="INTEGER"/> | |
| 10 | - </resultMap> | |
| 5 | +<resultMap id="RegionsResultMap" type="com.lyms.platform.permission.model.Regions"> | |
| 6 | +<id column="id" property="id" jdbcType="INTEGER" /> | |
| 7 | +<result column="parent_id" property="parentId" jdbcType="INTEGER" /> | |
| 8 | +<result column="region_name" property="regionName" jdbcType="VARCHAR" /> | |
| 9 | +<result column="level" property="level" jdbcType="INTEGER" /> | |
| 10 | +</resultMap> | |
| 11 | 11 | |
| 12 | 12 | |
| 13 | - <insert id="addRegions" parameterType="com.lyms.platform.permission.model.Regions"> | |
| 13 | + | |
| 14 | +<insert id="addRegions" parameterType="com.lyms.platform.permission.model.Regions"> | |
| 14 | 15 | insert into regions (parent_id,region_name,level) values (#{parentId},#{regionName},#{level}) |
| 15 | 16 | </insert> |
| 16 | 17 | |
| 17 | 18 | |
| 18 | - <update id="updateRegions" parameterType="com.lyms.platform.permission.model.Regions"> | |
| 19 | - update regions | |
| 20 | - <set> | |
| 21 | - <if test="parentId != null"> | |
| 22 | - parent_id = #{parentId,jdbcType=INTEGER}, | |
| 23 | - </if> | |
| 24 | - <if test="regionName != null and regionName != ''"> | |
| 25 | - region_name = #{regionName,jdbcType=VARCHAR}, | |
| 26 | - </if> | |
| 27 | - <if test="level != null"> | |
| 28 | - level = #{level,jdbcType=INTEGER}, | |
| 29 | - </if> | |
| 30 | - </set> | |
| 31 | - where id = #{id,jdbcType=INTEGER} | |
| 32 | - </update> | |
| 33 | 19 | |
| 20 | +<update id="updateRegions" parameterType="com.lyms.platform.permission.model.Regions"> | |
| 21 | +update regions <set><if test="parentId != null and parentId >= 0"> | |
| 22 | +parent_id = #{parentId,jdbcType=INTEGER}, | |
| 23 | +</if> | |
| 24 | +<if test="regionName != null and regionName != ''"> | |
| 25 | +region_name = #{regionName,jdbcType=VARCHAR}, | |
| 26 | +</if> | |
| 27 | +<if test="level != null and level >= 0"> | |
| 28 | +level = #{level,jdbcType=INTEGER}, | |
| 29 | +</if> | |
| 30 | +</set> | |
| 31 | +where id = #{id,jdbcType=INTEGER} | |
| 32 | +</update> | |
| 34 | 33 | |
| 35 | - <delete id="deleteRegions" parameterType="java.lang.Integer"> | |
| 34 | + | |
| 35 | +<delete id="deleteRegions" parameterType="java.lang.Integer"> | |
| 36 | 36 | delete from regions where id = #{id,jdbcType=INTEGER} |
| 37 | 37 | </delete> |
| 38 | 38 | |
| 39 | 39 | |
| 40 | - <select id="getRegions" resultMap="RegionsResultMap" parameterType="java.lang.Integer"> | |
| 40 | + | |
| 41 | +<select id="getRegions" resultMap="RegionsResultMap" parameterType="java.lang.Integer"> | |
| 41 | 42 | select id,parent_id,region_name,level |
| 42 | 43 | from regions where id = #{id,jdbcType=INTEGER} |
| 43 | 44 | </select> |
| 44 | 45 | |
| 45 | 46 | |
| 46 | - <sql id="orderAndLimit"> | |
| 47 | - <if test="sort != null and sort != '' "> | |
| 48 | - order by ${sort} | |
| 49 | - <if test="need != null"> | |
| 50 | - limit #{offset, jdbcType=INTEGER} , #{limit, jdbcType=INTEGER} | |
| 51 | - </if> | |
| 52 | - </if> | |
| 53 | - </sql> | |
| 47 | +<sql id="orderAndLimit"> | |
| 48 | +<if test="sort != null and sort != '' "> | |
| 49 | +order by ${sort} | |
| 50 | +<if test="need != null"> | |
| 51 | +limit #{offset, jdbcType=INTEGER} , #{limit, jdbcType=INTEGER} | |
| 52 | +</if> | |
| 53 | +</if> | |
| 54 | +</sql> | |
| 54 | 55 | |
| 55 | 56 | |
| 56 | - <sql id="RegionsCondition"> | |
| 57 | - <where> | |
| 58 | - 1 = 1 | |
| 59 | - <if test="id != null"> | |
| 60 | - and id = #{id,jdbcType=INTEGER} | |
| 61 | - </if> | |
| 62 | - <if test="parentId != null"> | |
| 63 | - and parent_id = #{parentId,jdbcType=INTEGER} | |
| 64 | - </if> | |
| 65 | - <if test="regionName != null and regionName != ''"> | |
| 66 | - and region_name = #{regionName,jdbcType=VARCHAR} | |
| 67 | - </if> | |
| 68 | - <if test="level != null"> | |
| 69 | - and level = #{level,jdbcType=INTEGER} | |
| 70 | - </if> | |
| 71 | - </where> | |
| 72 | - </sql> | |
| 73 | 57 | |
| 58 | +<sql id="RegionsCondition"> | |
| 59 | +<where> | |
| 60 | + 1 = 1 | |
| 61 | +<if test="id != null and id >= 0"> | |
| 62 | +and id = #{id,jdbcType=INTEGER} | |
| 63 | +</if> | |
| 64 | +<if test="parentId != null and parentId >= 0"> | |
| 65 | +and parent_id = #{parentId,jdbcType=INTEGER} | |
| 66 | +</if> | |
| 67 | +<if test="regionName != null and regionName != ''"> | |
| 68 | +and region_name = #{regionName,jdbcType=VARCHAR} | |
| 69 | +</if> | |
| 70 | +<if test="level != null and level >= 0"> | |
| 71 | +and level = #{level,jdbcType=INTEGER} | |
| 72 | +</if> | |
| 73 | +</where> | |
| 74 | +</sql> | |
| 74 | 75 | |
| 75 | - <select id="queryRegions" resultMap="RegionsResultMap" parameterType="com.lyms.platform.permission.model.RegionsQuery"> | |
| 76 | - select id,parent_id,region_name,level | |
| 77 | - from regions | |
| 78 | - <include refid="RegionsCondition"/> | |
| 79 | - <include refid="orderAndLimit"/> | |
| 80 | - </select> | |
| 81 | 76 | |
| 82 | 77 | |
| 83 | - <select id="queryRegionsCount" resultType="int" parameterType="com.lyms.platform.permission.model.RegionsQuery"> | |
| 84 | - select count(1) from regions | |
| 85 | - <include refid="RegionsCondition"/> | |
| 86 | - </select> | |
| 78 | +<select id="queryRegions" resultMap="RegionsResultMap" parameterType="com.lyms.platform.permission.model.RegionsQuery"> | |
| 79 | +select id,parent_id,region_name,level | |
| 80 | + from regions | |
| 81 | +<include refid="RegionsCondition" /> | |
| 82 | +<include refid="orderAndLimit" /> | |
| 83 | +</select> | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | +<select id="queryRegionsCount" resultType="int" parameterType="com.lyms.platform.permission.model.RegionsQuery"> | |
| 88 | +select count(1) from regions | |
| 89 | +<include refid="RegionsCondition" /> | |
| 90 | +</select> | |
| 91 | + | |
| 87 | 92 | |
| 88 | 93 | |
| 89 | 94 | </mapper> |