Compare commits

...

3 Commits

Author SHA1 Message Date
lijiayao 1910013cbb Merge remote-tracking branch 'origin/server_five_fufanrui' into server_five_xiaoyao
# Conflicts:
#	couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/src/main/java/com/couplet/server/service/ManageServer.java
#	couplet-modules/couplet-enterprisemanagement/couplet-enterprisemanagement-server/src/main/java/com/couplet/server/service/impl/ManageServiceImpl.java
2024-03-31 10:22:47 +08:00
ffr 2b392ec1d1 管理企业 2024-03-31 10:17:59 +08:00
ffr 24c219c145 更新代码 2024-03-30 09:50:19 +08:00
14 changed files with 324 additions and 61 deletions

View File

@ -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;
}

View File

@ -61,7 +61,7 @@ public class LoginUser implements Serializable {
/**
* ID
*/
private Long enterpriseId;
private Long deptId;
/**
*

View File

@ -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);
}

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,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());
}
};
}
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}
}

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.*;
@ -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;
}
}

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);
@ -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);
}
/**
*
*/

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}
/**
*
*/

View File

@ -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(