123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- <?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="generateWeeklyDate" property="generateWeeklyDate"/>
- <result column="type" property="type"/>
- <result column="name" property="name"/>
- <result column="createDate" property="createDate"/>
- <result column="organizationId" property="organizationId"/>
- <result column="organizationName" property="organizationName"/>
- <result column="address" property="address"/>
- <result column="addressCode" property="addressCode"/>
- <result column="picture" property="picture"/>
- <result column="tagIds" property="tagIds"/>
- <result column="comment" property="comment"/>
- <result column="coordinates" property="coordinates"/>
- <result column="supportingFacilities" property="supportingFacilities"/>
- <result column="data" property="data"/>
- </resultMap>
- <resultMap type="com.bosshand.virgo.api.model.Project" id="projectResult">
- <id column="id" property="id"/>
- <result column="generateWeeklyDate" property="generateWeeklyDate"/>
- <result column="type" property="type"/>
- <result column="name" property="name"/>
- <result column="createDate" property="createDate"/>
- <result column="organizationId" property="organizationId"/>
- <result column="address" property="address"/>
- <result column="addressCode" property="addressCode"/>
- <result column="picture" property="picture"/>
- <result column="tagIds" property="tagIds"/>
- <result column="comment" property="comment"/>
- <result column="coordinates" property="coordinates"/>
- <result column="supportingFacilities" property="supportingFacilities"/>
- <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="fuzzyName" resultMap="result">
- SELECT a.*, b.name as organizationName FROM project a LEFT JOIN mgr_organization b ON a.organizationId = b.id
- <where>
- and a.deleteState = 0
- <if test="tagIds != null">and
- <foreach item="tagId" collection="tagIds.split(',')" open="(" separator=" or " close=")">
- FIND_IN_SET (#{tagId}, a.tagIds)
- </foreach>
- </if>
- <if test="name!=null">and a.name LIKE CONCAT('%', #{name}, '%')</if>
- </where>
- </select>
- <select id="getProject" resultMap="result">
- SELECT a.*, b.name as organizationName FROM project a LEFT JOIN mgr_organization b ON a.organizationId = b.id WHERE a.id=#{id}
- </select>
- <select id="getAll" resultMap="result">
- SELECT a.*, b.name as organizationName FROM project a LEFT JOIN mgr_organization b ON a.organizationId = b.id where deleteState = 0
- </select>
- <select id="getIds" resultMap="result">
- SELECT a.*, b.name as organizationName FROM project a LEFT JOIN mgr_organization b ON a.organizationId = b.id where a.id in
- <foreach collection="list" open="(" separator="," close=")" item="id">
- #{id}
- </foreach>
- </select>
- <select id="get" resultMap="projectResult">
- <include refid="ProjectQuery"/>
- where p.deleteState = 0 and p.id=#{id}
- </select>
- <select id="getProjectByOrganizationId" resultMap="result">
- SELECT a.*, b.name as organizationName FROM project a LEFT JOIN mgr_organization b ON a.organizationId = b.id
- where deleteState = 0 and a.organizationId = #{organizationId}
- </select>
- <insert id="insert" parameterType="com.bosshand.virgo.api.model.Project" useGeneratedKeys="true" keyProperty="id">
- INSERT INTO project(`generateWeeklyDate`, `type`, `name`, `createDate`, `organizationId`, `address`, `addressCode`, `picture`, `tagIds`, `comment`, `coordinates`, `supportingFacilities`, `data`)
- VALUES (#{generateWeeklyDate}, #{type}, #{name}, now(), #{organizationId}, #{address}, #{addressCode}, #{picture}, #{tagIds}, #{comment}, #{coordinates}, #{supportingFacilities}, #{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="type!=null">type=#{type},</if>
- <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="addressCode!=null">addressCode=#{addressCode},</if>
- <if test="picture!=null">picture=#{picture},</if>
- <if test="tagIds!=null">tagIds=#{tagIds},</if>
- <if test="comment!=null">comment=#{comment},</if>
- <if test="coordinates!=null">coordinates=#{coordinates},</if>
- <if test="supportingFacilities!=null">supportingFacilities=#{supportingFacilities},</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=" or " close=")">
- FIND_IN_SET (#{tagId}, tagIds)
- </foreach>
- </if>
- <if test="type != null">and type = #{type}</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 a.*, b.name as organizationName FROM project a LEFT JOIN mgr_organization b ON a.organizationId = b.id
- <where>
- and a.deleteState = 0
- <if test="p.organizationId!=0">and a.organizationId=#{p.organizationId}</if>
- <if test="p.tagIds != null">and
- <foreach item="tagId" collection="p.tagIds.split(',')" open="(" separator=" or " close=")">
- FIND_IN_SET (#{tagId}, a.tagIds)
- </foreach>
- </if>
- <if test="p.type != null">and a.type = #{p.type}</if>
- <if test="p.name!=null">and a.name=#{p.name}</if>
- <if test="p.createDate!=null and p.createDate !=''">and a.createDate = #{p.createDate}</if>
- </where>
- limit #{currIndex} , #{pageSize}
- </select>
- <select id="getAddressCode" resultMap="result">
- SELECT id FROM project WHERE addressCode=#{addressCode}
- </select>
- </mapper>
|