zhangherong
2025-06-12 6abc1a2fb78003bb1ea6283d813b8ccc0bcd9b2b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?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="org.jeecg.modules.base.mapper.UnitMapper">
 
    <resultMap id="Unit" type="org.jeecg.modules.base.entity.Unit" >
        <result column="id" property="id" jdbcType="VARCHAR"/>
        <result column="num" property="num" jdbcType="VARCHAR"/>
        <result column="unit_category_id" property="unitCategoryId" jdbcType="VARCHAR"/>
        <result column="status" property="status" jdbcType="VARCHAR"/>
        <result column="tenant_id" property="tenantId" jdbcType="VARCHAR"/>
        <result column="create_by" property="createBy" jdbcType="VARCHAR"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
        <result column="del_flag" property="delFlag" jdbcType="VARCHAR"/>
        <result column="remark" property="remark" jdbcType="VARCHAR"/>
    </resultMap>
 
    <select id="getListByUnitCategoryId" resultMap="Unit">
       select m.id,m.num,m.name,m.unit_category_id,m.status,m.tenant_id,m.create_by,m.create_time,m.update_by,
       m.update_time,m.del_flag,m.remark,concat(u.code,u.name) categoryName from mom_base_unit m left join mom_base_unit_category u on m.unit_category_id=u.id
       <if test=" unitCategoryId !='' and unitCategoryId != null ">
           where m.unit_category_id = #{unitCategoryId}
       </if>
 
    </select>
 
    <select id="getTreeList" resultMap="Unit">
        select concat(m.code,m.name) categoryName,concat(u.num,u.name) unitName,m.id,m.pid,u.id,
        u.unit_category_id from mom_base_unit_category m LEFT join mom_base_unit u on m.id=u.unit_category_id
    </select>
 
    <!-- 根据单位名称查询 -->
    <select id="getUnitByName" resultType="org.jeecg.modules.base.entity.Unit">
        select * from  mom_base_unit  where name = #{name} and del_flag = 0
    </select>
</mapper>