<?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.estate.expert.admin.domain.repository.ScreenAccountMybatisMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.estate.expert.admin.domain.business.screenaccount.ScreenAccount">
|
<id column="id" property="id" />
|
<result column="name" property="name" />
|
<result column="account" property="account" />
|
<result column="password" property="password" />
|
<result column="type" property="type" />
|
<result column="client_project_ids" property="clientProjectIds" />
|
<result column="state" property="state" />
|
<result column="creator_id" property="creatorId" />
|
<result column="create_time" property="createTime" />
|
<result column="update_time" property="updateTime" />
|
<result column="deleted" property="deleted" />
|
</resultMap>
|
|
<!-- 根据名称模糊查询ScreenAccount列表 -->
|
<select id="findByName" parameterType="java.lang.String" resultMap="BaseResultMap">
|
select * from screen_account
|
where deleted = false
|
<if test="name != null and name != ''">
|
and name like concat('%', #{name}, '%')
|
</if>
|
order by create_time desc
|
</select>
|
|
<!-- 根据条件动态查询ScreenAccount列表 -->
|
<select id="findByConditions" resultMap="BaseResultMap">
|
select * from screen_account
|
where deleted = false
|
<if test="name != null and name != ''">
|
and name like concat('%', #{name}, '%')
|
</if>
|
<if test="type != null">
|
and type = #{type}
|
</if>
|
<if test="state != null">
|
and state = #{state}
|
</if>
|
<if test="clientProjectIds != null and clientProjectIds != ''">
|
and client_project_ids like concat('%', #{clientProjectIds}, '%')
|
</if>
|
order by update_time desc
|
</select>
|
<select id="list" resultType="com.estate.expert.admin.domain.business.screenaccount.ScreenAccountDto">
|
select id,
|
name,
|
type,
|
state,
|
deleted,
|
create_time as createTime,
|
creator_id,
|
account,
|
password,
|
update_time as updateTime,
|
client_project_ids as clientProjectIds
|
from screen_account where deleted = false
|
<if test="name != null and name != ''">
|
and name like concat('%', #{name}, '%')
|
</if>
|
|
<if test="type != null ">
|
and type = #{type}
|
</if>
|
|
<!-- 处理clientListIds数组参数 -->
|
<if test="clientListIds != null and clientListIds.size() > 0 and projectIds == null">
|
<foreach collection="clientListIds" item="id" separator="OR" open="and (">
|
FIND_IN_SET(#{id}, client_project_ids) > 0
|
</foreach>
|
)
|
</if>
|
<!-- 处理projectIds数组参数 -->
|
<if test="clientListIds == null and projectIds != null and projectIds.size() > 0">
|
<foreach collection="projectIds" item="id" separator="OR" open="and (">
|
FIND_IN_SET(#{id}, client_project_ids) > 0
|
</foreach>
|
)
|
</if>
|
<!-- 处理clientListIds和projectIds都不为空的情况 -->
|
<if test="clientListIds != null and clientListIds.size() > 0 and projectIds != null and projectIds.size() > 0">
|
<foreach collection="clientListIds" item="id" separator="OR" open="and (">
|
FIND_IN_SET(#{id}, client_project_ids) > 0
|
</foreach>
|
OR
|
<foreach collection="projectIds" item="id" separator="OR">
|
FIND_IN_SET(#{id}, client_project_ids) > 0
|
</foreach>
|
)
|
</if>
|
order by create_time desc
|
|
</select>
|
<select id="getClientNameList" resultType="java.lang.String">
|
select name from client where id in
|
<foreach collection="ids" item="id" separator="," close=")" open="(">
|
#{id}
|
</foreach>
|
|
</select>
|
<select id="getProjectNameList" resultType="java.lang.String">
|
select name from project where id in
|
<foreach collection="ids" item="id" separator="," close=")" open="(">
|
#{id}
|
</foreach>
|
</select>
|
<select id="getUserFromMobile"
|
resultType="com.estate.expert.admin.domain.business.screenaccount.ScreenAccount">
|
select * from screen_account where deleted = false and account = #{mobile}
|
</select>
|
<select id="findAllByTitleIdAndDeleted" resultType="com.estate.expert.admin.domain.project.Project">
|
select id,name from project where deleted = false
|
<if test="name !=null and name !=''">
|
and name like concat('%',#{name},'%')
|
</if>
|
</select>
|
</mapper>
|