mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
<?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.panzhihua.service_community.dao.ComActEnterpriseTypeDAO">
 
    <resultMap type="com.panzhihua.service_community.entity.ComActEnterpriseType" id="ComActEnterpriseTypeMap">
        <result property="id" column="id" jdbcType="INTEGER"/>
        <result property="communityId" column="community_id" jdbcType="INTEGER"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="description" column="description" jdbcType="VARCHAR"/>
        <result property="status" column="status" jdbcType="INTEGER"/>
        <result property="isDel" column="is_del" jdbcType="VARCHAR"/>
        <result property="createdBy" column="created_by" jdbcType="INTEGER"/>
        <result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
        <result property="updatedBy" column="updated_by" jdbcType="INTEGER"/>
        <result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
    </resultMap>
 
    <!-- 批量插入 -->
    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
        insert into smart_life.com_act_enterprise_type(community_id, name, description, status, is_del, created_by,
        created_at, updated_by, updated_at)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.communityId}, #{entity.name}, #{entity.description}, #{entity.status}, #{entity.isDel},
            #{entity.createdBy}, #{entity.createdAt}, #{entity.updatedBy}, #{entity.updatedAt})
        </foreach>
    </insert>
    <!-- 批量插入或按主键更新 -->
    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
        insert into smart_life.com_act_enterprise_type(community_id, name, description, status, is_del, created_by,
        created_at, updated_by, updated_at)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.communityId}, #{entity.name}, #{entity.description}, #{entity.status}, #{entity.isDel},
            #{entity.createdBy}, #{entity.createdAt}, #{entity.updatedBy}, #{entity.updatedAt})
        </foreach>
        on duplicate key update
        community_id = values(community_id) , name = values(name) , description = values(description) , status =
        values(status) , is_del = values(is_del) , created_by = values(created_by) , created_at = values(created_at) ,
        updated_by = values(updated_by) , updated_at = values(updated_at)
    </insert>
    <select id="detailEnterpriseType"
            resultType="com.panzhihua.common.model.vos.community.ComActEnterpriseTypeVO">
        SELECT t.id, t.`name`, t.description, t.status, t1.`name` AS createdBy, t2.`name` AS updatedBy
        FROM com_act_enterprise_type t
        LEFT JOIN sys_user t1 ON t.created_by = t1.user_id
        LEFT JOIN sys_user t2 ON t.updated_by = t2.user_id
        WHERE t.id = #{id}
    </select>
    <select id="pageEnterpriseType"
            resultType="com.panzhihua.common.model.vos.community.ComActEnterpriseTypeVO">
        SELECT t.id, t.`name`, t.description, t.status, t1.`name` AS createdBy, t2.`name` AS updatedBy
        FROM com_act_enterprise_type t
        LEFT JOIN sys_user t1 ON t.created_by = t1.user_id
        LEFT JOIN sys_user t2 ON t.updated_by = t2.user_id
        WHERE t.community_id = #{pageEnterpriseTypeDTO.communityId} AND t.is_del = 0
        <if test="pageEnterpriseTypeDTO.status != null">
            AND t.status = #{pageEnterpriseTypeDTO.status}
        </if>
        <if test="pageEnterpriseTypeDTO.keyword != null and pageEnterpriseTypeDTO.keyword != &quot;&quot;">
            AND t.`name` LIKE CONCAT(#{pageEnterpriseTypeDTO.keyword}, '%')
        </if>
        ORDER BY t.created_at DESC
    </select>
    <select id="getEnterpriseTypeList"
            resultType="com.panzhihua.common.model.vos.community.ComActEnterpriseTypeVO">
        SELECT t.id, t.`name`, t.description, t.status, t1.`name` AS createdBy, t2.`name` AS updatedBy
        FROM com_act_enterprise_type t
        LEFT JOIN sys_user t1 ON t.created_by = t1.user_id
        LEFT JOIN sys_user t2 ON t.updated_by = t2.user_id
        WHERE t.community_id = #{communityId} AND t.is_del = 0 AND t.status = 1
    </select>
 
</mapper>