管理企业

server_five_liuyunhu
ffr 2024-03-31 10:17:59 +08:00
parent 24c219c145
commit 2b392ec1d1
9 changed files with 208 additions and 25 deletions

View File

@ -2,17 +2,11 @@ package com.couplet.common.system.remote;
import com.couplet.common.core.constant.ServiceNameConstants;
import com.couplet.common.core.domain.Result;
import com.couplet.common.core.web.page.TableDataInfo;
import com.couplet.common.system.domain.SysDept;
import com.couplet.common.system.domain.SysUser;
import com.couplet.common.system.remote.factory.RemoteDeptFallbackFactory;
import lombok.extern.java.Log;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -34,6 +28,7 @@ public interface RemoteDeptService {
/**
* ID
*
* @param deptId ID
* @return
*/
@ -41,6 +36,62 @@ public interface RemoteDeptService {
public Result<List<SysDept>> getSysDeptByDeptId(@PathVariable(value = "deptId") Long deptId);
/*
* @param dept:
* @return Result
* @author
* @description
* @date
*/
@PostMapping
public Result add (@Validated @RequestBody SysDept dept);
/*
* @param dept:
* @return null
* @author
* @description
* @date
*/
@PutMapping
public Result edit (@Validated @RequestBody SysDept dept);
/*
* @param null:
* @return null
* @author
* @description
* @date
*/
@DeleteMapping("/{deptId}")
public Result remove (@PathVariable(value = "deptId") Long deptId);
/*
* @param deptId:
* @return Result
* @author
* @description deptId
* @date
*/
@GetMapping(value = "/{deptId}")
public Result getInfo (@PathVariable(value = "deptId") Long deptId);
/*
* @param deptId:
* @return Result
* @author
* @description
* @date
*/
@GetMapping("/list/exclude/{deptId}")
public Result excludeChild (@PathVariable(value = "deptId") Long deptId);
}

View File

@ -24,6 +24,7 @@ public interface RemoteUserService {
*
* @return
*/
@GetMapping("/user/info/{username}")
public Result<LoginUser> getUserInfo (@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

View File

@ -1,9 +1,7 @@
package com.couplet.common.system.remote.factory;
import com.couplet.common.core.domain.Result;
import com.couplet.common.core.web.page.TableDataInfo;
import com.couplet.common.system.domain.SysDept;
import com.couplet.common.system.domain.SysUser;
import com.couplet.common.system.remote.RemoteDeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
@ -30,22 +28,79 @@ public class RemoteDeptFallbackFactory implements FallbackFactory<RemoteDeptServ
return null;
}
/**
* ID
*
* @param deptId ID
*
* @return
*/
@Override
public Result<List<SysDept>> getSysDeptByDeptId(Long deptId) {
return Result.error("调用失败...."+cause.getMessage());
}
/*
* @param cause:
* @return RemoteDeptService
* @author
* @description
* @date
*/
@Override
public Result add(SysDept dept) {
return Result.error("调用失败...."+cause.getMessage());
}
/*
* @param dept:
* @return Result
* @author
* @description
* @date
*/
@Override
public Result edit(SysDept dept) {
return Result.error("调用失败..."+cause.getMessage());
}
/*
* @param deptId:
* @return Result
* @author
* @description
* @date
*/
@Override
public Result remove(Long deptId) {
return Result.error("调用失败...."+cause.getMessage());
}
/*
* @param deptId:
* @return Result
* @author
* @description deptId
* @date
*/
@Override
public Result getInfo(Long deptId) {
return Result.error("调用失败....."+cause.getMessage());
}
/*
* @param deptId:
* @return Result
* @author
* @description
* @date
*/
@Override
public Result excludeChild(Long deptId) {
return Result.error("调用失败...."+cause.getMessage());
}
};
}

View File

