|
@@ -2,7 +2,10 @@ package com.mokamrp.privates.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.mokamrp.privates.constant.Constants;
|
|
import com.mokamrp.privates.constant.Constants;
|
|
|
|
|
+import com.mokamrp.privates.constant.HttpStatus;
|
|
|
import com.mokamrp.privates.entity.SetUserCorpsHandle;
|
|
import com.mokamrp.privates.entity.SetUserCorpsHandle;
|
|
|
|
|
+import com.mokamrp.privates.entity.UnSetGroupCorpHandle;
|
|
|
|
|
+import com.mokamrp.privates.entity.UnSetUserCorpHandle;
|
|
|
import com.mokamrp.privates.help.AjaxResult;
|
|
import com.mokamrp.privates.help.AjaxResult;
|
|
|
import com.mokamrp.privates.interceptor.AuthUser;
|
|
import com.mokamrp.privates.interceptor.AuthUser;
|
|
|
import com.mokamrp.privates.mapper.pojo.Corp;
|
|
import com.mokamrp.privates.mapper.pojo.Corp;
|
|
@@ -10,6 +13,7 @@ import com.mokamrp.privates.mapper.pojo.User;
|
|
|
import com.mokamrp.privates.mapper.pojo.UserCorp;
|
|
import com.mokamrp.privates.mapper.pojo.UserCorp;
|
|
|
import com.mokamrp.privates.service.UserCorpService;
|
|
import com.mokamrp.privates.service.UserCorpService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.validation.BindingResult;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
@@ -32,54 +36,71 @@ public class UserCorpController {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取当前登录用户管辖的企业列表
|
|
* 获取当前登录用户管辖的企业列表
|
|
|
|
|
+ *
|
|
|
* @param authUser
|
|
* @param authUser
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
@GetMapping("/getAuthUserCorps")
|
|
@GetMapping("/getAuthUserCorps")
|
|
|
- public Object getAuthUserCorps(@AuthUser User authUser){
|
|
|
|
|
|
|
+ public Object getAuthUserCorps(@AuthUser User authUser) {
|
|
|
|
|
|
|
|
List<Corp> res = userCorpService.getCorpsByUserId(authUser.getId());
|
|
List<Corp> res = userCorpService.getCorpsByUserId(authUser.getId());
|
|
|
- return AjaxResult.success(Constants.SUCCESS,res);
|
|
|
|
|
|
|
+ return AjaxResult.success(Constants.SUCCESS, res);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 通过用户ID查询管辖的企业列表
|
|
* 通过用户ID查询管辖的企业列表
|
|
|
|
|
+ *
|
|
|
* @param authUser
|
|
* @param authUser
|
|
|
* @param userId
|
|
* @param userId
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
@GetMapping("/getCorpsByUserId")
|
|
@GetMapping("/getCorpsByUserId")
|
|
|
- public Object getCorpsByUserId(@AuthUser User authUser,@RequestParam(name = "userId") Integer userId){
|
|
|
|
|
- if(authUser.getIsSuperAdmin() == 1){
|
|
|
|
|
|
|
+ public Object getCorpsByUserId(@AuthUser User authUser, @RequestParam(name = "userId") Integer userId) {
|
|
|
|
|
+ if (authUser.getIsSuperAdmin() == 1) {
|
|
|
List<Corp> res = userCorpService.getCorpsByUserId(userId);
|
|
List<Corp> res = userCorpService.getCorpsByUserId(userId);
|
|
|
return AjaxResult.success(res);
|
|
return AjaxResult.success(res);
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
return AjaxResult.error("Permission denied");
|
|
return AjaxResult.error("Permission denied");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 绑定用户企业信息
|
|
* 绑定用户企业信息
|
|
|
|
|
+ *
|
|
|
* @param setUserCorpsHandle
|
|
* @param setUserCorpsHandle
|
|
|
* @param authUser
|
|
* @param authUser
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
@PostMapping("/setUserCorpsByUserId")
|
|
@PostMapping("/setUserCorpsByUserId")
|
|
|
- public Object setUserCorpsByUserId(@Valid @RequestBody SetUserCorpsHandle setUserCorpsHandle, @AuthUser User authUser){
|
|
|
|
|
- if (authUser.getIsSuperAdmin() == 1){
|
|
|
|
|
|
|
+ public Object setUserCorpsByUserId(@Valid @RequestBody SetUserCorpsHandle setUserCorpsHandle, @AuthUser User authUser) {
|
|
|
|
|
+ if (authUser.getIsSuperAdmin() == 1) {
|
|
|
userCorpService.setUserCorpsByUserId(setUserCorpsHandle.getUserIds(), setUserCorpsHandle.getCorpIds());
|
|
userCorpService.setUserCorpsByUserId(setUserCorpsHandle.getUserIds(), setUserCorpsHandle.getCorpIds());
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return AjaxResult.error("Permission denied");
|
|
|
|
|
+ }
|
|
|
|
|
+ return AjaxResult.success(Constants.SUCCESS);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/unSetUserCorp")
|
|
|
|
|
+ public Object unSetUserCorp(@Valid @RequestBody UnSetUserCorpHandle unSetUserCorpHandle, @AuthUser User authUser, BindingResult bindingResult) {
|
|
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
|
|
+ return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (authUser.getIsSuperAdmin() == 1) {
|
|
|
|
|
+ Boolean res = userCorpService.unSetUserCorp(unSetUserCorpHandle.getUserId(),unSetUserCorpHandle.getCorpId());
|
|
|
|
|
+ } else {
|
|
|
return AjaxResult.error("Permission denied");
|
|
return AjaxResult.error("Permission denied");
|
|
|
}
|
|
}
|
|
|
return AjaxResult.success(Constants.SUCCESS);
|
|
return AjaxResult.success(Constants.SUCCESS);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("/getUserCorpsByUserId")
|
|
@GetMapping("/getUserCorpsByUserId")
|
|
|
- public Object getUserCorpsByUserId(@RequestParam(name = "userId") String UserId){
|
|
|
|
|
- if (UserId == null || UserId.isEmpty()){
|
|
|
|
|
|
|
+ public Object getUserCorpsByUserId(@RequestParam(name = "userId") String UserId) {
|
|
|
|
|
+ if (UserId == null || UserId.isEmpty()) {
|
|
|
return AjaxResult.error("userId null");
|
|
return AjaxResult.error("userId null");
|
|
|
}
|
|
}
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|