123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?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.bosshand.virgo.api.dao.ProjectDao">
- <resultMap type="com.bosshand.virgo.api.model.Project" id="result">
- <id column="id" property="id"/>
- <result column="name" property="name"/>
- <result column="createDate" property="createDate"/>
- <result column="organizationId" property="organizationId"/>
- <result column="address" property="address"/>
- <result column="picture" property="picture"/>
- <result column="tagIds" property="tagIds"/>
- <result column="comment" property="comment"/>
- <result column="data" property="data"/>
- </resultMap>
- <resultMap type="com.bosshand.virgo.api.model.Project" id="projectResult">
- <id column="id" property="id"/>
- <result column="name" property="name"/>
- <result column="createDate" property="createDate"/>
- <result column="organizationId" property="organizationId"/>
- <result column="address" property="address"/>
- <result column="picture" property="picture"/>
- <result column="tagIds" property="tagIds"/>
- <result column="comment" property="comment"/>
- <result column="data" property="data"/>
- <collection property="projectItemList" ofType="com.bosshand.virgo.api.model.ProjectItem" resultMap="com.bosshand.virgo.api.dao.ProjectItemDao.projectItemResult" columnPrefix="projectItem_"/>
- </resultMap>
- <sql id="ProjectQuery">
- SELECT
- p.*,
- pi.id as projectItem_id,
- pi.name as projectItem_name,
- pi.createDate as projectItem_createDate,
- pi.area as projectItem_area,
- pi.address as projectItem_address,
- pi.picture as projectItem_picture,
- pi.propertyCertificateNumber as projectItem_propertyCertificateNumber,
- pi.tagIds as projectItem_tagIds,
- pi.data as projectItem_data
- FROM project p
- left join project_item pi on p.id = pi.projectId
- </sql>
- <select id="getProject" resultMap="result">
- SELECT * FROM project WHERE id=#{id}
- </select>
- <select id="get" resultMap="projectResult">
- <include refid="ProjectQuery"/>
- where p.deleteState = 0 and p.id=#{id}
- </select>
- <select id="getProjectByOrganizationId" resultMap="result">
- select * from project where deleteState = 0 and organizationId = #{organizationId}
- </select>
- <insert id="insert" parameterType="com.bosshand.virgo.api.model.Project" useGeneratedKeys="true" keyProperty="id">
- INSERT INTO project(`name`, `createDate`, `organizationId`, `address`, `picture`, `tagIds`, `comment`, `data`)
- VALUES (#{name}, now(), #{organizationId}, #{address}, #{picture}, #{tagIds}, #{comment}, #{data})
- </insert>
- <update id="delete">
- UPDATE project SET deleteState = 1 WHERE id=#{id}
- </update>
-
- <update id="update" parameterType="com.bosshand.virgo.api.model.Project">
- UPDATE project
- <trim prefix="set" suffixOverrides=",">
- <if test="name!=null">name=#{name},</if>
- <if test="createDate!=null">createDate=#{createDate},</if>
- <if test="organizationId!=0">organizationId=#{organizationId},</if>
- <if test="address!=null">address=#{address},</if>
- <if test="picture!=null">picture=#{picture},</if>
- <if test="tagIds!=null">tagIds=#{tagIds},</if>
- <if test="comment!=null">comment=#{comment},</if>
- <if test="data!=null">data=#{data},</if>
- </trim>
- WHERE id=#{id}
- </update>
- <select id="getTotalCount" parameterType="com.bosshand.virgo.api.model.Project" resultType="Integer">
- SELECT count(*) FROM project
- <where>
- and deleteState = 0
- <if test="organizationId != 0">and organizationId = #{organizationId}</if>
- <if test="tagIds != null">and
- <foreach item="tagId" collection="tagIds.split(',')" open="(" separator=" and " close=")">
- FIND_IN_SET (#{tagId}, tagIds)
- </foreach>
- </if>
- <if test="name != null and name !=''">and name = #{name}</if>
- <if test="createDate != null and createDate !=''">and createDate = #{createDate}</if>
- </where>
- </select>
- <select id="getLimit" resultMap="result">
- SELECT * FROM project
- <where>
- and deleteState = 0
- <if test="p.organizationId!=0">and organizationId=#{p.organizationId}</if>
- <if test="p.tagIds != null">and
- <foreach item="tagId" collection="p.tagIds.split(',')" open="(" separator=" and " close=")">
- FIND_IN_SET (#{tagId}, tagIds)
- </foreach>
- </if>
- <if test="p.name!=null">and name=#{p.name}</if>
- <if test="p.createDate!=null and p.createDate !=''">and createDate = #{p.createDate}</if>
- </where>
- limit #{currIndex} , #{pageSize}
- </select>
- </mapper>
|