| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- <?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.goafanti.common.dao.AmbSystemMapper">
- <resultMap id="BaseResultMap" type="com.goafanti.common.model.AmbSystem">
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="parent_id" jdbcType="BIGINT" property="parentId" />
- <result column="ancestors" jdbcType="VARCHAR" property="ancestors" />
- <result column="name" jdbcType="VARCHAR" property="name" />
- <result column="order_num" jdbcType="INTEGER" property="orderNum" />
- <result column="leader" jdbcType="VARCHAR" property="leader" />
- <result column="status" jdbcType="CHAR" property="status" />
- <result column="create_by" jdbcType="VARCHAR" property="createBy" />
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
- <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
- <result column="lvl" jdbcType="INTEGER" property="lvl" />
- <result column="finance_id" jdbcType="VARCHAR" property="financeId" />
- <result column="ancestors_names" jdbcType="VARCHAR" property="ancestorsNames" />
- <result column="accountant" jdbcType="VARCHAR" property="accountant" />
- <result column="remarks" jdbcType="VARCHAR" property="remarks" />
- </resultMap>
- <sql id="Base_Column_List">
- id, parent_id, ancestors, `name`, order_num, leader, `status`, create_by, create_time,
- update_by, update_time, lvl, finance_id, ancestors_names, accountant, remarks
- </sql>
- <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List" />
- from amb_system
- where id = #{id,jdbcType=BIGINT}
- </select>
- <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
- delete from amb_system
- where id = #{id,jdbcType=BIGINT}
- </delete>
- <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.AmbSystem" useGeneratedKeys="true">
- insert into amb_system (parent_id, ancestors, `name`,
- order_num, leader, `status`,
- create_by, create_time, update_by,
- update_time, lvl, finance_id,
- ancestors_names, accountant, remarks
- )
- values (#{parentId,jdbcType=BIGINT}, #{ancestors,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
- #{orderNum,jdbcType=INTEGER}, #{leader,jdbcType=VARCHAR}, #{status,jdbcType=CHAR},
- #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR},
- #{updateTime,jdbcType=TIMESTAMP}, #{lvl,jdbcType=INTEGER}, #{financeId,jdbcType=VARCHAR},
- #{ancestorsNames,jdbcType=VARCHAR}, #{accountant,jdbcType=VARCHAR}, #{remarks,jdbcType=VARCHAR}
- )
- </insert>
- <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.AmbSystem" useGeneratedKeys="true">
- insert into amb_system
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="parentId != null">
- parent_id,
- </if>
- <if test="ancestors != null">
- ancestors,
- </if>
- <if test="name != null">
- `name`,
- </if>
- <if test="orderNum != null">
- order_num,
- </if>
- <if test="leader != null">
- leader,
- </if>
- <if test="status != null">
- `status`,
- </if>
- <if test="createBy != null">
- create_by,
- </if>
- <if test="createTime != null">
- create_time,
- </if>
- <if test="updateBy != null">
- update_by,
- </if>
- <if test="updateTime != null">
- update_time,
- </if>
- <if test="lvl != null">
- lvl,
- </if>
- <if test="financeId != null">
- finance_id,
- </if>
- <if test="ancestorsNames != null">
- ancestors_names,
- </if>
- <if test="accountant != null">
- accountant,
- </if>
- <if test="remarks != null">
- remarks,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="parentId != null">
- #{parentId,jdbcType=BIGINT},
- </if>
- <if test="ancestors != null">
- #{ancestors,jdbcType=VARCHAR},
- </if>
- <if test="name != null">
- #{name,jdbcType=VARCHAR},
- </if>
- <if test="orderNum != null">
- #{orderNum,jdbcType=INTEGER},
- </if>
- <if test="leader != null">
- #{leader,jdbcType=VARCHAR},
- </if>
- <if test="status != null">
- #{status,jdbcType=CHAR},
- </if>
- <if test="createBy != null">
- #{createBy,jdbcType=VARCHAR},
- </if>
- <if test="createTime != null">
- #{createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="updateBy != null">
- #{updateBy,jdbcType=VARCHAR},
- </if>
- <if test="updateTime != null">
- #{updateTime,jdbcType=TIMESTAMP},
- </if>
- <if test="lvl != null">
- #{lvl,jdbcType=INTEGER},
- </if>
- <if test="financeId != null">
- #{financeId,jdbcType=VARCHAR},
- </if>
- <if test="ancestorsNames != null">
- #{ancestorsNames,jdbcType=VARCHAR},
- </if>
- <if test="accountant != null">
- #{accountant,jdbcType=VARCHAR},
- </if>
- <if test="remarks != null">
- #{remarks,jdbcType=VARCHAR},
- </if>
- </trim>
- </insert>
- <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.AmbSystem">
- update amb_system
- <set>
- <if test="parentId != null">
- parent_id = #{parentId,jdbcType=BIGINT},
- </if>
- <if test="ancestors != null">
- ancestors = #{ancestors,jdbcType=VARCHAR},
- </if>
- <if test="name != null">
- `name` = #{name,jdbcType=VARCHAR},
- </if>
- <if test="orderNum != null">
- order_num = #{orderNum,jdbcType=INTEGER},
- </if>
- <if test="leader != null">
- leader = #{leader,jdbcType=VARCHAR},
- </if>
- <if test="status != null">
- `status` = #{status,jdbcType=CHAR},
- </if>
- <if test="createBy != null">
- create_by = #{createBy,jdbcType=VARCHAR},
- </if>
- <if test="createTime != null">
- create_time = #{createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="updateBy != null">
- update_by = #{updateBy,jdbcType=VARCHAR},
- </if>
- <if test="updateTime != null">
- update_time = #{updateTime,jdbcType=TIMESTAMP},
- </if>
- <if test="lvl != null">
- lvl = #{lvl,jdbcType=INTEGER},
- </if>
- <if test="financeId != null">
- finance_id = #{financeId,jdbcType=VARCHAR},
- </if>
- <if test="ancestorsNames != null">
- ancestors_names = #{ancestorsNames,jdbcType=VARCHAR},
- </if>
- <if test="accountant != null">
- accountant = #{accountant,jdbcType=VARCHAR},
- </if>
- <if test="remarks != null">
- remarks = #{remarks,jdbcType=VARCHAR},
- </if>
- </set>
- where id = #{id,jdbcType=BIGINT}
- </update>
- <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.AmbSystem">
- update amb_system
- set parent_id = #{parentId,jdbcType=BIGINT},
- ancestors = #{ancestors,jdbcType=VARCHAR},
- `name` = #{name,jdbcType=VARCHAR},
- order_num = #{orderNum,jdbcType=INTEGER},
- leader = #{leader,jdbcType=VARCHAR},
- `status` = #{status,jdbcType=CHAR},
- create_by = #{createBy,jdbcType=VARCHAR},
- create_time = #{createTime,jdbcType=TIMESTAMP},
- update_by = #{updateBy,jdbcType=VARCHAR},
- update_time = #{updateTime,jdbcType=TIMESTAMP},
- lvl = #{lvl,jdbcType=INTEGER},
- finance_id = #{financeId,jdbcType=VARCHAR},
- ancestors_names = #{ancestorsNames,jdbcType=VARCHAR},
- accountant = #{accountant,jdbcType=VARCHAR},
- remarks = #{remarks,jdbcType=VARCHAR}
- where id = #{id,jdbcType=BIGINT}
- </update>
- <update id="updateAncestorsNames">
- update amb_system
- set ancestors_names=replace(ancestors_names,#{useName},#{name})
- where FIND_IN_SET( #{id},ancestors)
- </update>
- <select id="getAncestorsList" resultType="com.goafanti.ambSystem.bo.AmbAll">
- select id,name,lvl,parent_id parentId
- from amb_system where status=0
- <if test="list !=null and list.size>0 ">
- and id in
- <foreach close=")" collection="list" item="id" open="(" separator=",">
- #{id}
- </foreach>
- </if>
- </select>
- <select id="selectAmbSystemList" resultType="com.goafanti.ambSystem.bo.OutAmb">
- select a.id,a.name ,a.ancestors_names ancestorsNames ,a.status,
- b.name leaderName,c.name financeName,d.name accountantName,
- date_format(a.create_time,'%Y-%m-%d %H:%i:%s')createTimes
- from amb_system a
- left join admin b on a.leader =b.id
- left join admin c on a.finance_id =c.id
- left join admin d on a.accountant =d.id
- where 1=1
- <if test="lvl < 5">
- and a.lvl= #{lvl}
- </if>
- <if test="lvl > 4">
- and a.lvl in(5,6)
- </if>
- <if test="leader !=null">
- and a.leader= #{leader}
- </if>
- <if test="name !=null">
- and a.name like concat('%',#{name},'%')
- </if>
- <if test="ancestors !=null">
- and (a.id=#{ancestors} or find_in_set( #{ancestors} ,a.ancestors))
- </if>
- order by id
- <if test="page_sql !=null">
- ${page_sql}
- </if>
- </select>
- <select id="selectAmbSystemCount" resultType="java.lang.Integer">
- select count(*)
- from amb_system a
- left join admin b on a.leader =b.id
- left join admin c on a.finance_id =c.id
- where 1=1
- <if test="lvl < 5">
- and a.lvl= #{lvl}
- </if>
- <if test="lvl > 4">
- and a.lvl in(5,6)
- </if>
- <if test="leader !=null">
- and a.leader= #{leader}
- </if>
- <if test="name !=null">
- and a.name like concat('%',#{name},'%')
- </if>
- <if test="ancestors !=null">
- and (a.id=#{ancestors} or find_in_set( #{ancestors} ,a.ancestors))
- </if>
- </select>
- <select id="selectByParentId" parameterType="java.lang.Long" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List" />
- from amb_system
- where parent_id = #{id,jdbcType=BIGINT}
- </select>
- <select id="selectByName" resultType="java.lang.Integer">
- select
- count(*)
- from amb_system
- where name= #{name}
- </select>
- <select id="selectDtailsAmb" resultType="com.goafanti.ambSystem.bo.OutAmbDtails">
- select a.id,a.name,a.parent_id parentId,a.accountant,a.lvl,a.status,a.ancestors, a.ancestors_names ancestorsNames,
- a.order_num orderNum,a.remarks, date_format(a.create_time,'%Y-%m-%d %H:%i:%s')createTimes, a.leader,
- a.finance_id financeId, b.name leaderName,c.name financeName,d.name accountantName
- from amb_system a left join admin b on a.leader =b.id left join admin c on a.finance_id =c.id
- left join admin d on a.accountant =d.id
- where a.id= #{id}
- </select>
- </mapper>
|