This commit is contained in:
xiangwb
2017-11-15 15:33:31 +08:00
parent 2e236d25b4
commit 57fd86750b
6 changed files with 24 additions and 19 deletions
@@ -65,5 +65,5 @@ public class SysUser extends BaseEntity {
private transient String modified;
private transient String sexName;
private transient List<SysAuthority> menuArray;
private transient List<SysAuthority> otherArray;
private transient List<SysAuthority> buttonArray;
}
@@ -137,8 +137,6 @@ public class SysAuthorityService {
* @return
*/
public List<SysAuthority> listByParentEnable(String parentId, String enable) {
if (StringUtils.isEmpty(parentId))
parentId = CommonConstant.ROOT;
if (StringUtils.isNotEmpty(enable))
return sysAuthorityRepository.getByParentIdAndEnable(parentId, enable);
else
@@ -155,7 +153,7 @@ public class SysAuthorityService {
public List<SysAuthority> listByRoleIdEnable(String roleId, String enable) {
List<SysAuthority> list = new ArrayList<>();
List<SysRoleAuthority> roleAuthorities = sysRoleAuthorityService.listByRoleId(roleId);
if (CollectionUtils.isNotEmpty(roleAuthorities))
if (CollectionUtils.isEmpty(roleAuthorities))
return list;
List<String> authorityIds = roleAuthorities.stream().map(SysRoleAuthority::getAuthorityId).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(authorityIds))
@@ -51,7 +51,8 @@ public class SysUserService {
if (old != null) {
throw new BusinessException("已经存在此用户名");
}
sysUser.setId(PassWordUtil.createId());
String id=PassWordUtil.createId();
sysUser.setId(id);
sysUser.setCreateTime(new Date());
// 获取初始密码
String[] res = PassWordUtil.getUserSecret(null, null);
@@ -70,6 +71,7 @@ public class SysUserService {
throw new BusinessException("发送密码邮件错误");
}
result.setSuccess(true);
result.setId(id);
return result;
}
@@ -131,6 +133,7 @@ public class SysUserService {
SysUser one = sysUserRepository.save(old);
if (one != null) {
result.setMessage("更新成功");
result.setId(sysUser.getId());
result.setSuccess(true);
} else {
result.setMessage("更新失败");
@@ -10,6 +10,7 @@ import com.xwbing.service.SysAuthorityService;
import com.xwbing.util.JSONObjResult;
import com.xwbing.util.RestMessage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
@@ -71,6 +72,7 @@ public class SysAuthorityControl {
@LogInfo("根据父节点查询子节点(非递归)")
@GetMapping("listByParentId")
@ApiImplicitParam(name = "parentId", value = "父id,可为空", paramType = "query", dataType = "string")
public JSONObject listByParentId(String parentId) {
if (StringUtils.isEmpty(parentId))
parentId = CommonConstant.ROOT;
@@ -81,16 +83,16 @@ public class SysAuthorityControl {
}
@LogInfo("根据是否启用查询所有权限")
@GetMapping("listAuthorityByEnable")
public JSONObject listAuthorityByEnable(String enable) {
// if (StringUtils.isEmpty(enable))
// return JSONObjResult.toJSONObj("是否启用不能为空");
@GetMapping("listByEnable")
@ApiImplicitParam(name = "enable", value = "是否启用,格式Y|N", paramType = "query", dataType = "string")
public JSONObject listByEnable(String enable) {
List<SysAuthority> authoritys = sysAuthorityService.listByEnable(enable);
return JSONObjResult.toJSONObj(authoritys, true, "");
}
@LogInfo("递归查询所有权限")
@GetMapping("queryTree")
@ApiImplicitParam(name = "enable", value = "是否启用,格式Y|N", paramType = "query", dataType = "string")
public JSONObject queryTree(String enable) {
List<SysAuthVo> authoritys = sysAuthorityService.queryAllChildren(CommonConstant.ROOT, enable);
return JSONObjResult.toJSONObj(authoritys, true, "");
@@ -11,6 +11,7 @@ import com.xwbing.service.SysRoleService;
import com.xwbing.util.JSONObjResult;
import com.xwbing.util.RestMessage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
@@ -73,6 +74,7 @@ public class SysRoleControl {
@LogInfo("根据角色主键查找权限")
@PostMapping("listAuthorityByRoleId")
@ApiImplicitParam(name = "enable", value = "是否启用,格式Y|N", paramType = "query",dataType = "string")
public JSONObject listAuthorityByRoleId(@RequestParam String roleId, String enable) {
if (StringUtils.isEmpty(roleId))
return JSONObjResult.toJSONObj("角色主键不能为空");
@@ -106,10 +108,9 @@ public class SysRoleControl {
}
@LogInfo("根据是否启用查询所有角色")
@GetMapping("listAllByEnable")
public JSONObject listAllByEnable(String enable) {
// if (StringUtils.isEmpty(enable))
// return JSONObjResult.toJSONObj("是否启用不能为空");
@GetMapping("listByEnable")
@ApiImplicitParam(name = "enable", value = "是否启用,格式Y|N", paramType = "query",dataType = "string")
public JSONObject listByEnable(String enable) {
List<SysRole> sysRoles = sysRoleService.listAllByEnable(enable);
return JSONObjResult.toJSONObj(sysRoles, true, "");
}
@@ -16,6 +16,7 @@ import com.xwbing.util.CommonDataUtil;
import com.xwbing.util.JSONObjResult;
import com.xwbing.util.RestMessage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
@@ -136,7 +137,7 @@ public class SysUserControl {
SysUser sysUser = sysUserService.getOne((String) CommonDataUtil.getToken(CommonConstant.CURRENT_USER_ID));
if (sysUser == null)
return JSONObjResult.toJSONObj("未获取到当前登录用户信息");
List<SysAuthority> other = new ArrayList<>();
List<SysAuthority> button = new ArrayList<>();
List<SysAuthority> menu = new ArrayList<>();
List<SysAuthority> list;
if (CommonEnum.YesOrNoEnum.YES.getCode().equalsIgnoreCase(sysUser.getAdmin()))
@@ -148,11 +149,11 @@ public class SysUserControl {
if (sysAuthority.getType() == CommonEnum.MenuOrButtonEnum.MENU.getCode())
menu.add(sysAuthority);
else
other.add(sysAuthority);
button.add(sysAuthority);
}
}
sysUser.setMenuArray(menu);
sysUser.setOtherArray(other);
sysUser.setButtonArray(button);
return JSONObjResult.toJSONObj(sysUser, true, "");
}
@@ -184,17 +185,17 @@ public class SysUserControl {
@LogInfo("根据用户主键查找所拥有的角色")
@PostMapping("listRoleByUserId")
public JSONObject listRoleByUserId(@RequestParam String userId,String enable) {
@ApiImplicitParam(name = "enable", value = "是否启用,格式Y|N", paramType = "query",dataType = "string")
public JSONObject listRoleByUserId(@RequestParam String userId, String enable) {
if (StringUtils.isEmpty(userId))
return JSONObjResult.toJSONObj("用户主键不能为空");
// if (StringUtils.isEmpty(enable))
// return JSONObjResult.toJSONObj("是否启用不能为空");
List<SysRole> list = sysRoleService.listByUserIdEnable(userId, enable);
return JSONObjResult.toJSONObj(list, true, "");
}
@LogInfo("根据用户主键查找所拥有的权限")
@PostMapping("listAuthorityByUserId")
@ApiImplicitParam(name = "enable", value = "是否启用,格式Y|N", paramType = "query",dataType = "string")
public JSONObject listAuthorityByUserId(@RequestParam String userId,String enable) {
if (StringUtils.isEmpty(userId))
return JSONObjResult.toJSONObj("用户主键不能为空");