upd: 编码规范
This commit is contained in:
+1
-1
@@ -13,7 +13,7 @@ import java.util.Set;
|
||||
@Mapper
|
||||
public interface DeptMapper extends BaseMapper<Dept> {
|
||||
|
||||
List<Dept> selectAll(@Param("criteria") DeptQueryCriteria criteria);
|
||||
List<Dept> selectByPage(@Param("criteria") DeptQueryCriteria criteria);
|
||||
|
||||
List<Dept> selectByPid(@Param("pid") Long pid);
|
||||
@Select("select count(*) from sys_dept where pid = #{pid}")
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ import java.util.List;
|
||||
@Mapper
|
||||
public interface DictMapper extends BaseMapper<Dict> {
|
||||
|
||||
IPage<Dict> findAll(@Param("criteria") DictQueryCriteria criteria, Page<Object> page);
|
||||
IPage<Dict> selectByPage(@Param("criteria") DictQueryCriteria criteria, Page<Object> page);
|
||||
|
||||
List<Dict> findAll(@Param("criteria") DictQueryCriteria criteria);
|
||||
List<Dict> selectByPage(@Param("criteria") DictQueryCriteria criteria);
|
||||
}
|
||||
+3
-3
@@ -15,9 +15,9 @@ import java.util.List;
|
||||
public interface JobMapper extends BaseMapper<Job> {
|
||||
|
||||
@Select("select id from sys_job where name = #{name}")
|
||||
Job findByName(@Param("name") String name);
|
||||
Job selectByName(@Param("name") String name);
|
||||
|
||||
List<Job> findAll(@Param("criteria") JobQueryCriteria criteria);
|
||||
List<Job> selectByPage(@Param("criteria") JobQueryCriteria criteria);
|
||||
|
||||
IPage<Job> findAll(@Param("criteria") JobQueryCriteria criteria, Page<Object> page);
|
||||
IPage<Job> selectByPage(@Param("criteria") JobQueryCriteria criteria, Page<Object> page);
|
||||
}
|
||||
+2
-2
@@ -8,9 +8,9 @@ import java.util.Set;
|
||||
|
||||
@Mapper
|
||||
public interface RoleDeptMapper {
|
||||
void insertData(@Param("roleId") Long roleId, @Param("depts") Set<Dept> depts);
|
||||
void insertBatchByRoleId(@Param("roleId") Long roleId, @Param("depts") Set<Dept> depts);
|
||||
|
||||
void deleteByRoleId(@Param("roleId") Long roleId);
|
||||
|
||||
void deleteByRoleIds(@Param("roleIds") Set<Long> roleIds);
|
||||
void deleteBatchByRoleIds(@Param("roleIds") Set<Long> roleIds);
|
||||
}
|
||||
|
||||
+9
-18
@@ -12,23 +12,14 @@ import java.util.Set;
|
||||
|
||||
@Mapper
|
||||
public interface RoleMapper extends BaseMapper<Role> {
|
||||
|
||||
List<Role> queryAll();
|
||||
|
||||
Long countAll(@Param("criteria") RoleQueryCriteria criteria);
|
||||
|
||||
List<Role> findAll(@Param("criteria") RoleQueryCriteria criteria);
|
||||
|
||||
Role findById(@Param("roleId") Long roleId);
|
||||
|
||||
Role findByName(@Param("name") String name);
|
||||
|
||||
List<Role> findByUserId(@Param("userId") Long userId);
|
||||
|
||||
int countByDepts(@Param("deptIds") Set<Long> deptIds);
|
||||
|
||||
@Select("SELECT role.role_id as id FROM sys_role role, sys_roles_menus rm " +
|
||||
"WHERE role.role_id = rm.role_id AND rm.menu_id = #{menuId}")
|
||||
List<Role> findByMenuId(@Param("menuId") Long menuId);
|
||||
List<Role> selectByPage();
|
||||
Long countByCriteria(@Param("criteria") RoleQueryCriteria criteria);
|
||||
List<Role> selectByPage(@Param("criteria") RoleQueryCriteria criteria);
|
||||
Role selectById(@Param("roleId") Long roleId);
|
||||
Role selectByName(@Param("name") String name);
|
||||
List<Role> selectByUserId(@Param("userId") Long userId);
|
||||
int countByDeptIds(@Param("deptIds") Set<Long> deptIds);
|
||||
@Select("SELECT role.role_id as id FROM sys_role role, sys_roles_menus rm WHERE role.role_id = rm.role_id AND rm.menu_id = #{menuId}")
|
||||
List<Role> selectByMenuId(@Param("menuId") Long menuId);
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -64,7 +64,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements De
|
||||
}
|
||||
// 数据权限
|
||||
criteria.setIds(SecurityUtil.getCurrentUserDataScope());
|
||||
List<Dept> list = deptMapper.selectAll(criteria);
|
||||
List<Dept> list = deptMapper.selectByPage(criteria);
|
||||
// 如果为空,就代表为自定义权限或者本级权限,就需要去重,不理解可以注释掉,看查询结果
|
||||
if (StringUtil.isBlank(dataScopeType)) {
|
||||
return deduplication(list);
|
||||
@@ -226,7 +226,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements De
|
||||
if (userMapper.countByDepts(deptIds) > 0) {
|
||||
throw new BadRequestException("所选部门存在用户关联,请解除后再试!");
|
||||
}
|
||||
if (roleMapper.countByDepts(deptIds) > 0) {
|
||||
if (roleMapper.countByDeptIds(deptIds) > 0) {
|
||||
throw new BadRequestException("所选部门存在角色关联,请解除后再试!");
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -32,13 +32,13 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements Di
|
||||
|
||||
@Override
|
||||
public PageResult<Dict> queryAll(DictQueryCriteria criteria, Page<Object> page) {
|
||||
IPage<Dict> dicts = dictMapper.findAll(criteria, page);
|
||||
IPage<Dict> dicts = dictMapper.selectByPage(criteria, page);
|
||||
return PageUtil.toPage(dicts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Dict> queryAll(DictQueryCriteria criteria) {
|
||||
return dictMapper.findAll(criteria);
|
||||
return dictMapper.selectByPage(criteria);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-4
@@ -32,12 +32,12 @@ public class JobServiceImpl extends ServiceImpl<JobMapper, Job> implements JobSe
|
||||
|
||||
@Override
|
||||
public PageResult<Job> queryAll(JobQueryCriteria criteria, Page<Object> page) {
|
||||
return PageUtil.toPage(jobMapper.findAll(criteria, page));
|
||||
return PageUtil.toPage(jobMapper.selectByPage(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Job> queryAll(JobQueryCriteria criteria) {
|
||||
return jobMapper.findAll(criteria);
|
||||
return jobMapper.selectByPage(criteria);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,7 +54,7 @@ public class JobServiceImpl extends ServiceImpl<JobMapper, Job> implements JobSe
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(Job resources) {
|
||||
Job job = jobMapper.findByName(resources.getName());
|
||||
Job job = jobMapper.selectByName(resources.getName());
|
||||
if (job != null) {
|
||||
throw new EntityExistException(Job.class, "name", resources.getName());
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public class JobServiceImpl extends ServiceImpl<JobMapper, Job> implements JobSe
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(Job resources) {
|
||||
Job job = getById(resources.getId());
|
||||
Job old = jobMapper.findByName(resources.getName());
|
||||
Job old = jobMapper.selectByName(resources.getName());
|
||||
if (old != null && !old.getId().equals(resources.getId())) {
|
||||
throw new EntityExistException(Job.class, "name", resources.getName());
|
||||
}
|
||||
|
||||
+13
-13
@@ -45,19 +45,19 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
||||
|
||||
@Override
|
||||
public List<Role> queryAll() {
|
||||
return roleMapper.queryAll();
|
||||
return roleMapper.selectByPage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Role> queryAll(RoleQueryCriteria criteria) {
|
||||
return roleMapper.findAll(criteria);
|
||||
return roleMapper.selectByPage(criteria);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<Role> queryAll(RoleQueryCriteria criteria, Page<Object> page) {
|
||||
criteria.setOffset(page.offset());
|
||||
List<Role> roles = roleMapper.findAll(criteria);
|
||||
Long total = roleMapper.countAll(criteria);
|
||||
List<Role> roles = roleMapper.selectByPage(criteria);
|
||||
Long total = roleMapper.countByCriteria(criteria);
|
||||
return PageUtil.toPage(roles, total);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
||||
String key = CacheKey.ROLE_ID + id;
|
||||
Role role = redisUtil.get(key, Role.class);
|
||||
if (role == null) {
|
||||
role = roleMapper.findById(id);
|
||||
role = roleMapper.selectById(id);
|
||||
redisUtil.set(key, role, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return role;
|
||||
@@ -75,13 +75,13 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(Role resources) {
|
||||
if (roleMapper.findByName(resources.getName()) != null) {
|
||||
if (roleMapper.selectByName(resources.getName()) != null) {
|
||||
throw new EntityExistException(Role.class, "username", resources.getName());
|
||||
}
|
||||
save(resources);
|
||||
// 判断是否有部门数据,若有,则需创建关联
|
||||
if (CollectionUtil.isNotEmpty(resources.getDepts())) {
|
||||
roleDeptMapper.insertData(resources.getId(), resources.getDepts());
|
||||
roleDeptMapper.insertBatchByRoleId(resources.getId(), resources.getDepts());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(Role resources) {
|
||||
Role role = getById(resources.getId());
|
||||
Role role1 = roleMapper.findByName(resources.getName());
|
||||
Role role1 = roleMapper.selectByName(resources.getName());
|
||||
if (role1 != null && !role1.getId().equals(role.getId())) {
|
||||
throw new EntityExistException(Role.class, "username", resources.getName());
|
||||
}
|
||||
@@ -104,7 +104,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
||||
roleDeptMapper.deleteByRoleId(resources.getId());
|
||||
// 判断是否有部门数据,若有,则需更新关联
|
||||
if (CollectionUtil.isNotEmpty(resources.getDepts())) {
|
||||
roleDeptMapper.insertData(resources.getId(), resources.getDepts());
|
||||
roleDeptMapper.insertBatchByRoleId(resources.getId(), resources.getDepts());
|
||||
}
|
||||
// 更新相关缓存
|
||||
delCaches(role.getId(), null);
|
||||
@@ -132,7 +132,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
||||
}
|
||||
removeBatchByIds(ids);
|
||||
// 删除角色部门关联数据、角色菜单关联数据
|
||||
roleDeptMapper.deleteByRoleIds(ids);
|
||||
roleDeptMapper.deleteBatchByRoleIds(ids);
|
||||
roleMenuMapper.deleteByRoleIds(ids);
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
||||
String key = CacheKey.ROLE_USER + userId;
|
||||
List<Role> roles = redisUtil.getList(key, Role.class);
|
||||
if (CollUtil.isEmpty(roles)) {
|
||||
roles = roleMapper.findByUserId(userId);
|
||||
roles = roleMapper.selectByUserId(userId);
|
||||
redisUtil.set(key, roles, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return roles;
|
||||
@@ -171,7 +171,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
||||
return permissions.stream().map(AuthorityDto::new)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
List<Role> roles = roleMapper.findByUserId(user.getId());
|
||||
List<Role> roles = roleMapper.selectByUserId(user.getId());
|
||||
permissions = roles.stream().flatMap(role -> role.getMenus().stream())
|
||||
.map(Menu::getPermission)
|
||||
.filter(StringUtil::isNotBlank).collect(Collectors.toSet());
|
||||
@@ -205,7 +205,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
||||
|
||||
@Override
|
||||
public List<Role> findByMenuId(Long menuId) {
|
||||
return roleMapper.findByMenuId(menuId);
|
||||
return roleMapper.selectByMenuId(menuId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<result column="update_time" property="updateTime"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectAll" resultMap="BaseResultMap">
|
||||
<select id="selectByPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
dept_id,
|
||||
`name`,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?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.odboy.modules.system.mapper.DictMapper">
|
||||
<select id="findAll" resultType="cn.odboy.model.system.domain.Dict">
|
||||
<select id="selectByPage" resultType="cn.odboy.model.system.domain.Dict">
|
||||
SELECT
|
||||
*
|
||||
from sys_dict d
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?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.odboy.modules.system.mapper.JobMapper">
|
||||
<select id="findAll" resultType="cn.odboy.model.system.domain.Job">
|
||||
<select id="selectByPage" resultType="cn.odboy.model.system.domain.Job">
|
||||
select
|
||||
*
|
||||
from sys_job
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?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.odboy.modules.system.mapper.RoleDeptMapper">
|
||||
<insert id="insertData">
|
||||
<insert id="insertBatchByRoleId">
|
||||
insert into sys_roles_depts (role_id, dept_id)
|
||||
values
|
||||
<foreach collection="depts" item="item" open="(" separator="),(" close=")">
|
||||
@@ -14,7 +14,7 @@
|
||||
where role_id = #{roleId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByRoleIds">
|
||||
<delete id="deleteBatchByRoleIds">
|
||||
delete from sys_roles_depts
|
||||
where role_id in
|
||||
<foreach collection="roleIds" item="id" open="(" separator="," close=")">
|
||||
|
||||
Reference in New Issue
Block a user