#update
This commit is contained in:
@@ -166,6 +166,8 @@ public class SysLoginController {
|
||||
ajax.put("nickName", nickName);
|
||||
if (sysUser != null) {
|
||||
ajax.put("roleId",sysUser.getRoleId());
|
||||
ajax.put("siteId",sysUser.getSiteId());
|
||||
ajax.put("orgId",sysUser.getOrgId());
|
||||
aiChatNum = sysUser.getAiChatNum();
|
||||
sysUser.setSessionId(split[1]);
|
||||
sysUser.setDisplayPassword(password);
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.maibu.service.ISysDeptService;
|
||||
import com.maibu.service.ISysRoleService;
|
||||
import com.maibu.service.ISysUserService;
|
||||
import com.maibu.utils.MessageUtils;
|
||||
import com.maibu.utils.SecurityUtils;
|
||||
import com.maibu.utils.StringUtils;
|
||||
import com.maibu.utils.collection.CollectionUtils;
|
||||
import com.maibu.utils.poi.ExcelUtil;
|
||||
@@ -187,6 +188,17 @@ public class SysRoleController extends BaseController {
|
||||
return success(roleService.selectRoleAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色选择框列表
|
||||
*/
|
||||
@ApiOperation("获取角色选择框列表")
|
||||
@GetMapping("/selectAllocatableRole")
|
||||
public AjaxResult selectAllocatableRole() {
|
||||
Long roleId = SecurityUtils.getLoginUser() == null? null:SecurityUtils.getLoginUser().getRoleId();
|
||||
return success(roleService.selectAllocatableRole(roleId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询已分配用户角色列表
|
||||
*/
|
||||
|
||||
@@ -37,8 +37,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
@Api(tags = "用户管理")
|
||||
@RestController
|
||||
@RequestMapping("/system/user")
|
||||
public class SysUserController extends BaseController
|
||||
{
|
||||
public class SysUserController extends BaseController {
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
@@ -54,8 +53,7 @@ public class SysUserController extends BaseController
|
||||
@ApiOperation("获取用户分页列表")
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysUser user)
|
||||
{
|
||||
public TableDataInfo list(SysUser user) {
|
||||
startPage();
|
||||
// if (null == user.getDeptId()) {
|
||||
// user.setDeptId(getLoginUser().getDeptId());
|
||||
@@ -68,8 +66,7 @@ public class SysUserController extends BaseController
|
||||
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:export')")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysUser user)
|
||||
{
|
||||
public void export(HttpServletResponse response, SysUser user) {
|
||||
if (null == user.getDeptId()) {
|
||||
user.setDeptId(getLoginUser().getDeptId());
|
||||
}
|
||||
@@ -82,8 +79,7 @@ public class SysUserController extends BaseController
|
||||
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:import')")
|
||||
@PostMapping("/importData")
|
||||
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
|
||||
{
|
||||
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
|
||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||
List<SysUser> userList = util.importExcel(file.getInputStream());
|
||||
String operName = getUsername();
|
||||
@@ -94,8 +90,7 @@ public class SysUserController extends BaseController
|
||||
|
||||
@ApiOperation("下载用户导入模板")
|
||||
@PostMapping("/importTemplate")
|
||||
public void importTemplate(HttpServletResponse response)
|
||||
{
|
||||
public void importTemplate(HttpServletResponse response) {
|
||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||
util.importTemplateExcel(response, "用户数据");
|
||||
}
|
||||
@@ -105,16 +100,14 @@ public class SysUserController extends BaseController
|
||||
*/
|
||||
@ApiOperation("根据用户编号获取详细信息")
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:query')")
|
||||
@GetMapping(value = { "/", "/{userId}" })
|
||||
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
|
||||
{
|
||||
@GetMapping(value = {"/", "/{userId}"})
|
||||
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) {
|
||||
userService.checkUserDataScope(userId);
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
// List<SysRole> roles = roleService.selectRoleAll();
|
||||
// ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||
// ajax.put("posts", postService.selectPostAll());
|
||||
if (StringUtils.isNotNull(userId))
|
||||
{
|
||||
if (StringUtils.isNotNull(userId)) {
|
||||
SysUser sysUser = userService.selectUserById(userId);
|
||||
ajax.put(AjaxResult.DATA_TAG, sysUser);
|
||||
// ajax.put("postIds", postService.selectPostListByUserId(userId));
|
||||
@@ -135,20 +128,14 @@ public class SysUserController extends BaseController
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:add')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysUser user)
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user)))
|
||||
{
|
||||
public AjaxResult add(@Validated @RequestBody SysUser user) {
|
||||
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user))) {
|
||||
return error(StringUtils.format(MessageUtils.message("user.add.failed.name.exists"), user.getUserName()));
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(user.getPhonenumber())
|
||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
||||
{
|
||||
} else if (StringUtils.isNotEmpty(user.getPhonenumber())
|
||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
|
||||
return error(StringUtils.format(MessageUtils.message("user.add.failed.phone.exists"), user.getUserName()));
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(user.getEmail())
|
||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
||||
{
|
||||
} else if (StringUtils.isNotEmpty(user.getEmail())
|
||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
||||
return error(StringUtils.format(MessageUtils.message("user.add.failed.email.exists"), user.getUserName()));
|
||||
}
|
||||
user.setCreateBy(getUsername());
|
||||
@@ -165,26 +152,22 @@ public class SysUserController extends BaseController
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysUser user)
|
||||
{
|
||||
public AjaxResult edit(@Validated @RequestBody SysUser user) {
|
||||
userService.checkUserAllowed(user);
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user)))
|
||||
{
|
||||
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user))) {
|
||||
return error(StringUtils.format(MessageUtils.message("user.update.failed.name.exists"), user.getUserName()));
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(user.getPhonenumber())
|
||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
||||
{
|
||||
} else if (StringUtils.isNotEmpty(user.getPhonenumber())
|
||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
|
||||
return error(StringUtils.format(MessageUtils.message("user.update.failed.phone.exists"), user.getUserName()));
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(user.getEmail())
|
||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
||||
{
|
||||
} else if (StringUtils.isNotEmpty(user.getEmail())
|
||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
||||
return error(StringUtils.format(MessageUtils.message("user.update.failed.email.exists"), user.getUserName()));
|
||||
}
|
||||
user.setUpdateBy(getUsername());
|
||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||
if (!StringUtils.isEmpty(user.getPassword())) {
|
||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||
}
|
||||
user.setDisplayPassword(user.getPassword());
|
||||
return toAjax(userService.updateUser(user));
|
||||
}
|
||||
@@ -196,10 +179,8 @@ public class SysUserController extends BaseController
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:remove')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{userIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] userIds)
|
||||
{
|
||||
if (ArrayUtils.contains(userIds, getUserId()))
|
||||
{
|
||||
public AjaxResult remove(@PathVariable Long[] userIds) {
|
||||
if (ArrayUtils.contains(userIds, getUserId())) {
|
||||
return error(MessageUtils.message("user.delete.failed"));
|
||||
}
|
||||
return toAjax(userService.deleteUserByIds(userIds));
|
||||
@@ -212,8 +193,7 @@ public class SysUserController extends BaseController
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/resetPwd")
|
||||
public AjaxResult resetPwd(@RequestBody SysUser user)
|
||||
{
|
||||
public AjaxResult resetPwd(@RequestBody SysUser user) {
|
||||
userService.checkUserAllowed(user);
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||
@@ -229,8 +209,7 @@ public class SysUserController extends BaseController
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/changeStatus")
|
||||
public AjaxResult changeStatus(@RequestBody SysUser user)
|
||||
{
|
||||
public AjaxResult changeStatus(@RequestBody SysUser user) {
|
||||
userService.checkUserAllowed(user);
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
user.setUpdateBy(getUsername());
|
||||
@@ -243,8 +222,7 @@ public class SysUserController extends BaseController
|
||||
@ApiOperation("根据用户编号获取授权角色")
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:query')")
|
||||
@GetMapping("/authRole/{userId}")
|
||||
public AjaxResult authRole(@PathVariable("userId") Long userId)
|
||||
{
|
||||
public AjaxResult authRole(@PathVariable("userId") Long userId) {
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
SysUser user = userService.selectUserById(userId);
|
||||
List<SysRole> roles = roleService.selectRolesByUserId(userId);
|
||||
@@ -260,8 +238,7 @@ public class SysUserController extends BaseController
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||
@Log(title = "用户管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authRole")
|
||||
public AjaxResult insertAuthRole(Long userId, Long[] roleIds)
|
||||
{
|
||||
public AjaxResult insertAuthRole(Long userId, Long[] roleIds) {
|
||||
userService.checkUserDataScope(userId);
|
||||
userService.insertUserAuth(userId, roleIds);
|
||||
return success();
|
||||
@@ -273,8 +250,7 @@ public class SysUserController extends BaseController
|
||||
@ApiOperation("获取部门树列表")
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:list')")
|
||||
@GetMapping("/deptTree")
|
||||
public AjaxResult deptTree(SysDept dept)
|
||||
{
|
||||
public AjaxResult deptTree(SysDept dept) {
|
||||
return success(deptService.selectDeptTreeList(dept));
|
||||
}
|
||||
|
||||
@@ -286,8 +262,7 @@ public class SysUserController extends BaseController
|
||||
@ApiOperation("获取用户分页列表")
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:list')")
|
||||
@GetMapping("/listTerminal")
|
||||
public TableDataInfo listTerminal(SysUser user)
|
||||
{
|
||||
public TableDataInfo listTerminal(SysUser user) {
|
||||
startPage();
|
||||
List<SysUser> list = userService.listTerminal(user);
|
||||
return getDataTable(list);
|
||||
@@ -300,8 +275,7 @@ public class SysUserController extends BaseController
|
||||
@ApiOperation("根据机构id获取当前用户列表")
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:list')")
|
||||
@GetMapping("/getByDeptId")
|
||||
public TableDataInfo getByDeptId()
|
||||
{
|
||||
public TableDataInfo getByDeptId() {
|
||||
startPage();
|
||||
List<SysUser> list = userService.selectByDeptId();
|
||||
return getDataTable(list);
|
||||
@@ -311,8 +285,7 @@ public class SysUserController extends BaseController
|
||||
* 根据机构id获取当前用户列表
|
||||
*/
|
||||
@GetMapping("/getByRoleId")
|
||||
public TableDataInfo getByRoleId(@RequestParam Long id)
|
||||
{
|
||||
public TableDataInfo getByRoleId(@RequestParam Long id) {
|
||||
startPage();
|
||||
List<SysUser> list = userService.selectByRoleId(id);
|
||||
return getDataTable(list);
|
||||
|
||||
@@ -113,6 +113,8 @@ public class SysRole extends BaseDO {
|
||||
*/
|
||||
private Boolean siteAccess = false;
|
||||
|
||||
private Integer roleLevel;
|
||||
|
||||
|
||||
public SysRole() {
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public class SysSite extends BaseDO {
|
||||
|
||||
private String siteCode;
|
||||
|
||||
private String orgId;
|
||||
private Long orgId;
|
||||
|
||||
private BigDecimal longitude;
|
||||
|
||||
|
||||
@@ -108,11 +108,12 @@ public class LoginUser implements UserDetails {
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
public LoginUser(Long userId, Long deptId, Long orgId, Long siteId, String language, SysUser user, Set<String> permissions) {
|
||||
public LoginUser(Long userId, Long deptId, Long orgId, Long siteId, Long roleId,String language, SysUser user, Set<String> permissions) {
|
||||
this.userId = userId;
|
||||
this.deptId = deptId;
|
||||
this.orgId = orgId;
|
||||
this.siteId = siteId;
|
||||
this.roleId = roleId;
|
||||
this.user = user;
|
||||
this.language = language;
|
||||
this.permissions = permissions;
|
||||
|
||||
@@ -60,6 +60,6 @@ public class UserDetailsServiceImpl implements UserDetailsService
|
||||
|
||||
public UserDetails createLoginUser(SysUser user)
|
||||
{
|
||||
return new LoginUser(user.getUserId(), user.getDeptId(), user.getOrgId(),user.getSiteId(),user.getLanguage(), user, permissionService.getMenuPermission(user));
|
||||
return new LoginUser(user.getUserId(), user.getDeptId(), user.getOrgId(),user.getSiteId(),user.getRoleId(),user.getLanguage(), user, permissionService.getMenuPermission(user));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ public interface SysRoleMapper
|
||||
*/
|
||||
public List<SysRole> selectRoleAll();
|
||||
|
||||
public List<SysRole> selectAllocatableRole(Integer roleLevel);
|
||||
|
||||
/**
|
||||
* 根据用户ID获取角色选择框列表
|
||||
*
|
||||
|
||||
@@ -46,6 +46,13 @@ public interface ISysRoleService
|
||||
*/
|
||||
public List<SysRole> selectRoleAll();
|
||||
|
||||
/**
|
||||
* 查询所有角色
|
||||
*
|
||||
* @return 角色列表
|
||||
*/
|
||||
public List<SysRole> selectAllocatableRole(Long roleId);
|
||||
|
||||
/**
|
||||
* 根据用户ID获取角色选择框列表
|
||||
*
|
||||
|
||||
@@ -29,6 +29,9 @@ public class SysSiteService {
|
||||
if (site != null && !StringUtils.isEmpty(site.getSiteName())) {
|
||||
queryWrapper.like(SysSite::getSiteName, site.getSiteName());
|
||||
}
|
||||
if (site != null && site.getOrgId()!=null) {
|
||||
queryWrapper.eq(SysSite::getOrgId, site.getOrgId());
|
||||
}
|
||||
return sysSiteMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
@@ -116,6 +116,17 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
||||
return permsSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有角色
|
||||
*
|
||||
* @return 角色列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysRole> selectAllocatableRole(Long roleId) {
|
||||
SysRole sysRole = roleMapper.selectRoleById(roleId);
|
||||
return roleMapper.selectAllocatableRole(sysRole.getRoleLevel());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有角色
|
||||
*
|
||||
|
||||
@@ -21,11 +21,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="remark" column="remark" />
|
||||
<result property="menuList" column="menu_list" />
|
||||
<result property="siteAccess" column="site_access" />
|
||||
<result property="roleLevel" column="role_level" />
|
||||
</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.site_access
|
||||
r.status, r.del_flag, r.create_time, r.remark,r.site_access,r.role_level
|
||||
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
|
||||
@@ -44,7 +45,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
r.del_flag,
|
||||
r.create_time,
|
||||
r.remark,
|
||||
r.site_access
|
||||
r.site_access,
|
||||
r.role_level,
|
||||
GROUP_CONCAT(srm.menu_id) AS menu_list
|
||||
FROM sys_role r
|
||||
LEFT JOIN sys_user_role ur ON ur.role_id = r.role_id
|
||||
@@ -93,12 +95,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
r.create_time,
|
||||
r.remark,
|
||||
r.site_access,
|
||||
r.role_level,
|
||||
GROUP_CONCAT(srm.menu_id) AS menu_list
|
||||
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
|
||||
LEFT JOIN sys_role_menu srm ON srm.role_id = r.role_id
|
||||
where r.del_flag = 0
|
||||
<if test="roleLevel != null and roleLevel != 0">
|
||||
AND r.role_level < #{role_level}
|
||||
</if>
|
||||
GROUP BY r.role_id
|
||||
order by r.role_sort
|
||||
</select>
|
||||
|
||||
<select id="selectAllocatableRole" resultMap="SysRoleResult">
|
||||
SELECT
|
||||
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.site_access,
|
||||
r.role_level,
|
||||
GROUP_CONCAT(srm.menu_id) AS menu_list
|
||||
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
|
||||
LEFT JOIN sys_role_menu srm ON srm.role_id = r.role_id
|
||||
where r.del_flag = 0
|
||||
<if test="roleLevel != null and roleLevel != 0">
|
||||
AND r.role_level < #{role_level}
|
||||
</if>
|
||||
GROUP BY r.role_id
|
||||
order by r.role_sort
|
||||
</select>
|
||||
@@ -157,6 +191,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="siteAccess != null and siteAccess != ''">site_access,</if>
|
||||
<if test="roleLevel != null and roleLevel != ''">role_level,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
create_time
|
||||
)values(
|
||||
@@ -170,6 +205,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="siteAccess != null and siteAccess != ''">#{siteAccess},</if>
|
||||
<if test="roleLevel != null and roleLevel != ''">#{roleLevel},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate()
|
||||
)
|
||||
@@ -187,6 +223,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="siteAccess != null">site_access = #{siteAccess},</if>
|
||||
<if test="roleLevel != null">role_level = #{roleLevel},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
|
||||
Reference in New Issue
Block a user