Commit 597cce4f authored by 赵啸非's avatar 赵啸非

修改部分权限

parent 694557ea
/**
* 文件:ResourceController.java
* 版本:1.0.0
* 日期:
* Copyright ®
* All right reserved.
*/
package com.mortals.xhx.base.system.resource.web; package com.mortals.xhx.base.system.resource.web;
import java.util.HashMap; import com.alibaba.fastjson.JSONObject;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.common.IBaseEnum; import com.mortals.framework.common.IBaseEnum;
import com.mortals.framework.common.code.UserType; import com.mortals.framework.common.code.UserType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.resource.model.ResourceEntity; import com.mortals.xhx.base.system.resource.model.ResourceEntity;
import com.mortals.xhx.base.system.resource.service.ResourceService; import com.mortals.xhx.base.system.resource.service.ResourceService;
import com.mortals.xhx.common.code.AuthType; import com.mortals.xhx.common.code.AuthType;
import com.mortals.xhx.common.code.SourceType; import com.mortals.xhx.common.code.SourceType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
/** /**
* <p>Title: 资源信息</p> * 资源信息
* <p>Description: ResourceController </p> *
* <p>Copyright: Copyright &reg; </p> * @author: zxfei
* <p>Company: </p> * @date: 2022/5/7 15:27
* @author
* @version 1.0.0
*/ */
@Slf4j
@RestController @RestController
@RequestMapping("resource") @RequestMapping("resource")
public class ResourceController extends BaseCRUDJsonMappingController<ResourceService,ResourceForm,ResourceEntity,Long> { public class ResourceController extends BaseCRUDJsonBodyMappingController<ResourceService,ResourceEntity,Long> {
public ResourceController(){ public ResourceController(){
super.setFormClass(ResourceForm.class);
super.setModuleDesc("资源信息"); super.setModuleDesc("资源信息");
} }
@Override @Override
protected void init(HttpServletRequest request, HttpServletResponse response, ResourceForm form, protected void init(Map<String, Object> model, Context context) {
Map<String, Object> model, Context context) {
Map<String, Object> statsus = new HashMap<String, Object>(); Map<String, Object> statsus = new HashMap<String, Object>();
statsus.put("authType", AuthType.getEnumMap()); statsus.put("authType", AuthType.getEnumMap());
statsus.put("sourceType", SourceType.getEnumMap()); statsus.put("sourceType", SourceType.getEnumMap());
...@@ -57,7 +44,6 @@ public class ResourceController extends BaseCRUDJsonMappingController<ResourceSe ...@@ -57,7 +44,6 @@ public class ResourceController extends BaseCRUDJsonMappingController<ResourceSe
statsus.put("userType", UserType.findByValue(getCurUser().getUserType())); statsus.put("userType", UserType.findByValue(getCurUser().getUserType()));
} }
model.put(KEY_RESULT_DICT, statsus); model.put(KEY_RESULT_DICT, statsus);
super.init(request, response, form, model, context);
} }
/** /**
......
/**
* 文件:RoleAuthController.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.role.web; package com.mortals.xhx.base.system.role.web;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.role.model.RoleAuthEntity;
import com.mortals.xhx.base.system.role.model.RoleAuthQuery;
import com.mortals.xhx.base.system.role.service.RoleAuthService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.mortals.framework.web.BaseCRUDJsonMappingController;
import com.mortals.xhx.base.system.role.model.RoleAuthEntity;
import com.mortals.xhx.base.system.role.service.RoleAuthService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/** /**
* <p>Title: 角色资源权限</p> * 角色资源权限
* <p>Description: RoleAuthController </p> *
* <p>Copyright: Copyright &reg; </p> * @author: zxfei
* <p>Company: </p> * @date: 2022/5/7 15:19
* @author
* @version 1.0.0
*/ */
@Slf4j
@RestController @RestController
@RequestMapping("role/auth") @RequestMapping("role/auth")
public class RoleAuthController extends BaseCRUDJsonMappingController<RoleAuthService,RoleAuthForm,RoleAuthEntity,Long> { public class RoleAuthController extends BaseCRUDJsonBodyMappingController<RoleAuthService, RoleAuthEntity, Long> {
public RoleAuthController(){ public RoleAuthController() {
super.setFormClass(RoleAuthForm.class);
super.setModuleDesc("角色资源权限"); super.setModuleDesc("角色资源权限");
} }
...@@ -41,9 +31,9 @@ public class RoleAuthController extends BaseCRUDJsonMappingController<RoleAuthSe ...@@ -41,9 +31,9 @@ public class RoleAuthController extends BaseCRUDJsonMappingController<RoleAuthSe
* 分配资源 * 分配资源
*/ */
@PostMapping(value = "distributionSource") @PostMapping(value = "distributionSource")
public String distributionUser(HttpServletRequest request, HttpServletResponse response, RoleAuthForm form) { public String distributionUser(@RequestBody RoleAuthQuery query) {
try { try {
service.doDistributionSource(form.getQuery()); service.doDistributionSource(query);
JSONObject ret = new JSONObject(); JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS); ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
return ret.toJSONString(); return ret.toJSONString();
......
/**
* 文件:RoleController.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.role.web; package com.mortals.xhx.base.system.role.web;
...@@ -12,34 +5,28 @@ import com.alibaba.fastjson.JSONObject; ...@@ -12,34 +5,28 @@ import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.common.IBaseEnum; import com.mortals.framework.common.IBaseEnum;
import com.mortals.framework.common.code.UserType; import com.mortals.framework.common.code.UserType;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mortals.framework.web.BaseCRUDJsonMappingController;
import com.mortals.xhx.base.system.role.model.RoleEntity; import com.mortals.xhx.base.system.role.model.RoleEntity;
import com.mortals.xhx.base.system.role.model.RoleUserEntity; import com.mortals.xhx.base.system.role.model.RoleUserEntity;
import com.mortals.xhx.base.system.role.service.RoleService; import com.mortals.xhx.base.system.role.service.RoleService;
import com.mortals.xhx.base.system.role.service.RoleUserService; import com.mortals.xhx.base.system.role.service.RoleUserService;
import com.mortals.xhx.common.code.RoleType; import com.mortals.xhx.common.code.RoleType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* <p>Title: 角色信息</p> * 角色信息
* <p>Description: RoleController </p> *
* <p>Copyright: Copyright &reg; </p> * @author: zxfei
* <p>Company: </p> * @date: 2022/5/7 15:15
* @author
* @version 1.0.0
*/ */
@RestController @RestController
@RequestMapping("role") @RequestMapping("role")
...@@ -49,23 +36,29 @@ public class RoleController extends BaseCRUDJsonBodyMappingController<RoleServic ...@@ -49,23 +36,29 @@ public class RoleController extends BaseCRUDJsonBodyMappingController<RoleServic
private RoleUserService roleUserService; private RoleUserService roleUserService;
public RoleController(){ public RoleController(){
super.setFormClass(RoleForm.class);
super.setModuleDesc("角色信息"); super.setModuleDesc("角色信息");
} }
@Override @Override
protected void init(Map<String, Object> model, Context context) { protected void init(Map<String, Object> model, Context context) {
this.addDict(model,"userType", IBaseEnum.getEnumMap(UserType.class)); Map<String, Object> status = new HashMap<>();
this.addDict(model,"roleType", RoleType.getEnumMap()); status.put("userType", IBaseEnum.getEnumMap(UserType.class));
super.init(model, context); status.put("roleType", RoleType.getEnumMap());
model.put(KEY_RESULT_DICT, status);
} }
/**
* 根据用户id获取角色名称
* @param userId
* @return
*/
@PostMapping("roleNameByUserId") @PostMapping("roleNameByUserId")
public String getRoleNameByUserId(@RequestBody RoleUserEntity query) { public String getRoleNameByUserId(@RequestParam(value = "userId") Long userId) {
try{ try{
JSONObject ret = new JSONObject(); JSONObject ret = new JSONObject();
RoleUserEntity roleUserEntity = new RoleUserEntity(); RoleUserEntity roleUserEntity = new RoleUserEntity();
roleUserEntity.setUserId(query.getUserId()); roleUserEntity.setUserId(userId);
List<RoleUserEntity> find = roleUserService.find(roleUserEntity, new Context()); List<RoleUserEntity> find = roleUserService.find(roleUserEntity, new Context());
List<RoleEntity> model = new ArrayList<>(); List<RoleEntity> model = new ArrayList<>();
if(find.size() > 0){ if(find.size() > 0){
......
/**
* 文件:RoleUserController.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.role.web; package com.mortals.xhx.base.system.role.web;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -14,23 +7,22 @@ import com.mortals.framework.ap.SysConstains; ...@@ -14,23 +7,22 @@ import com.mortals.framework.ap.SysConstains;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.BaseEntityLong; import com.mortals.framework.model.BaseEntityLong;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import org.apache.commons.beanutils.MethodUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mortals.framework.web.BaseCRUDJsonMappingController;
import com.mortals.xhx.base.system.role.model.RoleEntity; import com.mortals.xhx.base.system.role.model.RoleEntity;
import com.mortals.xhx.base.system.role.model.RoleUserEntity; import com.mortals.xhx.base.system.role.model.RoleUserEntity;
import com.mortals.xhx.base.system.role.model.RoleUserQuery;
import com.mortals.xhx.base.system.role.service.RoleService; import com.mortals.xhx.base.system.role.service.RoleService;
import com.mortals.xhx.base.system.role.service.RoleUserService; import com.mortals.xhx.base.system.role.service.RoleUserService;
import com.mortals.xhx.base.system.user.model.UserEntity; import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.model.UserQuery; import com.mortals.xhx.base.system.user.model.UserQuery;
import com.mortals.xhx.base.system.user.service.UserService; import com.mortals.xhx.base.system.user.service.UserService;
import org.apache.commons.beanutils.MethodUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -38,29 +30,49 @@ import java.util.Set; ...@@ -38,29 +30,49 @@ import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* <p>Title: 角色用户</p> * 角色用户
* <p>Description: RoleUserController </p> *
* <p>Copyright: Copyright &reg; </p> * @author: zxfei
* <p>Company: </p> * @date: 2022/5/7 15:15
* @author
* @version 1.0.0
*/ */
@RestController @RestController
@RequestMapping("role/user") @RequestMapping("role/user")
public class RoleUserController extends BaseCRUDJsonMappingController<RoleUserService,RoleUserForm,RoleUserEntity,Long> { public class RoleUserController extends BaseCRUDJsonBodyMappingController<RoleUserService, RoleUserEntity, Long> {
@Autowired @Autowired
private RoleService roleService; private RoleService roleService;
@Autowired @Autowired
private UserService userService; private UserService userService;
public RoleUserController(){ public RoleUserController() {
super.setFormClass(RoleUserForm.class);
super.setModuleDesc("角色用户"); super.setModuleDesc("角色用户");
} }
@Override
protected void init(Map<String, Object> model, Context context) {
Map<String, Object> status = new HashMap<>(3);
status.put("roleId", roleService.find(new RoleEntity(), null).stream()
.collect(Collectors.toMap(e -> e.getId().toString(), RoleEntity::getName)));
List<RoleUserEntity> roleUserList = (List<RoleUserEntity>) model.get(SysConstains.RESULT_KEY);
if (roleUserList != null && roleUserList.size() > 0) {
List<Long> userIdsList = roleUserList.stream().map(RoleUserEntity::getUserId).collect(Collectors.toList());
List<UserEntity> userEntityList = userService.find(getQuery(UserQuery.class,
Sets.newHashSet("id", "realName", "loginName"), userIdsList.toArray(new Long[userIdsList.size()])), null);
if (userEntityList != null) {
status.put("userReNameMap",
userEntityList.stream().collect(Collectors.toMap(e -> e.getId().toString(), UserEntity::getRealName)));
status.put("userId",
userEntityList.stream().collect(Collectors.toMap(e -> e.getId().toString(), UserEntity::getLoginName)));
}
}
model.put(KEY_RESULT_DICT, status);
}
/** /**
* 获取查询对象,限制查询返回的结果只包含ID和名称 * 获取查询对象,限制查询返回的结果只包含ID和名称
*
* @param IdList * @param IdList
* @return * @return
*/ */
...@@ -79,36 +91,13 @@ public class RoleUserController extends BaseCRUDJsonMappingController<RoleUserSe ...@@ -79,36 +91,13 @@ public class RoleUserController extends BaseCRUDJsonMappingController<RoleUserSe
} }
} }
@SuppressWarnings("unchecked")
@Override
protected void init(HttpServletRequest request, HttpServletResponse response, RoleUserForm form, Map<String, Object> model, Context context) {
Map<String, Object> status = new HashMap<>(3);
status.put("roleId", roleService.find(new RoleEntity(), null).stream()
.collect(Collectors.toMap(e -> e.getId().toString(), RoleEntity::getName)));
List<RoleUserEntity> roleUserList = (List<RoleUserEntity>) model.get(SysConstains.RESULT_KEY);
if(roleUserList!=null && roleUserList.size()>0) {
List<Long> userIdsList = roleUserList.stream().map(RoleUserEntity::getUserId).collect(Collectors.toList());
List<UserEntity> userEntityList = userService.find(getQuery(UserQuery.class,
Sets.newHashSet("id", "realName","loginName"), userIdsList.toArray(new Long[userIdsList.size()])), null);
if(userEntityList!=null) {
status.put("userReNameMap",
userEntityList.stream().collect(Collectors.toMap(e -> e.getId().toString(), UserEntity::getRealName)));
status.put("userId",
userEntityList.stream().collect(Collectors.toMap(e -> e.getId().toString(), UserEntity::getLoginName)));
}
}
model.put(KEY_RESULT_DICT, status);
super.init(request, response, form, model, context);
}
/** /**
* 分配用户 * 分配用户
*/ */
@PostMapping(value = "distributionUser") @PostMapping(value = "distributionUser")
public String distributionUser(HttpServletRequest request, HttpServletResponse response, RoleUserForm form) { public String distributionUser(@RequestBody RoleUserQuery query) {
try { try {
service.doDistributionUser(form.getQuery()); service.doDistributionUser(query);
JSONObject ret = new JSONObject(); JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS); ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
return ret.toJSONString(); return ret.toJSONString();
...@@ -125,9 +114,9 @@ public class RoleUserController extends BaseCRUDJsonMappingController<RoleUserSe ...@@ -125,9 +114,9 @@ public class RoleUserController extends BaseCRUDJsonMappingController<RoleUserSe
* 分配角色 * 分配角色
*/ */
@PostMapping(value = "distributionRole") @PostMapping(value = "distributionRole")
public String distributionRole(HttpServletRequest request, HttpServletResponse response, RoleUserForm form) { public String distributionRole(@RequestBody RoleUserQuery query) {
try { try {
service.doDistributionRole(form.getQuery()); service.doDistributionRole(query);
JSONObject ret = new JSONObject(); JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS); ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
return ret.toJSONString(); return ret.toJSONString();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment