|
|
@@ -3,6 +3,7 @@ package com.mokamrp.privates.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
|
import com.mokamrp.privates.constant.Constants;
|
|
|
+import com.mokamrp.privates.entity.SetUserCorpsHandle;
|
|
|
import com.mokamrp.privates.help.AjaxResult;
|
|
|
import com.mokamrp.privates.interceptor.AuthUser;
|
|
|
import com.mokamrp.privates.mapper.pojo.Corp;
|
|
|
@@ -10,10 +11,9 @@ import com.mokamrp.privates.mapper.pojo.User;
|
|
|
import com.mokamrp.privates.mapper.pojo.UserCorp;
|
|
|
import com.mokamrp.privates.service.UserCorpService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -38,14 +38,47 @@ public class UserCorpController {
|
|
|
*/
|
|
|
@GetMapping("/getAuthUserCorps")
|
|
|
public Object getAuthUserCorps(@AuthUser User authUser){
|
|
|
- List<Corp> res = userCorpService.getAuthUserCorps(authUser.getId());
|
|
|
+ List<Corp> res = userCorpService.getCorpsByUserId(authUser.getId());
|
|
|
return AjaxResult.success(Constants.SUCCESS,res);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 通过用户ID查询管辖的企业列表
|
|
|
+ * @param authUser
|
|
|
+ * @param userId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/getCorpsByUserId")
|
|
|
+ public Object getCorpsByUserId(@AuthUser User authUser,@RequestParam(name = "userId") Integer userId){
|
|
|
+ if(authUser.getIsSuperAdmin() == 1){
|
|
|
+ List<Corp> res = userCorpService.getCorpsByUserId(userId);
|
|
|
+ return AjaxResult.success(res);
|
|
|
+ }else{
|
|
|
+ return AjaxResult.error("Permission denied");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 绑定用户企业信息
|
|
|
+ * @param setUserCorpsHandle
|
|
|
+ * @param authUser
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@PostMapping("/setUserCorpsByUserId")
|
|
|
- public Object setUserCorpsByUserId(@AuthUser User authUser){
|
|
|
+ public Object setUserCorpsByUserId(@Valid @RequestBody SetUserCorpsHandle setUserCorpsHandle, @AuthUser User authUser){
|
|
|
if (authUser.getIsSuperAdmin() == 1){
|
|
|
+ userCorpService.setUserCorpsByUserId(setUserCorpsHandle.getUserIds(), setUserCorpsHandle.getCorpIds());
|
|
|
+ }else{
|
|
|
+ return AjaxResult.error("Permission denied");
|
|
|
+ }
|
|
|
+ return AjaxResult.success(Constants.SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+ @GetMapping("/getUserCorpsByUserId")
|
|
|
+ public Object getUserCorpsByUserId(@RequestParam(name = "userId") String UserId){
|
|
|
+ if (UserId == null || UserId.isEmpty()){
|
|
|
+ return AjaxResult.error("userId null");
|
|
|
}
|
|
|
return null;
|
|
|
}
|