oil-station/fuintBackend/fuint-repository/src/main/resources/mapper/TAccountMapper.xml
2024-11-14 17:15:11 +08:00

126 lines
4.3 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="com.fuint.repository.mapper.TAccountMapper">
<!-- <select id="listAccount" resultType="com.fuint.repository.model.TAccount">-->
<!-- SELECT-->
<!-- ta.*,sd.dept_name-->
<!-- FROM-->
<!-- `t_account` ta-->
<!-- left join sys_dept sd on sd.dept_id = ta.dept_id-->
<!-- <if test="accountInfo.realName != null and accountInfo.realName != ''">-->
<!-- AND ta.real_name = like concat('%',#{accountInfo.realName},'%')-->
<!-- </if>-->
<!-- <if test="accountInfo.deptId != null">-->
<!-- AND ta.dept_id = #{accountInfo.deptId}-->
<!-- </if>-->
<!-- &lt;!&ndash; 数据范围过滤 &ndash;&gt;-->
<!-- <if test="ancestors != null and ancestors!=''">-->
<!-- AND sd.ancestors like concat (#{ancestors},'%')-->
<!-- </if>-->
<!-- order by create_time desc-->
<!-- </select>-->
<!--&lt;!&ndash; where account_status != -1&ndash;&gt;-->
<select id="listAccount" resultType="com.fuint.repository.model.TAccount">
SELECT
ta.*,sd.dept_name, ms.mobile,sd.dept_type deptType,td.duty_name roleName
FROM
`t_account` ta
left join sys_dept sd on sd.dept_id = ta.dept_id
left join mt_staff ms on ta.staff_id = ms.id
left join t_duty td ON ta.role_ids = td.duty_id
where account_status != -1
<if test="accountInfo.accountName != null and accountInfo.accountName != ''">
AND ta.account_name like concat('%',#{accountInfo.accountName},'%')
</if>
<if test="accountInfo.accountStatus != null">
AND ta.account_status = #{accountInfo.accountStatus}
</if>
<if test="accountInfo.realName != null and accountInfo.realName != ''">
AND ta.real_name like concat('%',#{accountInfo.realName},'%')
</if>
<if test="accountInfo.deptId != null">
AND (ta.dept_id = #{accountInfo.deptId} or FIND_IN_SET(#{accountInfo.deptId}, sd.ancestors))
</if>
order by create_time desc
</select>
<select id="getStationmasterByStoreId" resultType="com.fuint.repository.model.TAccount">
select
ta.*
from
`t_account` ta
left join t_account_duty td on ta.acct_id = td.acct_id
where
ta.dept_id = #{deptId}
and td.duty_id = #{roleIds}
</select>
<select id="getAccountByRolsIds" resultType="com.fuint.repository.model.TAccount">
select * ,
td.turnover_type turnoverType
from t_account ta
left join sys_dept td on ta.dept_id = td.dept_id
where role_ids in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="getDeptByRolsIds" resultType="com.fuint.repository.model.TAccount">
select dept_id deptId,
dept_name deptName,
turnover_type turnoverType
from t_account ta
left join sys_dept td on ta.acct_id = td.acct_id
<where>
role_ids in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item}
</foreach>
<if test="turnoverType != null">
td.turnover_type = #{turnoverType}
</if>
</where>
group by dept_id
</select>
<select id="getAccountByRolsId" resultType="com.fuint.repository.model.TAccount">
select
ta.dept_id deptId,
td.dept_name deptName,
td.turnover_type turnoverType
from t_account ta left join sys_dept td on ta.dept_id = td.dept_id
where role_ids = #{rolsId}
group by ta.dept_id
LIMIT 1
</select>
<select id="getByRoleId" resultType="com.fuint.repository.model.TAccount">
SELECT
ta.*
FROM
`t_account` ta
<where>
ta.role_ids in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</where>
</select>
<select id="selectOnes" resultType="com.fuint.repository.model.TAccount">
SELECT
*
FROM
`t_account`
where staff_id=#{staffId}
</select>
</mapper>