管理企业
parent
24c219c145
commit
2b392ec1d1
|
@ -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);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册用户信息
|
||||
*/
|
||||
|
|
|
@ -63,7 +63,6 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|||
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
|
||||
return buildDeptTreeSelect(depts);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建前端所需要树结构
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue