1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- package com.wtkj.controller;
- import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
- import com.wtkj.entity.AuthUserInfo;
- import com.wtkj.entity.DeptToDept;
- import com.wtkj.service.IDeptToDeptService;
- import com.wtkj.wrapper.UserListWrapper;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import lombok.AllArgsConstructor;
- import org.springblade.core.tool.api.R;
- import org.springblade.system.entity.Dept;
- import org.springblade.system.feign.ISysClient;
- import org.springblade.system.user.entity.User;
- import org.springblade.system.user.feign.IUserClient;
- import org.springframework.util.CollectionUtils;
- import org.springframework.web.bind.annotation.*;
- import javax.validation.Valid;
- import java.util.ArrayList;
- import java.util.List;
- /**
- * @author Blizzard
- * @create at 2023-09-14 11:13
- * @describe
- */
- @RestController
- @AllArgsConstructor
- @RequestMapping("/common")
- @Api(value = "公共模块", tags = "公共模块")
- public class CommonController {
- private final IDeptToDeptService deptToDeptService;
- private final ISysClient sysClient;
- private final IUserClient userClient;
- /**
- * 当前登录用户信息
- */
- @GetMapping("/user-info")
- @ApiOperation(value = "当前登录用户信息", notes = "")
- @ApiOperationSupport(order = 1)
- public R<AuthUserInfo> userInfo() {
- return R.data(deptToDeptService.userInfo());
- }
- /**
- * 新建机构
- */
- @PostMapping("/sava-dept")
- @ApiOperation(value = "新建政府机构", notes = "传入DeptToDept")
- @ApiOperationSupport(order = 2)
- public R<Boolean> createDept(@RequestBody @Valid DeptToDept dept) {
- return R.status(deptToDeptService.saveOrUpdate(dept));
- }
- /**
- * 机构搜索
- */
- @GetMapping("/get-dept")
- @ApiOperation(value = "搜索机构", notes = "")
- @ApiOperationSupport(order = 3)
- public R<List<Dept>> list(Long topDept, String areaCode, String name, Integer category) {
- return R.data(deptToDeptService.getDept(topDept, areaCode, name, category));
- }
- /**
- * 本机构下的机构
- */
- @GetMapping("/dept-by-parentId")
- @ApiOperation(value = "机构下的子机构", notes = "传入上级机构id")
- @ApiOperationSupport(order = 4)
- public R<List<Dept>> deptList(@RequestParam Long parentId) {
- List<Dept> result = new ArrayList<>();
- R<List<Dept>> rpc = sysClient.getDeptChildByParentId(parentId);
- if (rpc.isSuccess() && !CollectionUtils.isEmpty(rpc.getData())) {
- result.addAll(rpc.getData());
- }
- return R.data(result);
- }
- /**
- * 机构下的人
- */
- @GetMapping("/get-user-list")
- @ApiOperationSupport(order = 5)
- @ApiOperation(value = "机构下用户列表", notes = "")
- public R getUserList(@RequestParam Long deptId, String name) {
- List<User> list = new ArrayList<>();
- R<List<User>> rpc = userClient.getDeptUserList(deptId, name);
- if (rpc.isSuccess()) {
- list = rpc.getData();
- }
- return R.data(UserListWrapper.build().listVO(list));
- }
- }
|