<?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="cn.chnmuseum.party.mapper.IndexMapper"> <!-- 通用查询映射结果 --> <resultMap id="BaseResultMap" type="Index"> <id column="id" property="id" /> <result column="name" property="name" /> <result column="creator" property="creator" /> <result column="creatorName" property="creatorName" /> <result column="createTime" property="createTime" /> <result column="updateTime" property="updateTime" /> <result column="type" property="type" /> <result column="typeName" property="typeName" /> <result column="branchName" property="branchName" /> <result column="bankBranchId" property="bankBranchId" /> </resultMap> <select id="getIndexList" resultMap="BaseResultMap"> SELECT * FROM ( SELECT bi.id AS id, bi.`name` AS `name`, bi.creator AS creator, crep.`name` AS creatorName, bi.create_time AS createTime, bi.update_time AS updateTime, '1' AS type, '业务服务指南' AS typeName, bbi.`name` AS branchName, bi.bank_branch_id AS bankBranchId FROM business_info bi LEFT JOIN employee crep ON crep.id = bi.creator LEFT JOIN bank_branch_info bbi ON bbi.id = bi.bank_branch_id <if test=" roleId == 2 "> WHERE bi.`status` = 2 OR bi.`status` = 3 </if> <if test=" roleId == 3 "> WHERE bi.`status` = 1 OR bi.`status` = 6 </if> UNION ALL SELECT bbi.id AS id, bbi.`name` AS `name`, bbi.modifier AS creator, crep.`name` AS creatorName, bbi.create_time AS createTime, bbi.update_time AS updateTime, '2' AS type, '网点地图' AS typeName, bbi.`name` AS branchName, bbi.id AS bankBranchId FROM bank_branch_info bbi LEFT JOIN employee crep ON crep.id = bbi.modifier <if test=" roleId == 2 "> WHERE bbi.is_show = 2 OR bbi.is_show = 3 </if> <if test=" roleId == 3 "> WHERE bbi.is_show = 1 OR bbi.is_show = 6 </if> UNION ALL SELECT hp.id AS id, hp.`name` AS `name`, hp.creator AS creator, crep.`name` AS creatorName, hp.create_time AS createTime, hp.update_time AS updateTime, '3' AS type, '热门产品' AS typeName, bbi.`name` AS branchName, hp.bank_branch_id AS bankBranchId FROM hot_product_activity hp LEFT JOIN employee crep ON crep.id = hp.creator LEFT JOIN bank_branch_info bbi ON bbi.id = hp.bank_branch_id WHERE hp.type = 1 <if test=" roleId == 2 "> AND (hp.is_show = 2 OR hp.is_show = 3) </if> <if test=" roleId == 3 "> AND (hp.is_show = 1 OR hp.is_show = 6) </if> UNION ALL SELECT ha.id AS id, ha.`name` AS `name`, ha.creator AS creator, crep.`name` AS creatorName, ha.create_time AS createTime, ha.update_time AS updateTime, '4' AS type, '热门活动' AS typeName, bbi.`name` AS branchName, ha.bank_branch_id AS bankBranchId FROM hot_product_activity ha LEFT JOIN employee crep ON crep.id = ha.creator LEFT JOIN bank_branch_info bbi ON bbi.id = ha.bank_branch_id WHERE ha.type = 2 <if test=" roleId == 2 "> AND (ha.is_show = 2 OR ha.is_show = 3) </if> <if test=" roleId == 3 "> AND (ha.is_show = 1 OR ha.is_show = 6) </if> ) T <where> <if test=" bankBranchId != null and bankBranchId != '' and roleId == 3"> T.bankBranchId = #{bankBranchId} </if> </where> ORDER BY T.updateTime DESC </select> </mapper>