Compare commits
3 Commits
b8e3b4dcd1
...
1910013cbb
Author | SHA1 | Date |
---|---|---|
|
1910013cbb | |
|
2b392ec1d1 | |
|
24c219c145 |
|
@ -49,7 +49,7 @@ public class SecurityUtils {
|
|||
* 获取登录企业ID
|
||||
*/
|
||||
public static Long getEnterpriseId(){
|
||||
Long enterpriseId = getLoginUser().getEnterpriseId();
|
||||
Long enterpriseId = getLoginUser().getDeptId();
|
||||
Assert.notNull(enterpriseId, "该用户未绑定负责企业");
|
||||
return enterpriseId;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public class LoginUser implements Serializable {
|
|||
/**
|
||||
* 企业ID
|
||||
*/
|
||||
private Long enterpriseId;
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
|
|
|
@ -2,16 +2,16 @@ 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 org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@FeignClient(contextId = "remoteFileService" ,
|
||||
@FeignClient(contextId = "remoteDeptService" ,
|
||||
value = ServiceNameConstants.SYSTEM_SERVICE,
|
||||
fallbackFactory = RemoteDeptFallbackFactory.class,
|
||||
path = "/dept"
|
||||
|
@ -28,9 +28,70 @@ public interface RemoteDeptService {
|
|||
|
||||
/**
|
||||
* 根据企业ID获取企业下部门
|
||||
* @param enterpriseId 企业ID
|
||||
*
|
||||
* @param deptId 企业ID
|
||||
* @return 企业信息,内含有部门
|
||||
*/
|
||||
@GetMapping("/getSysDeptByEnterpriseId/{enterpriseId}")
|
||||
public Result<SysDept> getSysDeptByEnterpriseId(@PathVariable(value = "enterpriseId") Long enterpriseId);
|
||||
@GetMapping("/getSysDeptByDeptId/{deptId}")
|
||||
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,13 +1,13 @@
|
|||
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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author fufanrui
|
||||
* @version 1.0
|
||||
|
@ -20,24 +20,88 @@ public class RemoteDeptFallbackFactory implements FallbackFactory<RemoteDeptServ
|
|||
@Override
|
||||
public RemoteDeptService create(Throwable cause) {
|
||||
log.error("sys服务调用失败:{}", cause.getMessage());
|
||||
|
||||
return new RemoteDeptService() {
|
||||
|
||||
@Override
|
||||
public Result list(SysDept dept) {
|
||||
return Result.error("调用失败..."+cause.getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据企业ID获取企业下部门
|
||||
*
|
||||
* @param enterpriseId 企业ID
|
||||
*
|
||||
* @param deptId 企业ID
|
||||
* @return 企业信息,内含有部门
|
||||
*/
|
||||
@Override
|
||||
public Result<SysDept> getSysDeptByEnterpriseId (Long enterpriseId) {
|
||||
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,23 +1,92 @@
|
|||
package com.couplet.server.controller;
|
||||
|
||||
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 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;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author fufanrui
|
||||
* @version 1.0
|
||||
* @description: TODO
|
||||
* @date 2024/3/27 15:33
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/manage")
|
||||
public class ManageController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ManageServer manageServer;
|
||||
|
||||
|
||||
/*
|
||||
* @param sysDept:
|
||||
* @return Result
|
||||
* @author 付凡芮
|
||||
* @description 登入后获取到企业下的所有部门
|
||||
* @date
|
||||
*/
|
||||
@GetMapping("manageList")
|
||||
@RequiresPermissions("system:dept:list")
|
||||
public Result<List<SysDept>> manageList() {
|
||||
List<SysDept> sysDepts = manageServer.selectDeptList();
|
||||
return Result.success(sysDepts);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @param sysDept:
|
||||
* @return Result
|
||||
* @author 付凡芮
|
||||
* @description 添加企业中的部门
|
||||
* @date
|
||||
*/
|
||||
@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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,23 @@
|
|||
package com.couplet.server.service;
|
||||
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.system.domain.SysDept;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ManageServer {
|
||||
|
||||
|
||||
List<SysDept> selectDeptList();
|
||||
|
||||
Result insertDept(SysDept sysDept);
|
||||
|
||||
Result manageEdit(SysDept sysDept);
|
||||
|
||||
Result manageRemove(Long deptId);
|
||||
|
||||
Result getInfo(Long deptId);
|
||||
|
||||
Result excludeChild(Long deptId);
|
||||
}
|
||||
|
|
|
@ -1,32 +1,72 @@
|
|||
package com.couplet.server.service.impl;
|
||||
|
||||
import com.couplet.common.core.constant.SecurityConstants;
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.core.utils.StringUtils;
|
||||
import com.couplet.common.security.utils.SecurityUtils;
|
||||
import com.couplet.common.system.domain.LoginUser;
|
||||
import com.couplet.common.system.domain.SysDept;
|
||||
import com.couplet.common.system.remote.RemoteDeptService;
|
||||
import com.couplet.common.system.remote.RemoteUserService;
|
||||
import com.couplet.server.service.ManageServer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author fufanrui
|
||||
* @version 1.0
|
||||
* @description: TODO
|
||||
* @description: 管理企业业务层
|
||||
* @date 2024/3/27 15:34
|
||||
*/
|
||||
@Service
|
||||
public class ManageServiceImpl implements ManageServer {
|
||||
public class ManageServiceImpl implements ManageServer{
|
||||
|
||||
// @Autowired
|
||||
// private RemoteDeptService remoteDeptService;
|
||||
// {
|
||||
// Long enterpriseId = SecurityUtils.getEnterpriseId();
|
||||
// Result<SysDept> sysDeptByEnterpriseId = remoteDeptService.getSysDeptByEnterpriseId(enterpriseId);
|
||||
// if (sysDeptByEnterpriseId.getCode() == 200){
|
||||
// SysDept sysDept = sysDeptByEnterpriseId.getData();
|
||||
// }
|
||||
// }
|
||||
@Autowired
|
||||
private RemoteDeptService remoteDeptService;
|
||||
@Autowired
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
@Override
|
||||
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.*;
|
||||
|
@ -110,12 +111,13 @@ public class SysDeptController extends BaseController {
|
|||
|
||||
/**
|
||||
* 根据企业ID获取企业下部门
|
||||
* @param enterpriseId 企业ID
|
||||
* @param deptId 企业ID
|
||||
* @return 企业信息,内含有部门
|
||||
*/
|
||||
@GetMapping("/getSysDeptByEnterpriseId/{enterpriseId}")
|
||||
public Result<SysDept> getSysDeptByEnterpriseId(@PathVariable(value = "enterpriseId") Long enterpriseId){
|
||||
SysDept sysDept = deptService.getSysDeptByEnterpriseId(enterpriseId);
|
||||
return Result.success(sysDept);
|
||||
@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);
|
||||
return success;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
@ -113,10 +112,9 @@ public class SysUserController extends BaseController {
|
|||
sysUserVo.setSysUser(sysUser);
|
||||
sysUserVo.setRoles(roles);
|
||||
sysUserVo.setPermissions(permissions);
|
||||
sysUserVo.setEnterpriseId(deptId);
|
||||
sysUserVo.setDeptId(deptId);
|
||||
return Result.success(sysUserVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册用户信息
|
||||
*/
|
||||
|
|
|
@ -128,4 +128,9 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteDeptById (Long deptId);
|
||||
|
||||
SysDept selectDeptIdByLeader(String userName);
|
||||
|
||||
List<SysDept> getSysDeptByDeptId(Long deptId);
|
||||
|
||||
}
|
||||
|
|
|
@ -138,15 +138,15 @@ public interface SysDeptService extends IService<SysDept> {
|
|||
|
||||
/**
|
||||
* 通过负责人查询企业ID
|
||||
* @param leader 负责人
|
||||
* @param userName 负责人
|
||||
* @return 企业ID
|
||||
*/
|
||||
Long selectDeptIdByLeader (String leader);
|
||||
Long selectDeptIdByLeader (String userName);
|
||||
|
||||
/**
|
||||
* 根据企业ID获取企业下部门
|
||||
* @param enterpriseId 企业ID
|
||||
* @param deptId 企业ID
|
||||
* @return 企业信息,内含有部门
|
||||
*/
|
||||
SysDept getSysDeptByEnterpriseId (Long enterpriseId);
|
||||
List<SysDept> getSysDeptByDeptId(Long deptId);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.couplet.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.couplet.common.core.constant.UserConstants;
|
||||
import com.couplet.common.core.exception.ServiceException;
|
||||
|
@ -63,7 +63,6 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|||
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
|
||||
return buildDeptTreeSelect(depts);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建前端所需要树结构
|
||||
*
|
||||
|
@ -285,31 +284,33 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|||
/**
|
||||
* 通过负责人查询企业ID
|
||||
*
|
||||
* @param leader 负责人
|
||||
* @param userName 负责人
|
||||
*
|
||||
* @return 企业ID
|
||||
*/
|
||||
@Override
|
||||
public Long selectDeptIdByLeader (String leader) {
|
||||
SysDept sysDept = getOne(new LambdaQueryWrapper<>() {{
|
||||
eq(SysDept::getLeader, leader);
|
||||
}});
|
||||
public Long selectDeptIdByLeader (String userName) {
|
||||
|
||||
SysDept sysDept = deptMapper.selectDeptIdByLeader(userName);
|
||||
|
||||
return sysDept == null ? null : sysDept.getDeptId();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据企业ID获取企业下部门
|
||||
*
|
||||
* @param enterpriseId 企业ID
|
||||
* @param deptId 企业ID
|
||||
*
|
||||
* @return 企业信息,内含有部门
|
||||
*/
|
||||
@Override
|
||||
public SysDept getSysDeptByEnterpriseId (Long enterpriseId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysDept> getSysDeptByDeptId(Long deptId) {
|
||||
|
||||
return deptMapper.getSysDeptByDeptId(deptId);
|
||||
}
|
||||
/**
|
||||
* 递归列表
|
||||
*/
|
||||
|
|
|
@ -108,6 +108,12 @@
|
|||
<include refid="selectDeptVo"/>
|
||||
where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
|
||||
</select>
|
||||
<select id="selectDeptIdByLeader" resultType="com.couplet.common.system.domain.SysDept">
|
||||
SELECT * FROM sys_dept d LEFT JOIN sys_user u on d.dept_id = u.dept_id WHERE u.user_name = #{userName}
|
||||
</select>
|
||||
<select id="getSysDeptByDeptId" resultType="com.couplet.common.system.domain.SysDept">
|
||||
SELECT * FROM sys_dept WHERE parent_id = #{deptId}
|
||||
</select>
|
||||
|
||||
<insert id="insertDept" parameterType="com.couplet.common.system.domain.SysDept">
|
||||
insert into sys_dept(
|
||||
|
|
Loading…
Reference in New Issue