jiangping
2023-08-21 2837bdd57f72e386bbf9a725e7b3a13e5eb9e930
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?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="doumeemes.dao.ext.CategoryExtMapper">
 
  <!-- 管理页面查询 -->
  <resultMap id="CategoryExtListVO" type="doumeemes.dao.ext.vo.CategoryExtListVO" autoMapping="true">
    <id column="ID" jdbcType="INTEGER" property="id"/>
    <association property="pmodel" javaType="doumeemes.dao.business.model.Category">
      <id column="PMODEL_ID" jdbcType="INTEGER" property="id"/>
      <result column="PMODEL_DELETED" jdbcType="TINYINT" property="deleted"/>
      <result column="PMODEL_CREATE_USER" jdbcType="INTEGER" property="createUser"/>
      <result column="PMODEL_CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/>
      <result column="PMODEL_UPDATE_USER" jdbcType="INTEGER" property="updateUser"/>
      <result column="PMODEL_UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime"/>
      <result column="PMODEL_REMARK" jdbcType="VARCHAR" property="remark"/>
      <result column="PMODEL_ROOT_DEPART_ID" jdbcType="INTEGER" property="rootDepartId"/>
      <result column="PMODEL_TYPE" jdbcType="VARCHAR" property="type"/>
      <result column="PMODEL_CODE" jdbcType="TINYINT" property="code"/>
      <result column="PMODEL_NAME" jdbcType="TINYINT" property="name"/>
      <result column="PMODEL_PARENT_ID" jdbcType="INTEGER" property="parentId"/>
      <result column="PMODEL_CATE_TYPE" jdbcType="CHAR" property="cateType"/>
    </association>
  </resultMap>
  <select id="selectList" parameterType="doumeemes.dao.ext.dto.QueryCategoryExtDTO" resultMap="CategoryExtListVO">
    SELECT
      `a`.*,
      `pmodel`.`ID` AS PMODEL_ID,
      `pmodel`.`DELETED` AS PMODEL_DELETED,
      `pmodel`.`CREATE_USER` AS PMODEL_CREATE_USER,
      `pmodel`.`CREATE_TIME` AS PMODEL_CREATE_TIME,
      `pmodel`.`UPDATE_USER` AS PMODEL_UPDATE_USER,
      `pmodel`.`UPDATE_TIME` AS PMODEL_UPDATE_TIME,
      `pmodel`.`REMARK` AS PMODEL_REMARK,
      `pmodel`.`ROOT_DEPART_ID` AS PMODEL_ROOT_DEPART_ID,
      `pmodel`.`TYPE` AS PMODEL_TYPE,
      `pmodel`.`CODE` AS PMODEL_CODE,
      `pmodel`.`NAME` AS PMODEL_NAME,
      `pmodel`.`PARENT_ID` AS PMODEL_PARENT_ID,
      `pmodel`.`CATE_TYPE` AS PMODEL_CATE_TYPE,
       d.company_id as companyId
    FROM `category` `a`
    LEFT JOIN `category` `pmodel` ON a.PARENT_ID=pmodel.ID
    LEFT JOIN `department` `d` ON a.ROOT_DEPART_ID=d.ID
    <where>
      <if test="id != null">
        AND `a`.`ID` = #{id}
      </if>
      <if test="deleted != null">
        AND `a`.`DELETED` = #{deleted}
      </if>
      <if test="createUser != null">
        AND `a`.`CREATE_USER` = #{createUser}
      </if>
      <if test="createTime != null">
        AND `a`.`CREATE_TIME` = #{createTime}
      </if>
      <if test="updateUser != null">
        AND `a`.`UPDATE_USER` = #{updateUser}
      </if>
      <if test="updateTime != null">
        AND `a`.`UPDATE_TIME` = #{updateTime}
      </if>
      <if test="remark != null and remark != ''">
        AND `a`.`REMARK` = #{remark}
      </if>
      <if test="rootDepartId != null">
        AND `a`.`ROOT_DEPART_ID` = #{rootDepartId}
      </if>
      <if test="type != null and type != ''">
        AND `a`.`TYPE` = #{type}
      </if>
      <if test="code != null and code!=''">
        AND `a`.`CODE` = #{code}
      </if>
      <if test="name != null and name!=''">
        AND `a`.`NAME` like concat('%',#{name},'%')
      </if>
      <if test="parentId != null">
        AND `a`.`PARENT_ID` = #{parentId}
      </if>
      <if test="cateType != null and cateType != ''">
        AND `a`.`CATE_TYPE` = #{cateType}
      </if>
      <if test="pmodelId != null">
        AND `pmodel`.`ID` = #{pmodelId}
      </if>
      <if test="pmodelDeleted != null">
        AND `pmodel`.`DELETED` = #{pmodelDeleted}
      </if>
      <if test="pmodelCreateUser != null">
        AND `pmodel`.`CREATE_USER` = #{pmodelCreateUser}
      </if>
      <if test="pmodelCreateTime != null">
        AND `pmodel`.`CREATE_TIME` = #{pmodelCreateTime}
      </if>
      <if test="pmodelUpdateUser != null">
        AND `pmodel`.`UPDATE_USER` = #{pmodelUpdateUser}
      </if>
      <if test="pmodelUpdateTime != null">
        AND `pmodel`.`UPDATE_TIME` = #{pmodelUpdateTime}
      </if>
      <if test="pmodelRemark != null and pmodelRemark != ''">
        AND `pmodel`.`REMARK` = #{pmodelRemark}
      </if>
      <if test="pmodelRootDepartId != null">
        AND `pmodel`.`ROOT_DEPART_ID` = #{pmodelRootDepartId}
      </if>
      <if test="pmodelType != null and pmodelType != ''">
        AND `pmodel`.`TYPE` = #{pmodelType}
      </if>
      <if test="pmodelCode != null">
        AND `pmodel`.`CODE` = #{pmodelCode}
      </if>
      <if test="pmodelName != null">
        AND `pmodel`.`NAME` = #{pmodelName}
      </if>
      <if test="pmodelParentId != null">
        AND `pmodel`.`PARENT_ID` = #{pmodelParentId}
      </if>
      <if test="pmodelCateType != null and pmodelCateType != ''">
        AND `pmodel`.`CATE_TYPE` = #{pmodelCateType}
      </if>
    </where>
    order by a.id desc
  </select>
</mapper>