131 lines
3.9 KiB
XML
131 lines
3.9 KiB
XML
<?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="ink.wgink.module.map.dao.grid.IGridDao">
|
||
|
||
<cache/>
|
||
|
||
<resultMap id="gridDTO" type="ink.wgink.module.map.pojo.dto.grid.GridDTO">
|
||
<id column="grid_id" property="gridId"/>
|
||
<result column="fill_color" property="fillColor"/>
|
||
<result column="grid_name" property="gridName"/>
|
||
<result column="relation_id" property="relationId"/>
|
||
</resultMap>
|
||
|
||
<!-- 建表 -->
|
||
<update id="createTable">
|
||
CREATE TABLE `map_grid` (
|
||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||
`grid_id` char(36) NOT NULL,
|
||
`grid_name` varchar(255) NOT NULL,
|
||
`fill_color` varchar(7) NOT NULL DEFAULT '#000000' COMMENT '颜色',
|
||
`gmt_create` datetime DEFAULT NULL,
|
||
`creator` char(36) DEFAULT NULL,
|
||
`gmt_modified` datetime DEFAULT NULL,
|
||
`modifier` char(36) DEFAULT NULL,
|
||
`is_delete` int(1) DEFAULT '0',
|
||
PRIMARY KEY (`id`),
|
||
UNIQUE KEY `grid_id` (`grid_id`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='网格';
|
||
</update>
|
||
|
||
<!-- 保存网格 -->
|
||
<insert id="save" parameterType="map" flushCache="true">
|
||
INSERT INTO map_grid(
|
||
grid_id,
|
||
grid_name,
|
||
fill_color,
|
||
gmt_create,
|
||
creator,
|
||
gmt_modified,
|
||
modifier,
|
||
is_delete
|
||
) VALUES(
|
||
#{gridId},
|
||
#{gridName},
|
||
#{fillColor},
|
||
#{gmtCreate},
|
||
#{creator},
|
||
#{gmtModified},
|
||
#{modifier},
|
||
#{isDelete}
|
||
)
|
||
</insert>
|
||
|
||
<!-- 删除网格 -->
|
||
<delete id="delete" parameterType="map" flushCache="true">
|
||
DELETE FROM
|
||
map_grid
|
||
WHERE
|
||
<if test="gridId != null and gridId != ''">
|
||
grid_id = #{gridId}
|
||
</if>
|
||
<if test="gridIds != null and gridIds.size > 0">
|
||
grid_id IN
|
||
<foreach collection="gridIds" index="index" open="(" separator="," close=")">
|
||
#{gridIds[${index}]}
|
||
</foreach>
|
||
</if>
|
||
</delete>
|
||
|
||
<!-- 获取网格列表(通过关联ID) -->
|
||
<select id="listGridByRelationId" parameterType="java.lang.String" resultMap="gridDTO" useCache="true">
|
||
SELECT
|
||
t1.grid_id,
|
||
t1.fill_color,
|
||
t1.grid_name,
|
||
t2.relation_id
|
||
FROM
|
||
map_grid t1
|
||
LEFT JOIN
|
||
map_grid_relation t2
|
||
ON
|
||
t1.grid_id = t2.grid_id
|
||
WHERE
|
||
t1.is_delete = 0
|
||
AND
|
||
t2.relation_id = #{_parameter}
|
||
</select>
|
||
|
||
<!-- 网格列表 -->
|
||
<select id="list" parameterType="map" resultMap="gridDTO" useCache="true">
|
||
SELECT
|
||
t1.grid_id,
|
||
t1.fill_color,
|
||
t1.grid_name
|
||
FROM
|
||
map_grid t1
|
||
WHERE
|
||
t1.is_delete = 0
|
||
<if test="gridIds != null and gridIds.size > 0">
|
||
AND
|
||
t1.grid_id IN
|
||
<foreach collection="gridIds" index="index" open="(" separator="," close=")">
|
||
#{gridIds[${index}]}
|
||
</foreach>
|
||
</if>
|
||
</select>
|
||
|
||
<!-- 网格列表(group) -->
|
||
<select id="listGroup" parameterType="map" resultMap="gridDTO" useCache="true">
|
||
SELECT
|
||
t1.grid_id,
|
||
t1.fill_color,
|
||
t1.grid_name
|
||
FROM
|
||
map_grid t1
|
||
WHERE
|
||
t1.is_delete = 0
|
||
<if test="gridIds != null and gridIds.size > 0">
|
||
AND
|
||
t1.grid_id IN
|
||
<foreach collection="gridIds" index="index" open="(" separator="," close=")">
|
||
#{gridIds[${index}]}
|
||
</foreach>
|
||
</if>
|
||
GROUP BY
|
||
t1.grid_id,
|
||
t1.fill_color,
|
||
t1.grid_name
|
||
</select>
|
||
|
||
</mapper> |