@ -1,6 +1,9 @@
package com.couplet.server.controller;
import com.couplet.common.core.domain.Result;
import com.couplet.common.log.annotation.Log;
import com.couplet.common.log.enums.BusinessType;
import com.couplet.common.security.annotation.RequiresPermissions;
import com.couplet.common.system.domain.SysDept;
import com.couplet.server.service.ManageServer;
import org.springframework.beans.factory.annotation.Autowired;
@ -25,9 +28,10 @@ public class ManageController {
* @description
* @date
*/
@PostMapping("manageList")
public Result manageList(@RequestBody SysDept sysDept) {
List<SysDept> sysDepts = manageServer.selectDeptList(sysDept);
@GetMapping("manageList")
@RequiresPermissions("system:dept:list")
public Result<List<SysDept>> manageList() {
List<SysDept> sysDepts = manageServer.selectDeptList();
return Result.success(sysDepts);
}
@ -39,13 +43,51 @@ public class ManageController {
* @description
* @date
*/
@PostMapping("manageInsert")
@RequiresPermissions("system:dept:add")
@Log(title = "部门管理", businessType = BusinessType.INSERT)
@PostMapping
public Result manageInsert(@RequestBody SysDept sysDept) {
return manageServer.insertDept(sysDept);
}
@RequiresPermissions("system:dept:edit")
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
@PutMapping
public Result manageEdit(@RequestBody SysDept sysDept) {
return manageServer.manageEdit(sysDept);
}
@RequiresPermissions("system:dept:remove")
@Log(title = "部门管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{deptId}")
public Result manageRemove(@PathVariable Long deptId){
return manageServer.manageRemove(deptId);
}
// @GetMapping("/getSysDeptByDeptId/{deptId}")
// public Result<List<SysDept>> getSysDeptByDeptId(@PathVariable(value = "deptId") Long deptId) {
// return manageServer.getSysDeptByDeptId(deptId);
// }
@RequiresPermissions("system:dept:query")
@GetMapping(value = "/{deptId}")
public Result getInfo(@PathVariable Long deptId) {
return manageServer.getInfo(deptId);
}
@RequiresPermissions("system:dept:list")
@GetMapping("/list/exclude/{deptId}")
public Result excludeChild(@PathVariable(value = "deptId") Long deptId) {
return manageServer.excludeChild(deptId);
}
}

View File

@ -9,7 +9,15 @@ import java.util.List;
public interface ManageServer {
List<SysDept> selectDeptList(SysDept sysDept);
List<SysDept> selectDeptList();
Result insertDept(SysDept sysDept);
Result manageEdit(SysDept sysDept);
Result manageRemove(Long deptId);
Result getInfo(Long deptId);
Result excludeChild(Long deptId);
}

View File

@ -28,16 +28,45 @@ public class ManageServiceImpl implements ManageServer{
private RemoteDeptService remoteDeptService;
@Autowired
private RemoteUserService remoteUserService;
@Override
public List<SysDept> selectDeptList(SysDept sysDept) {
Result<LoginUser> userInfo = remoteUserService.getUserInfo(SecurityUtils.getUsername(), SecurityConstants.FROM_SOURCE);
LoginUser loginUser = userInfo.getData();
Long deptId = loginUser.getDeptId();
return remoteDeptService.getSysDeptByDeptId(deptId).getData();
public List<SysDept> selectDeptList() {
LoginUser loginUser = SecurityUtils.getLoginUser();
String username = loginUser.getUsername();
Result<LoginUser> userInfo = remoteUserService.getUserInfo(username, SecurityConstants.FROM_SOURCE);
LoginUser user = userInfo.getData();
Long deptId = user.getDeptId();
Result<List<SysDept>> sysDeptByDeptId = remoteDeptService.getSysDeptByDeptId(deptId);
List<SysDept> dept = sysDeptByDeptId.getData();
return dept;
}
@Override
public Result insertDept(SysDept sysDept) {
return remoteDeptService.add(sysDept);
}
@Override
public Result manageEdit(SysDept sysDept) {
return remoteDeptService.edit(sysDept);
}
@Override
public Result manageRemove(Long deptId) {
return remoteDeptService.remove(deptId);
}
@Override
public Result getInfo(Long deptId) {
return remoteDeptService.getInfo(deptId);
}
@Override
public Result excludeChild(Long deptId) {
return remoteDeptService.excludeChild(deptId);
}
}

View File

@ -11,6 +11,7 @@ import com.couplet.common.security.utils.SecurityUtils;
import com.couplet.common.system.domain.SysDept;
import com.couplet.system.service.SysDeptService;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.math3.analysis.solvers.BrentSolver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -114,7 +115,6 @@ public class SysDeptController extends BaseController {
* @return
*/
@GetMapping("/getSysDeptByDeptId/{deptId}")
public Result<List<SysDept>> getSysDeptByDeptId(@PathVariable(value = "deptId") Long deptId){
List<SysDept> sysDept = deptService.getSysDeptByDeptId(deptId);
Result<List<SysDept>> success = Result.success(sysDept);

View File

@ -96,7 +96,6 @@ public class SysUserController extends BaseController {
/**
*
*/
@InnerAuth
@GetMapping("/info/{username}")
public Result<LoginUser> info (@PathVariable("username") String username) {
SysUser sysUser = userService.selectUserByUserName(username);
@ -116,7 +115,6 @@ public class SysUserController extends BaseController {
sysUserVo.setDeptId(deptId);
return Result.success(sysUserVo);
}
/**
*
*/

View File

@ -63,7 +63,6 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
return buildDeptTreeSelect(depts);
}
/**
*
*