角色管理添加角色编码
This commit is contained in:
parent
81a78dfab5
commit
77abbcae6e
|
|
@ -64,6 +64,9 @@ public class SysRole extends BaseEntity
|
|||
/** 角色菜单权限 */
|
||||
private Set<String> permissions;
|
||||
|
||||
/** 角色编码 */
|
||||
private String roleCode;
|
||||
|
||||
public SysRole()
|
||||
{
|
||||
|
||||
|
|
@ -219,6 +222,14 @@ public class SysRole extends BaseEntity
|
|||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
public String getRoleCode() {
|
||||
return roleCode;
|
||||
}
|
||||
|
||||
public void setRoleCode(String roleCode) {
|
||||
this.roleCode = roleCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
|
|
@ -236,6 +247,7 @@ public class SysRole extends BaseEntity
|
|||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.append("roleCode", getRoleCode())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,17 @@
|
|||
<description>
|
||||
bonus-common-entity
|
||||
</description>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.bonus</groupId>
|
||||
<artifactId>bonus-common-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bonus</groupId>
|
||||
<artifactId>bonus-common-security</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
package com.bonus.common.entity.app;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @className:AppParamsDto
|
||||
* @author:cwchen
|
||||
* @date:2024-07-15-17:11
|
||||
* @version:1.0
|
||||
* @description:APP前端参数-dto
|
||||
*/
|
||||
@Data
|
||||
public class AppParamsDto {
|
||||
/** id */
|
||||
private String id;
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.bonus.common.entity.app.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @className:AppVo
|
||||
* @author:cwchen
|
||||
* @date:2024-07-15-17:25
|
||||
* @version:1.0
|
||||
* @description:App-vo
|
||||
*/
|
||||
@Data
|
||||
public class AppVo {
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.bonus.common.entity.bracelet;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @className:ParamsDto
|
||||
* @author:cwchen
|
||||
* @date:2024-07-15-17:10
|
||||
* @version:1.0
|
||||
* @description:手环模块前端参数-dto
|
||||
*/
|
||||
@Data
|
||||
public class BraceletParamsDto {
|
||||
|
||||
/** id */
|
||||
private String id;
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.bonus.common.entity.bracelet.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @className:ProjectVo
|
||||
* @author:cwchen
|
||||
* @date:2024-07-15-17:24
|
||||
* @version:1.0
|
||||
* @description:工程管理-vo
|
||||
*/
|
||||
@Data
|
||||
public class ProjectVo {
|
||||
|
||||
/** id */
|
||||
private Long id;
|
||||
}
|
||||
|
|
@ -82,6 +82,12 @@
|
|||
<artifactId>jasypt-spring-boot-starter</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bonus</groupId>
|
||||
<artifactId>bonus-common-entity</artifactId>
|
||||
<version>24.6.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
package com.bonus.bracelet.controller;
|
||||
|
||||
import com.bonus.bracelet.service.IProjectMgeService;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.entity.bracelet.BraceletParamsDto;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @className:ProjectMgeController
|
||||
* @author:cwchen
|
||||
* @date:2024-07-15-17:00
|
||||
* @version:1.0
|
||||
* @description:工程管理-controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/project/")
|
||||
@Slf4j
|
||||
public class ProjectMgeController {
|
||||
|
||||
@Resource(name = "IProjectMgeService")
|
||||
private IProjectMgeService service;
|
||||
|
||||
@GetMapping("/getProjectLists")
|
||||
public AjaxResult getProjectLists(BraceletParamsDto dto) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.bonus.bracelet.mapper;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @className:ProjectMgeMapper
|
||||
* @author:cwchen
|
||||
* @date:2024-07-15-17:02
|
||||
* @version:1.0
|
||||
* @description:工程管理-mapper
|
||||
*/
|
||||
@Repository(value = "ProjectMgeMapper")
|
||||
public interface ProjectMgeMapper {
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.bonus.bracelet.service;
|
||||
|
||||
/**
|
||||
* @className:IProjectMgeService
|
||||
* @author:cwchen
|
||||
* @date:2024-07-15-17:01
|
||||
* @version:1.0
|
||||
* @description:工程管理-service
|
||||
*/
|
||||
public interface IProjectMgeService {
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.bonus.bracelet.service.impl;
|
||||
|
||||
import com.bonus.bracelet.service.IProjectMgeService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @className:ProjectMgeServiceImpl
|
||||
* @author:cwchen
|
||||
* @date:2024-07-15-17:02
|
||||
* @version:1.0
|
||||
* @description:工程管理-serviceImpl
|
||||
*/
|
||||
@Service(value = "IProjectMgeService")
|
||||
@Slf4j
|
||||
public class ProjectMgeServiceImpl implements IProjectMgeService {
|
||||
}
|
||||
|
|
@ -0,0 +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="com.bonus.bracelet.mapper.ProjectMgeMapper">
|
||||
|
||||
</mapper>
|
||||
|
|
@ -104,6 +104,8 @@ public class SysRoleController extends BaseController
|
|||
return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||
} else if (!roleService.checkRoleKeyUnique(role)) {
|
||||
return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||
}else if (!roleService.checkRoleCodeUnique(role)) {
|
||||
return error("新增角色'" + role.getRoleCode() + "'失败,角色编码已存在");
|
||||
}
|
||||
role.setCreateBy(SecurityUtils.getUsername());
|
||||
return toAjax(roleService.insertRole(role));
|
||||
|
|
@ -127,6 +129,8 @@ public class SysRoleController extends BaseController
|
|||
return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
||||
} else if (!roleService.checkRoleKeyUnique(role)) {
|
||||
return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
||||
}else if (!roleService.checkRoleCodeUnique(role)) {
|
||||
return error("修改角色'" + role.getRoleCode() + "'失败,角色编码已存在");
|
||||
}
|
||||
role.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(roleService.updateRole(role));
|
||||
|
|
|
|||
|
|
@ -104,4 +104,13 @@ public interface SysRoleMapper
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteRoleByIds(Long[] roleIds);
|
||||
|
||||
/**
|
||||
* 校验角色编码是否唯一
|
||||
* @param roleCode
|
||||
* @return SysRole
|
||||
* @author cwchen
|
||||
* @date 2024/7/15 16:40
|
||||
*/
|
||||
SysRole checkRoleCodeUnique(String roleCode);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,4 +170,13 @@ public interface ISysRoleService
|
|||
* @return 结果
|
||||
*/
|
||||
public int insertAuthUsers(Long roleId, Long[] userIds);
|
||||
|
||||
/**
|
||||
* 校验角色编码是否唯一
|
||||
* @param role
|
||||
* @return boolean
|
||||
* @author cwchen
|
||||
* @date 2024/7/15 16:38
|
||||
*/
|
||||
boolean checkRoleCodeUnique(SysRole role);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -424,4 +424,17 @@ public class SysRoleServiceImpl implements ISysRoleService
|
|||
}
|
||||
return userRoleMapper.batchUserRole(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkRoleCodeUnique(SysRole role) {
|
||||
{
|
||||
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
|
||||
SysRole info = roleMapper.checkRoleCodeUnique(role.getRoleCode());
|
||||
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue())
|
||||
{
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,11 +19,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="roleCode" column="role_code" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectRoleVo">
|
||||
select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly,
|
||||
r.status, r.del_flag, r.create_time, r.remark
|
||||
r.status, r.del_flag, r.create_time, r.remark ,r.role_code
|
||||
from sys_role r
|
||||
left join sys_user_role ur on ur.role_id = r.role_id
|
||||
left join sys_user u on u.user_id = ur.user_id
|
||||
|
|
@ -92,8 +93,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<include refid="selectRoleVo"/>
|
||||
where r.role_key=#{roleKey} and r.del_flag = '0' limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertRole" parameterType="SysRole" useGeneratedKeys="true" keyProperty="roleId">
|
||||
<!--校验角色编码是否唯一-->
|
||||
<select id="checkRoleCodeUnique" resultType="com.bonus.system.api.domain.SysRole">
|
||||
<include refid="selectRoleVo"/>
|
||||
where r.role_code=#{roleCode} and r.del_flag = '0' limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertRole" parameterType="SysRole" useGeneratedKeys="true" keyProperty="roleId">
|
||||
insert into sys_role(
|
||||
<if test="roleId != null and roleId != 0">role_id,</if>
|
||||
<if test="roleName != null and roleName != ''">role_name,</if>
|
||||
|
|
@ -105,6 +111,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
<if test="roleCode != null and roleCode != ''">role_code,</if>
|
||||
create_time
|
||||
)values(
|
||||
<if test="roleId != null and roleId != 0">#{roleId},</if>
|
||||
|
|
@ -117,6 +124,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
<if test="roleCode != null and roleCode != ''">#{roleCode},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
|
@ -133,6 +141,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="status != null and status != ''">status = #{status},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
<if test="roleCode != null and roleCode != ''">role_code = #{roleCode},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where role_id = #{roleId}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader,u.login_type,u.team_id,sr.role_code,sr.role_name from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
LEFT JOIN sys_user_role sur ON u.user_id = sur.user_id
|
||||
LEFT JOIN sys_role sr ON sur.role_id = sr.role_id AND sr.del_flag = '0' AND sr.status = '0'
|
||||
LEFT JOIN sys_role sr ON sur.role_id = sr.role_id AND sr.del_flag = '0'
|
||||
where u.del_flag = '0'
|
||||
<if test="userId != null and userId != 0">
|
||||
AND u.user_id = #{userId}
|
||||
|
|
|
|||
Loading…
Reference in New Issue