mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-11-04 10:57:10 +08:00 
			
		
		
		
	style: 移除 ` 符号的使用,保持数据库无关性
This commit is contained in:
		@@ -16,14 +16,13 @@
 | 
			
		||||
 | 
			
		||||
package top.charles7c.continew.admin.system.mapper;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.apache.ibatis.annotations.Param;
 | 
			
		||||
import org.apache.ibatis.annotations.Select;
 | 
			
		||||
 | 
			
		||||
import top.charles7c.continew.admin.system.model.entity.RoleDeptDO;
 | 
			
		||||
import top.charles7c.continew.starter.data.mybatis.plus.base.BaseMapper;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 角色和部门 Mapper
 | 
			
		||||
 *
 | 
			
		||||
@@ -38,6 +37,6 @@ public interface RoleDeptMapper extends BaseMapper<RoleDeptDO> {
 | 
			
		||||
     * @param roleId 角色 ID
 | 
			
		||||
     * @return 部门 ID 列表
 | 
			
		||||
     */
 | 
			
		||||
    @Select("SELECT `dept_id` FROM `sys_role_dept` WHERE `role_id` = #{roleId}")
 | 
			
		||||
    @Select("SELECT dept_id FROM sys_role_dept WHERE role_id = #{roleId}")
 | 
			
		||||
    List<Long> selectDeptIdByRoleId(@Param("roleId") Long roleId);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -37,7 +37,7 @@ public interface UserMapper extends DataPermissionMapper<UserDO> {
 | 
			
		||||
     * @param username 用户名
 | 
			
		||||
     * @return 用户信息
 | 
			
		||||
     */
 | 
			
		||||
    @Select("SELECT * FROM `sys_user` WHERE `username` = #{username}")
 | 
			
		||||
    @Select("SELECT * FROM sys_user WHERE username = #{username}")
 | 
			
		||||
    UserDO selectByUsername(@Param("username") String username);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -46,7 +46,7 @@ public interface UserMapper extends DataPermissionMapper<UserDO> {
 | 
			
		||||
     * @param phone 手机号
 | 
			
		||||
     * @return 用户信息
 | 
			
		||||
     */
 | 
			
		||||
    @Select("SELECT * FROM `sys_user` WHERE `phone` = #{phone}")
 | 
			
		||||
    @Select("SELECT * FROM sys_user WHERE phone = #{phone}")
 | 
			
		||||
    UserDO selectByPhone(@FieldEncrypt @Param("phone") String phone);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -55,7 +55,7 @@ public interface UserMapper extends DataPermissionMapper<UserDO> {
 | 
			
		||||
     * @param email 邮箱
 | 
			
		||||
     * @return 用户信息
 | 
			
		||||
     */
 | 
			
		||||
    @Select("SELECT * FROM `sys_user` WHERE `email` = #{email}")
 | 
			
		||||
    @Select("SELECT * FROM sys_user WHERE email = #{email}")
 | 
			
		||||
    UserDO selectByEmail(@FieldEncrypt @Param("email") String email);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -64,6 +64,6 @@ public interface UserMapper extends DataPermissionMapper<UserDO> {
 | 
			
		||||
     * @param id ID
 | 
			
		||||
     * @return 昵称
 | 
			
		||||
     */
 | 
			
		||||
    @Select("SELECT `nickname` FROM `sys_user` WHERE `id` = #{id}")
 | 
			
		||||
    @Select("SELECT nickname FROM sys_user WHERE id = #{id}")
 | 
			
		||||
    String selectNicknameById(@Param("id") Long id);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -38,6 +38,6 @@ public interface UserRoleMapper extends BaseMapper<UserRoleDO> {
 | 
			
		||||
     * @param userId 用户 ID
 | 
			
		||||
     * @return 角色 ID 列表
 | 
			
		||||
     */
 | 
			
		||||
    @Select("SELECT `role_id` FROM `sys_user_role` WHERE `user_id` = #{userId}")
 | 
			
		||||
    @Select("SELECT role_id FROM sys_user_role WHERE user_id = #{userId}")
 | 
			
		||||
    List<Long> selectRoleIdByUserId(@Param("userId") Long userId);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -155,7 +155,7 @@ public class DeptServiceImpl extends BaseServiceImpl<DeptMapper, DeptDO, DeptRes
 | 
			
		||||
     * @return 子部门列表
 | 
			
		||||
     */
 | 
			
		||||
    private List<DeptDO> listChildren(Long id) {
 | 
			
		||||
        return baseMapper.lambdaQuery().apply(String.format("find_in_set(%s, `ancestors`)", id)).list();
 | 
			
		||||
        return baseMapper.lambdaQuery().apply(String.format("find_in_set(%s, ancestors)", id)).list();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -170,7 +170,7 @@ public class DeptServiceImpl extends BaseServiceImpl<DeptMapper, DeptDO, DeptRes
 | 
			
		||||
            return 0L;
 | 
			
		||||
        }
 | 
			
		||||
        return ids.stream()
 | 
			
		||||
            .mapToLong(id -> baseMapper.lambdaQuery().apply(String.format("find_in_set(%s, `ancestors`)", id)).count())
 | 
			
		||||
            .mapToLong(id -> baseMapper.lambdaQuery().apply(String.format("find_in_set(%s, ancestors)", id)).count())
 | 
			
		||||
            .sum();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -5,11 +5,11 @@
 | 
			
		||||
    <select id="selectDashboardList"
 | 
			
		||||
            resultType="top.charles7c.continew.admin.system.model.resp.DashboardAnnouncementResp">
 | 
			
		||||
        SELECT
 | 
			
		||||
            `id`, `title`, `type`
 | 
			
		||||
        FROM `sys_announcement`
 | 
			
		||||
        WHERE (`effective_time` IS NULL OR NOW() > `effective_time`)
 | 
			
		||||
          AND (`terminate_time` IS NULL OR `terminate_time` > NOW())
 | 
			
		||||
        ORDER BY `sort` ASC, `effective_time` DESC
 | 
			
		||||
            id, title, type
 | 
			
		||||
        FROM sys_announcement
 | 
			
		||||
        WHERE (effective_time IS NULL OR NOW() > effective_time)
 | 
			
		||||
          AND (terminate_time IS NULL OR terminate_time > NOW())
 | 
			
		||||
        ORDER BY sort ASC, effective_time DESC
 | 
			
		||||
        LIMIT 5
 | 
			
		||||
    </select>
 | 
			
		||||
</mapper>
 | 
			
		||||
@@ -2,10 +2,10 @@
 | 
			
		||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 | 
			
		||||
<mapper namespace="top.charles7c.continew.admin.system.mapper.DictItemMapper">
 | 
			
		||||
    <select id="listByDictCode" resultType="top.charles7c.continew.admin.common.model.resp.LabelValueResp">
 | 
			
		||||
        SELECT t1.`label`, t1.`value`, t1.`color`
 | 
			
		||||
        FROM `sys_dict_item` AS t1
 | 
			
		||||
        LEFT JOIN `sys_dict` AS t2 ON t1.`dict_id` = t2.`id`
 | 
			
		||||
        WHERE t2.`code` = #{dictCode}
 | 
			
		||||
        ORDER BY t1.`sort` ASC
 | 
			
		||||
        SELECT t1.label, t1.value, t1.color
 | 
			
		||||
        FROM sys_dict_item AS t1
 | 
			
		||||
        LEFT JOIN sys_dict AS t2 ON t1.dict_id = t2.id
 | 
			
		||||
        WHERE t2.code = #{dictCode}
 | 
			
		||||
        ORDER BY t1.sort ASC
 | 
			
		||||
    </select>
 | 
			
		||||
</mapper>
 | 
			
		||||
@@ -2,25 +2,25 @@
 | 
			
		||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 | 
			
		||||
<mapper namespace="top.charles7c.continew.admin.system.mapper.MenuMapper">
 | 
			
		||||
    <select id="selectPermissionByUserId" resultType="java.lang.String">
 | 
			
		||||
        SELECT DISTINCT t1.`permission`
 | 
			
		||||
        FROM `sys_menu` AS t1
 | 
			
		||||
            LEFT JOIN `sys_role_menu` AS t2 ON t2.`menu_id` = t1.`id`
 | 
			
		||||
            LEFT JOIN `sys_role` AS t3 ON t3.`id` = t2.`role_id`
 | 
			
		||||
            LEFT JOIN `sys_user_role` AS t4 ON t4.`role_id` = t3.`id`
 | 
			
		||||
            LEFT JOIN `sys_user` AS t5 ON t5.`id` = t4.`user_id`
 | 
			
		||||
        WHERE t5.`id` = #{userId}
 | 
			
		||||
          AND t1.`type` IN (2, 3)
 | 
			
		||||
          AND t1.`status` = 1
 | 
			
		||||
          AND t3.`status` = 1
 | 
			
		||||
        SELECT DISTINCT t1.permission
 | 
			
		||||
        FROM sys_menu AS t1
 | 
			
		||||
            LEFT JOIN sys_role_menu AS t2 ON t2.menu_id = t1.id
 | 
			
		||||
            LEFT JOIN sys_role AS t3 ON t3.id = t2.role_id
 | 
			
		||||
            LEFT JOIN sys_user_role AS t4 ON t4.role_id = t3.id
 | 
			
		||||
            LEFT JOIN sys_user AS t5 ON t5.id = t4.user_id
 | 
			
		||||
        WHERE t5.id = #{userId}
 | 
			
		||||
          AND t1.type IN (2, 3)
 | 
			
		||||
          AND t1.status = 1
 | 
			
		||||
          AND t3.status = 1
 | 
			
		||||
    </select>
 | 
			
		||||
 | 
			
		||||
    <select id="selectListByRoleCode" resultType="top.charles7c.continew.admin.system.model.entity.MenuDO">
 | 
			
		||||
        SELECT t1.*
 | 
			
		||||
        FROM `sys_menu` AS t1
 | 
			
		||||
            LEFT JOIN `sys_role_menu` AS t2 ON t2.`menu_id` = t1.`id`
 | 
			
		||||
            LEFT JOIN `sys_role` AS t3 ON t3.`id` = t2.`role_id`
 | 
			
		||||
        WHERE t3.`code` = #{roleCode}
 | 
			
		||||
          AND t1.`status` = 1
 | 
			
		||||
          AND t3.`status` = 1
 | 
			
		||||
        FROM sys_menu AS t1
 | 
			
		||||
            LEFT JOIN sys_role_menu AS t2 ON t2.menu_id = t1.id
 | 
			
		||||
            LEFT JOIN sys_role AS t3 ON t3.id = t2.role_id
 | 
			
		||||
        WHERE t3.code = #{roleCode}
 | 
			
		||||
          AND t1.status = 1
 | 
			
		||||
          AND t3.status = 1
 | 
			
		||||
    </select>
 | 
			
		||||
</mapper>
 | 
			
		||||
@@ -4,11 +4,11 @@
 | 
			
		||||
    <select id="selectPageByUserId" resultType="top.charles7c.continew.admin.system.model.resp.MessageResp">
 | 
			
		||||
        SELECT
 | 
			
		||||
            t1.*,
 | 
			
		||||
            t2.`user_id`,
 | 
			
		||||
            t2.`is_read`,
 | 
			
		||||
            t2.`read_time`
 | 
			
		||||
        FROM `sys_message` AS t1
 | 
			
		||||
            LEFT JOIN `sys_message_user` AS t2 ON t2.`message_id` = t1.`id`
 | 
			
		||||
            t2.user_id,
 | 
			
		||||
            t2.is_read,
 | 
			
		||||
            t2.read_time
 | 
			
		||||
        FROM sys_message AS t1
 | 
			
		||||
            LEFT JOIN sys_message_user AS t2 ON t2.message_id = t1.id
 | 
			
		||||
        ${ew.getCustomSqlSegment}
 | 
			
		||||
    </select>
 | 
			
		||||
</mapper>
 | 
			
		||||
 
 | 
			
		||||
@@ -3,12 +3,12 @@
 | 
			
		||||
<mapper namespace="top.charles7c.continew.admin.system.mapper.MessageUserMapper">
 | 
			
		||||
    <select id="selectUnreadCountByUserIdAndType" resultType="Long">
 | 
			
		||||
        SELECT
 | 
			
		||||
            COUNT(t1.`message_id`)
 | 
			
		||||
        FROM `sys_message_user` AS t1
 | 
			
		||||
            LEFT JOIN `sys_message` AS t2 ON t2.`id` = t1.`message_id`
 | 
			
		||||
        WHERE t1.`user_id` = #{userId} AND t1.`is_read` = 0
 | 
			
		||||
            COUNT(t1.message_id)
 | 
			
		||||
        FROM sys_message_user AS t1
 | 
			
		||||
            LEFT JOIN sys_message AS t2 ON t2.id = t1.message_id
 | 
			
		||||
        WHERE t1.user_id = #{userId} AND t1.is_read = 0
 | 
			
		||||
        <if test="type != null">
 | 
			
		||||
            AND t2.`type` = #{type}
 | 
			
		||||
            AND t2.type = #{type}
 | 
			
		||||
        </if>
 | 
			
		||||
    </select>
 | 
			
		||||
</mapper>
 | 
			
		||||
@@ -2,9 +2,9 @@
 | 
			
		||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 | 
			
		||||
<mapper namespace="top.charles7c.continew.admin.system.mapper.RoleMenuMapper">
 | 
			
		||||
    <select id="selectMenuIdByRoleIds" resultType="java.lang.Long">
 | 
			
		||||
        SELECT `menu_id`
 | 
			
		||||
        FROM `sys_role_menu`
 | 
			
		||||
        WHERE `role_id` IN
 | 
			
		||||
        SELECT menu_id
 | 
			
		||||
        FROM sys_role_menu
 | 
			
		||||
        WHERE role_id IN
 | 
			
		||||
        <foreach collection="list" item="roleId" open="(" close=")" separator=",">
 | 
			
		||||
            #{roleId}
 | 
			
		||||
        </foreach>
 | 
			
		||||
 
 | 
			
		||||
@@ -4,8 +4,8 @@
 | 
			
		||||
    <select id="selectBySourceAndOpenId"
 | 
			
		||||
            resultType="top.charles7c.continew.admin.system.model.entity.UserSocialDO">
 | 
			
		||||
        SELECT t1.*
 | 
			
		||||
        FROM `sys_user_social` AS t1
 | 
			
		||||
            LEFT JOIN `sys_user` AS t2 ON t2.`id` = t1.`user_id`
 | 
			
		||||
        WHERE t1.`source` = #{source} AND t1.`open_id` = #{openId}
 | 
			
		||||
        FROM sys_user_social AS t1
 | 
			
		||||
            LEFT JOIN sys_user AS t2 ON t2.id = t1.user_id
 | 
			
		||||
        WHERE t1.source = #{source} AND t1.open_id = #{openId}
 | 
			
		||||
    </select>
 | 
			
		||||
</mapper>
 | 
			
		||||
		Reference in New Issue
	
	Block a user