|
|
|
|
<?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.youlai.boot.mini.mapper.MiniStrayAnimalMapper">
|
|
|
|
|
|
|
|
|
|
<insert id="insertStrayAnimal" parameterType="com.youlai.boot.mini.model.entity.MiniStrayAnimal" useGeneratedKeys="true" keyProperty="id">
|
|
|
|
|
INSERT INTO mini_stray_animal
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="uuid != null">uuid,</if>
|
|
|
|
|
<if test="miniUserId != null">mini_user_id,</if>
|
|
|
|
|
<if test="animalType != null">animal_type,</if>
|
|
|
|
|
<if test="color != null">color,</if>
|
|
|
|
|
<if test="size != null">size,</if>
|
|
|
|
|
<if test="status != null">status,</if>
|
|
|
|
|
<if test="adoptedBy != null">adopted_by,</if>
|
|
|
|
|
<if test="adoptedAt != null">adopted_at,</if>
|
|
|
|
|
<if test="auditStatus != null">audit_status,</if>
|
|
|
|
|
|
|
|
|
|
<if test="province != null">province,</if>
|
|
|
|
|
<if test="city != null">city,</if>
|
|
|
|
|
<if test="district != null">district,</if>
|
|
|
|
|
<if test="address != null">address,</if>
|
|
|
|
|
|
|
|
|
|
<if test="gdLocationPoint != null">gd_location_point,</if>
|
|
|
|
|
<if test="wgs84LocationPoint != null">wgs84_location_point,</if>
|
|
|
|
|
|
|
|
|
|
<if test="wgs84Geohash != null">wgs84_geohash,</if>
|
|
|
|
|
|
|
|
|
|
<if test="createTime != null">create_time,</if>
|
|
|
|
|
<if test="createTimestamp != null">create_timestamp,</if>
|
|
|
|
|
<if test="createBy != null">create_by,</if>
|
|
|
|
|
|
|
|
|
|
<if test="updateTime != null">update_time,</if>
|
|
|
|
|
<if test="updateTimestamp != null">update_timestamp,</if>
|
|
|
|
|
<if test="updateBy != null">update_by,</if>
|
|
|
|
|
|
|
|
|
|
<if test="deleted != null">is_deleted,</if>
|
|
|
|
|
</trim>
|
|
|
|
|
|
|
|
|
|
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
|
|
|
|
|
|
|
|
|
|
<if test="uuid != null">#{uuid},</if>
|
|
|
|
|
<if test="miniUserId != null">#{miniUserId},</if>
|
|
|
|
|
<if test="animalType != null">#{animalType},</if>
|
|
|
|
|
<if test="color != null">#{color},</if>
|
|
|
|
|
<if test="size != null">#{size},</if>
|
|
|
|
|
<if test="status != null">#{status},</if>
|
|
|
|
|
<if test="adoptedBy != null">#{adoptedBy},</if>
|
|
|
|
|
<if test="adoptedAt != null">#{adoptedAt},</if>
|
|
|
|
|
<if test="auditStatus != null">#{auditStatus},</if>
|
|
|
|
|
|
|
|
|
|
<if test="province != null">#{province},</if>
|
|
|
|
|
<if test="city != null">#{city},</if>
|
|
|
|
|
<if test="district != null">#{district},</if>
|
|
|
|
|
<if test="address != null">#{address},</if>
|
|
|
|
|
|
|
|
|
|
<if test="gdLocationPoint != null">
|
|
|
|
|
ST_GeomFromWKB(#{gdLocationPoint, typeHandler=com.youlai.boot.common.handler.PointTypeHandler}, 4326),
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
<if test="wgs84LocationPoint != null">
|
|
|
|
|
ST_GeomFromWKB(#{wgs84LocationPoint, typeHandler=com.youlai.boot.common.handler.PointTypeHandler}, 4326),
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
<if test="wgs84Geohash != null">#{wgs84Geohash},</if>
|
|
|
|
|
|
|
|
|
|
<if test="createTime != null">#{createTime},</if>
|
|
|
|
|
<if test="createTimestamp != null">#{createTimestamp},</if>
|
|
|
|
|
<if test="createBy != null">#{createBy},</if>
|
|
|
|
|
|
|
|
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
|
|
|
<if test="updateTimestamp != null">#{updateTimestamp},</if>
|
|
|
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
|
|
|
|
|
|
|
|
<if test="deleted != null">#{deleted},</if>
|
|
|
|
|
|
|
|
|
|
</trim>
|
|
|
|
|
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<update id="updateStrayAnimal" parameterType="com.youlai.boot.mini.model.entity.MiniStrayAnimal">
|
|
|
|
|
UPDATE mini_stray_animal
|
|
|
|
|
<set>
|
|
|
|
|
<if test="uuid != null">uuid = #{uuid},</if>
|
|
|
|
|
<if test="miniUserId != null">mini_user_id = #{miniUserId},</if>
|
|
|
|
|
<if test="animalType != null">animal_type = #{animalType},</if>
|
|
|
|
|
<if test="color != null">color = #{color},</if>
|
|
|
|
|
<if test="size != null">size = #{size},</if>
|
|
|
|
|
<if test="status != null">status = #{status},</if>
|
|
|
|
|
<if test="adoptedBy != null">adopted_by = #{adoptedBy},</if>
|
|
|
|
|
<if test="adoptedAt != null">adopted_at = #{adoptedAt},</if>
|
|
|
|
|
<if test="auditStatus != null">audit_status = #{auditStatus},</if>
|
|
|
|
|
<if test="province != null">province = #{province},</if>
|
|
|
|
|
<if test="city != null">city = #{city},</if>
|
|
|
|
|
<if test="district != null">district = #{district},</if>
|
|
|
|
|
<if test="address != null">address = #{address},</if>
|
|
|
|
|
|
|
|
|
|
<if test="gdLocationPoint != null">
|
|
|
|
|
gd_location_point =
|
|
|
|
|
ST_GeomFromWKB(#{gdLocationPoint, typeHandler=com.youlai.boot.common.handler.PointTypeHandler}, 4326),
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
<if test="wgs84LocationPoint != null">
|
|
|
|
|
wgs84_location_point =
|
|
|
|
|
ST_GeomFromWKB(#{wgs84LocationPoint, typeHandler=com.youlai.boot.common.handler.PointTypeHandler}, 4326),
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
<if test="wgs84Geohash != null">wgs84_geohash = #{wgs84Geohash},</if>
|
|
|
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
|
|
|
<if test="updateTimestamp != null">update_timestamp = #{updateTimestamp},</if>
|
|
|
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
|
|
|
</set>
|
|
|
|
|
WHERE id = #{id}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="getOwnPage" resultType="com.youlai.boot.mini.model.vo.StrayAnimalShortVO" databaseId="mysql">
|
|
|
|
|
SELECT
|
|
|
|
|
u.id,
|
|
|
|
|
u.username,
|
|
|
|
|
u.nickname,
|
|
|
|
|
u.mobile,
|
|
|
|
|
u.gender,
|
|
|
|
|
u.avatar,
|
|
|
|
|
u.STATUS,
|
|
|
|
|
u.email,
|
|
|
|
|
d.NAME AS dept_name,
|
|
|
|
|
GROUP_CONCAT( r.NAME ) AS roleNames,
|
|
|
|
|
u.create_time
|
|
|
|
|
FROM
|
|
|
|
|
sys_user u
|
|
|
|
|
LEFT JOIN sys_dept d ON u.dept_id = d.id
|
|
|
|
|
LEFT JOIN sys_user_role sur ON u.id = sur.user_id
|
|
|
|
|
LEFT JOIN sys_role r ON sur.role_id = r.id
|
|
|
|
|
<where>
|
|
|
|
|
u.is_deleted = 0
|
|
|
|
|
<!-- 非超级管理员用户限制查看超级管理员 -->
|
|
|
|
|
AND NOT EXISTS (
|
|
|
|
|
SELECT
|
|
|
|
|
1
|
|
|
|
|
FROM sys_user_role sur
|
|
|
|
|
INNER JOIN sys_role r ON sur.role_id = r.id
|
|
|
|
|
WHERE
|
|
|
|
|
sur.user_id = u.id
|
|
|
|
|
AND r.code = '${@com.youlai.boot.common.constant.SystemConstants@ROOT_ROLE_CODE}'
|
|
|
|
|
)
|
|
|
|
|
<if test='queryParams.keywords!=null and queryParams.keywords.trim() neq ""'>
|
|
|
|
|
AND (
|
|
|
|
|
u.username LIKE CONCAT('%',#{queryParams.keywords},'%')
|
|
|
|
|
OR u.nickname LIKE CONCAT('%',#{queryParams.keywords},'%')
|
|
|
|
|
OR u.mobile LIKE CONCAT('%',#{queryParams.keywords},'%')
|
|
|
|
|
)
|
|
|
|
|
</if>
|
|
|
|
|
<if test='queryParams.status!=null'>
|
|
|
|
|
AND u.status = #{queryParams.status}
|
|
|
|
|
</if>
|
|
|
|
|
<if test='queryParams.deptId!=null'>
|
|
|
|
|
AND concat(',',concat(d.tree_path,',',d.id),',') like concat('%,',#{queryParams.deptId},',%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="queryParams.createTime != null and queryParams.createTime.size > 0">
|
|
|
|
|
<if test="queryParams.createTime[0] != null and queryParams.createTime[0] != ''">
|
|
|
|
|
<bind name="startDate" value="queryParams.createTime[0].length() == 10 ? queryParams.createTime[0] + ' 00:00:00' : queryParams.createTime[0]"/>
|
|
|
|
|
AND u.create_time >= #{startDate}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="queryParams.createTime[1] != null and queryParams.createTime[1] != ''">
|
|
|
|
|
<bind name="endDate" value="queryParams.createTime[1].length() == 10 ? queryParams.createTime[1] + ' 23:59:59' : queryParams.createTime[1]"/>
|
|
|
|
|
AND u.create_time <= #{endDate}
|
|
|
|
|
</if>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="queryParams.roleIds != null and queryParams.roleIds.size() > 0">
|
|
|
|
|
AND sur.role_id IN
|
|
|
|
|
<foreach item="roleId" collection="queryParams.roleIds" open="(" separator="," close=")">
|
|
|
|
|
#{roleId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
GROUP BY
|
|
|
|
|
u.id
|
|
|
|
|
<choose>
|
|
|
|
|
<!-- 如果排序参数都传入 -->
|
|
|
|
|
<when test="queryParams.sortBy != null and queryParams.sortBy != '' and queryParams.order != null">
|
|
|
|
|
ORDER BY u.${queryParams.sortBy} ${queryParams.order}
|
|
|
|
|
</when>
|
|
|
|
|
<!-- 默认排序 -->
|
|
|
|
|
<otherwise>
|
|
|
|
|
ORDER BY u.update_time DESC, u.create_time DESC
|
|
|
|
|
</otherwise>
|
|
|
|
|
</choose>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
</mapper>
|