Explorar o código

修改企业逻辑

tianboguang %!s(int64=3) %!d(string=hai) anos
pai
achega
c50d783654

+ 0 - 442
platform-admin/src/main/java/com/platform/controller/SysDeptController.java

@@ -1,442 +0,0 @@
-package com.platform.controller;
-
-import com.alibaba.fastjson.JSON;
-import com.platform.annotation.SysLog;
-import com.platform.entity.Result;
-import com.platform.entity.SysDeptEntity;
-import com.platform.entity.SysUserEntity;
-import com.platform.service.SysDeptService;
-import com.platform.service.impl.SysUserServiceImpl;
-import com.platform.utils.*;
-import com.platform.vos.SysDeptEntityVo;
-import com.platform.vos.SysDeptVo;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang.StringUtils;
-import org.apache.shiro.authz.annotation.RequiresPermissions;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.CollectionUtils;
-import org.springframework.util.ObjectUtils;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.*;
-import java.util.stream.Collectors;
-
-/**
- * 部门管理Controller
- *
- * @author liepngjun
- * @email 939961241@qq.com
- * @gitee https://gitee.com/fuyang_lipengjun/platform
- * @date 2017-09-17 23:58:47
- */
-@Api(tags = "管理后台部门操作相关接口")
-@RestController
-@RequestMapping("/sys/dept")
-@Slf4j
-public class SysDeptController extends AbstractController {
-    @Autowired
-    private SysDeptService sysDeptService;
-
-    @Autowired
-    private SysUserServiceImpl sysUserService;
-
-    @ApiOperation(value = "获取公司可新增员工的数量")
-    @GetMapping("/getLessNum")
-    @RequiresPermissions("sys:user:list")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "deptId", value = "部门ID", dataType = "long"),
-    })
-    public Result userBindList(@RequestParam(name = "deptId") long deptId) {
-        Map<String , Object> mp = new HashMap<>();
-        SysDeptEntity sysDeptEntity = sysDeptService.queryObject(deptId);
-        if(null == sysDeptEntity){
-            return  Result.failure("公司不存在");
-        }
-        long curStaffNum = sysUserService.getUserNumOfDept(deptId);
-        long maxStaffNum = null !=  sysDeptEntity.getStaffNum() ? sysDeptEntity.getStaffNum() : 0;
-        long less = maxStaffNum - curStaffNum;
-        mp.put("less" , less);
-        return Result.success(mp);
-    }
-
-
-    /**
-     * 部门列表
-     *
-     * @return R
-     */
-    @RequestMapping("/list")
-    @RequiresPermissions("sys:dept:list")
-    public Result list(@RequestParam(name = "name") String name) {
-        List<SysDeptEntity> deptList;
-        if(StringUtils.isBlank(name)){
-            Map<String, Object> map = new HashMap<>();
-            //如果不是超级管理员,则只能查询本部门及子部门数据
-            if (getUserId() != Constant.SUPER_ADMIN) {
-                map.put("deptFilter", sysDeptService.getSubDeptIdList(getDeptId()));
-            }
-            if(map.containsKey("sidx")){
-                map.remove("sidx");
-            }
-            deptList = sysDeptService.queryList(map);
-        }else{
-            //如果不是超级管理员,则只能查询本部门及子部门数据
-            if (getUserId() != Constant.SUPER_ADMIN) {
-                deptList = sysDeptService.queryListByName(name , getAllSubDeptIds(getDeptId()));
-            }else{
-                deptList = sysDeptService.queryListByName(name , null);
-            }
-        }
-        // 获取管理员手机号
-        if(ObjectUtils.isEmpty(deptList)) {
-            return Result.success( deptList);
-        }
-        Map<Long, SysDeptEntity> entityMap = deptList.stream()
-                .collect(Collectors.toMap(SysDeptEntity::getDeptId, deptEntity -> deptEntity));
-        Map<String,Object> params = new HashMap<>();
-        params.put("deptIdList",entityMap.keySet());
-        List<SysUserEntity> users = sysUserService.queryList(params);
-        users.parallelStream().filter(user -> !ObjectUtils.isEmpty(user.getRoleId()))
-                .filter(user -> user.getRoleId() == 6 && entityMap.containsKey(user.getDeptId()))
-                .forEach(user -> {
-                    SysDeptEntity deptEntity = entityMap.get(user.getDeptId());
-                    String mobile = user.getMobile();
-                    if (ObjectUtils.isEmpty(deptEntity.getManagerPhoneNum())) {
-                        deptEntity.setManagerPhoneNum(mobile);
-                    } else {
-                        deptEntity.setManagerPhoneNum(deptEntity.getManagerPhoneNum().concat(";").concat(mobile));
-                    }
-                });
-        return Result.success(deptList);
-    }
-    @ApiOperation(value = "拉取所有部门列表,具有树状结构")
-    @PostMapping("/anonList")
-    public Result anonList() {
-        Map<String, Object> map = new HashMap<>();
-        //从总部开始去获取所有的子部门
-        map.put("deptFilter", sysDeptService.getSubDeptIdList(1L));
-        List<SysDeptEntity> deptList = sysDeptService.queryList(map);
-        return Result.success(deptList);
-    }
-
-    /**
-     * 选择部门(添加、修改菜单)
-     *
-     * @return R
-     */
-    @RequestMapping("/select")
-    @RequiresPermissions("sys:dept:select")
-    public Result select() {
-        Map<String, Object> map = new HashMap<>();
-        //如果不是超级管理员,则只能查询本部门及子部门数据
-        if (getUserId() != Constant.SUPER_ADMIN) {
-            map.put("deptFilter", sysDeptService.getSubDeptIdList(getDeptId()));
-        }
-        List<SysDeptEntity> deptList = sysDeptService.queryList(map);
-
-        //添加一级部门
-        if (getUserId() == Constant.SUPER_ADMIN) {
-            SysDeptEntity root = new SysDeptEntity();
-            root.setDeptId(0L);
-            root.setName("一级部门");
-            root.setParentId(-1L);
-            root.setOpen(true);
-            deptList.add(root);
-        }
-
-        return Result.success( deptList);
-    }
-
-    /**
-     * 获取用户部门Id(管理员则为0)
-     *
-     * @return
-     */
-    @RequestMapping("/info")
-    @RequiresPermissions("sys:dept:list")
-    public Result info() {
-        long deptId = 0;
-        if (getUserId() != Constant.SUPER_ADMIN) {
-            SysDeptEntity dept = sysDeptService.queryObject(getDeptId());
-            deptId = dept.getParentId();
-        }
-
-        return Result.success(deptId);
-    }
-
-    /**
-     * 根据主键获取部门信息
-     *
-     * @param deptId 主键
-     * @return R
-     */
-    @RequestMapping("/info/{deptId}")
-    @RequiresPermissions("sys:dept:info")
-    public Result info(@PathVariable("deptId") Long deptId) {
-        SysDeptEntity dept = sysDeptService.queryObject(deptId);
-
-        return Result.success( dept);
-    }
-
-    /**
-     * 新增部门
-     *
-     * @param dept 部门
-     * @return R
-     */
-    @ApiOperation(value = "新增部门")
-    @SysLog("新增部门")
-    @PostMapping("/save")
-    @RequiresPermissions("sys:dept:save")
-    public Result save(@RequestBody SysDeptEntityVo dept) {
-        try {
-            if(ObjectUtils.isEmpty(dept.getManagerPhoneNum())){
-                return Result.failure("手机号为空,请输入公司管理员手机号!");
-            }
-            SysUserEntity manager = sysUserService.queryByUserMobile(dept.getManagerPhoneNum());
-            if(!ObjectUtils.isEmpty(manager) && manager.getDeptId() != -1L){
-                return Result.failure("操作失败,当前账号已被绑定");
-            }
-            if (ObjectUtils.isEmpty(dept.getParentId())) {
-                dept.setParentId(1L);
-            }else{
-                Integer count = 0;
-                int parentLevel = countParentDeptLevel(dept.getParentId(), count);
-                log.info("当前部门的父类部门深度为:{}", parentLevel);
-                if (parentLevel > 4) {
-                    return Result.failure("部门层级已经达到5层了,无法再创建子部门");
-                }
-            }
-            if (ObjectUtils.isEmpty(dept.getDeptId())) {
-                dept.setCurStaffNum(1);
-            } else {
-                SysDeptEntity deptEntity = sysDeptService.queryObject(dept.getDeptId());
-                if (ObjectUtils.isEmpty(deptEntity.getCurStaffNum())) {
-                    deptEntity.setCurStaffNum(0);
-                }
-                deptEntity.setCurStaffNum(deptEntity.getCurStaffNum() + 1);
-            }
-            sysDeptService.save(dept);
-            //需要更新公司管理员的部门id
-            manager.setDeptId(dept.getDeptId());
-            manager.setRoleIdList(Arrays.asList(6L));
-            sysUserService.update(manager);
-        } catch (Exception e) {
-            e.printStackTrace();
-            return Result.failure(e.getMessage());
-        }
-        return Result.success();
-    }
-
-    @SysLog("计算当前部门的深度")
-    @ApiOperation(value = "计算当前部门的深度")
-    @GetMapping("/countDeptLevel")
-    @RequiresPermissions("sys:dept:save")
-    public Result countDeptLevel(Long deptId) {
-        if(null == deptId){
-            return Result.failure("部门Id缺失");
-        }
-        int count = 0;
-        Map<String , Object> result  = new HashMap<>();
-        result.put("num" , countParentDeptLevel(deptId , count));
-        return  Result.success(result);
-
-    }
-
-    public int countParentDeptLevel(long parentId , Integer count){
-
-        SysDeptEntity sysDeptEntity = sysDeptService.queryObject(parentId);
-        if(null == sysDeptEntity){
-            return 0;
-        }
-        if(count > 10){
-            log.warn("递归嵌套超过了10,保护资源,停止递归");
-            return 0;
-        }
-        count += 1;
-        if(null != sysDeptEntity.getParentId()){
-           return  1 + countParentDeptLevel(sysDeptEntity.getParentId() , count);
-        }
-
-        return 1;
-    }
-
-
-    @SysLog("校验父部门的管理员的短信验证码")
-    @PostMapping("/validParentAdmin")
-    @ResponseBody
-    @Transactional(rollbackFor = Exception.class)
-    public Result validParentAdmin(@RequestBody SysDeptVo sysDeptVo) {
-        if(null == sysDeptVo){
-            return Result.failure("缺失参数");
-        }
-        if(null == sysDeptVo.getParentId()){
-            return Result.failure("缺失父部门的id");
-        }
-
-        if(StringUtils.isBlank(sysDeptVo.getParentAdminPhoneNum())){
-            return Result.failure("缺失父部门管理员的手机号");
-        }
-
-        if(StringUtils.isBlank(sysDeptVo.getParentSmsCode())){
-            return Result.failure("缺失父部门管理员的短信验证码");
-        }
-        SysUserEntity parentAdmin = sysUserService.queryByMobileAndDeptId(sysDeptVo.getParentAdminPhoneNum() , sysDeptVo.getParentId());
-        if(null == parentAdmin){
-            return Result.failure("父部门的管理员信息不正确");
-        }
-
-        //校验管理员的短信验证码
-        String parentSmsCode = (String) LettuceRedisClientUtils.getValueByKey("login_sms_code:" + sysDeptVo.getParentAdminPhoneNum() + sysDeptVo.getParentSmsCode());
-        logger.info("上级部门管理员的上送验证码为:{},缓存中的为:{}" , sysDeptVo.getParentSmsCode() , parentSmsCode);
-        if(StringUtils.isBlank(parentSmsCode)){
-            return Result.failure("上级部门管理员的验证码过期或者不正确");
-        }
-        return Result.success();
-
-    }
-
-
-    @SysLog("新增部门同时更新管理员数据")
-    @PostMapping("/createDept")
-    @ResponseBody
-    @Transactional(rollbackFor = Exception.class)
-    public Result saveDept(@RequestBody SysDeptVo sysDeptVo) {
-
-        if(null == sysDeptVo){
-            return Result.failure("缺失参数");
-        }
-
-        if(StringUtils.isBlank(sysDeptVo.getSmsCode()) || StringUtils.isBlank(sysDeptVo.getAdminPhoneNum())){
-            return Result.failure("管理员的手机号或者验证码缺失");
-        }
-        //校验当前管理员的手机验证码
-        String smsCode = (String) LettuceRedisClientUtils.getValueByKey("login_sms_code:" + sysDeptVo.getAdminPhoneNum() + sysDeptVo.getSmsCode());
-        logger.info("上级部门管理员的上送验证码为:{},缓存中的为:{}" , sysDeptVo.getSmsCode() , smsCode);
-        if(StringUtils.isBlank(smsCode)){
-            return Result.failure("管理员的短信验证码过期或者无效");
-        }
-
-        SysUserEntity userEntity = getUser();
-        if(null == userEntity){
-            return Result.failure("用户未登录");
-        }
-        if(null != userEntity.getDeptId()){
-            return Result.failure("一个用户只能归属一个部门");
-        }
-
-        //新增部门数据
-        SysDeptEntity sysDeptEntity = new SysDeptEntity();
-        sysDeptEntity.setName(sysDeptVo.getDeptName());
-        if(null == sysDeptVo.getParentId()){
-            //不传,默认认为是新建,新建的,统一设置为1l总部
-            sysDeptEntity.setParentId(1L);
-        }else{
-            sysDeptEntity.setParentId(sysDeptVo.getParentId());
-        }
-
-        //TODO:事务管控
-        sysDeptService.save(sysDeptEntity);
-
-        log.info("新增的部门id={}" , sysDeptEntity.getDeptId());
-
-        //更新部门数据到管理员
-        SysUserEntity admin = sysUserService.queryByUserMobile(sysDeptVo.getAdminPhoneNum());
-        if(null == admin){
-            log.warn("管理员用户:{}不存在" , sysDeptVo.getAdminPhoneNum());
-        }else{
-            admin.setDeptId(sysDeptEntity.getDeptId());
-            sysUserService.updateUserAndAddDeptAdminRolls(admin);
-        }
-        return Result.success();
-    }
-
-
-    /**
-     * 修改部门
-     *
-     * @param dept 部门
-     * @return R
-     */
-    @SysLog("修改部门")
-    @RequestMapping("/update")
-    @RequiresPermissions("sys:dept:update")
-    public Result update(@RequestBody SysDeptEntityVo dept) {
-        sysDeptService.update(dept);
-
-        return Result.success();
-    }
-
-    /**
-     * 删除部门
-     *
-     * @param deptId 主键
-     * @return R
-     */
-    @SysLog("删除部门")
-    @RequestMapping("/delete")
-    @RequiresPermissions("sys:dept:delete")
-    public Result delete(long deptId) {
-        //判断是否有子部门
-        List<Long> deptList = getAllSubDeptIds(deptId);
-        if (deptList.size() > 1) {
-            return Result.failure("请先删除子部门");
-        }
-        // 判断 该部门(子部门)下有没有账号
-        List<SysUserEntity> users = sysUserService.getSysUserListByDeptIds(deptList);
-        if(!CollectionUtils.isEmpty(users)){
-            return Result.failure("删除失败,请先将公司以及下级公司所绑定的账号都解绑后,再进行删除!");
-        }
-        sysDeptService.delete(deptId);
-        return Result.success();
-    }
-
-    public List<Long> getAllSubDeptIds(Long deptId) {
-        if (null == deptId) {
-            log.info("部门ID为空");
-            return new ArrayList<>();
-        }
-        List<Long> allDeptIdList = new ArrayList<>();
-        int leve = 0;
-        leve = findDeptIdByParent(deptId, 0, allDeptIdList);
-        log.info("获取到当前部门以及所有子部门(10层嵌套以内)的id为:{},部门层级为:{}",
-                JSON.toJSONString(allDeptIdList) , leve);
-        return allDeptIdList;
-    }
-
-    private int findDeptIdByParent(long deptId, int level, List<Long> deptIdList) {
-
-        if (level > 10) {
-            log.info("嵌套层数超过了10层");
-            return level;
-        }
-        deptIdList.add(deptId);
-        //获取所有子部门的id
-        List<Long> subDeptIdList = sysDeptService.queryDetpIdList(deptId);
-        if (CollectionUtils.isEmpty(subDeptIdList)) {
-            //自己算一层,没有子部门,要先加上自己这一层
-            return level + 1;
-        }
-        int maxLevel = 0;
-        for(Long id : subDeptIdList){
-            //遍历所有子部门的子部门,并记下子部门中嵌套最深的层数
-            int tmpLevel = findDeptIdByParent(id, level, deptIdList);
-            if(tmpLevel > maxLevel){
-                maxLevel = tmpLevel;
-            }
-        }
-        //添加子部门的id
-        deptIdList.addAll(subDeptIdList);
-        //叠加子部门的最大层级
-        level += maxLevel;
-        //加上自己这一层
-        level += 1;
-        return level;
-    }
-
-}

+ 5 - 11
platform-common/src/main/java/com/platform/controller/SysLoginController.java

@@ -6,12 +6,10 @@ import com.google.code.kaptcha.Constants;
 import com.google.code.kaptcha.Producer;
 import com.platform.annotation.SysLog;
 import com.platform.entity.Result;
-import com.platform.entity.SysDeptEntity;
 import com.platform.entity.SysSmsLogEntity;
 import com.platform.entity.SysUserEntity;
 import com.platform.enums.ResultCodeEnum;
 import com.platform.exception.CommonBaseException;
-import com.platform.service.SysDeptService;
 import com.platform.service.impl.SysSmsLogServiceImpl;
 import com.platform.service.impl.SysUserRoleServiceImpl;
 import com.platform.service.impl.SysUserServiceImpl;
@@ -75,9 +73,6 @@ public class SysLoginController {
     @Autowired
     private SysUserRoleServiceImpl sysUserRoleService;
 
-    @Autowired
-    private SysDeptService sysDeptService;
-
     @Value("${scenePath}")
     private String zhiHouseHost;
 
@@ -301,12 +296,11 @@ public class SysLoginController {
             BeanUtils.copyProperties(dbUser,userVo);
             if(!ObjectUtils.isEmpty(dbUser.getDeptId())){
                 // 获取用户所在企业信息
-                SysDeptEntity deptEntity = sysDeptService.queryObject(dbUser.getDeptId());
-                userVo.setDeptName(deptEntity.getName());
-                userVo.setDeptManagerPhoneNum(deptEntity.getManagerPhoneNum());
-                userVo.setDeptExpirationDate(deptEntity.getExpirationDate());
-                userVo.setParentDeptId(deptEntity.getParentId());
-                userVo.setParentDeptName(deptEntity.getParentName());
+                JSONObject deptEntity = zhiHouseService.getComponyInfo(dbUser.getMobile());
+                userVo.setDeptName(deptEntity.getString("name"));
+                userVo.setDeptId(deptEntity.getLong("id"));
+                userVo.setDeptManagerPhoneNum(deptEntity.getString("phoneNum"));
+                userVo.setDeptExpirationDate(deptEntity.getDate("expirationDate"));
                 userVo.setFdkkPassword(null);
             }
             resultMap.put("user", userVo);

+ 0 - 10
platform-common/src/main/java/com/platform/controller/SysRoleController.java

@@ -37,12 +37,6 @@ public class SysRoleController extends AbstractController {
     @Autowired
     private SysRoleDeptService sysRoleDeptService;
 
-    @Autowired
-    private SysUserRoleServiceImpl sysUserRoleService;
-
-    @Autowired
-    private DepartmentUtils departmentUtils;
-
     /**
      * 角色列表
      */
@@ -52,10 +46,6 @@ public class SysRoleController extends AbstractController {
         //如果不是超级管理员,则只查询自己创建的角色列表
         if (getUserId() != Constant.SUPER_ADMIN) {
             params.put("excludeSuperAdmin",  true);
-            List<Long> deptIdList = departmentUtils.getAllSubDeptIds(getDeptId());
-            if(!CollectionUtils.isEmpty(deptIdList)){
-                params.put("deptIdList",  deptIdList);
-            }
         }
 
         //查询列表数据

+ 0 - 36
platform-common/src/main/java/com/platform/dao/SysDeptDao.java

@@ -1,36 +0,0 @@
-package com.platform.dao;
-
-import com.platform.entity.SysDeptEntity;
-import com.platform.entity.UserWindowDto;
-import com.platform.vos.SysDeptEntityVo;
-import org.apache.ibatis.annotations.Mapper;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-
-/**
- * 部门管理
- *
- * @author liepngjun
- * @email 939961241@qq.com
- * @date 2017-09-17 23:58:47
- */
-@Mapper
-public interface SysDeptDao extends BaseDao<SysDeptEntity> {
-
-    /**
-     * 查询子部门ID列表
-     *
-     * @param parentId 上级部门ID
-     */
-    List<Long> queryDetpIdList(Long parentId);
-
-    List<SysDeptEntity> queryListByName(@Param("name") String name ,
-                                        @Param("deptIdList") List<Long> deptIdList);
-
-    int queryListByNameCount(@Param("name") String name ,
-                              @Param("deptIdList") List<Long> deptIdList);
-
-    SysDeptEntity getDeptByParentDetpId(@Param("parentId") Long parentId);
-
-}

+ 0 - 57
platform-common/src/main/java/com/platform/service/SysDeptService.java

@@ -1,57 +0,0 @@
-package com.platform.service;
-
-import com.platform.entity.SysDeptEntity;
-import com.platform.entity.UserWindowDto;
-import com.platform.page.Page;
-import com.platform.vos.SysDeptEntityVo;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * 部门管理
- *
- * @author liepngjun
- * @email 939961241@qq.com
- * @date 2017-09-17 23:58:47
- */
-public interface SysDeptService {
-
-    SysDeptEntity queryObject(Long deptId);
-
-    SysDeptEntity getDeptByParentDeptId(Long parentDeptId);
-
-    int queryTotal();
-
-
-    List<SysDeptEntity> queryList(Map<String, Object> map);
-
-    List<SysDeptEntity> queryListByName(String name , List<Long> deptIdList);
-
-    int countQueryListByName(String name , List<Long> deptIdList);
-
-    void save(SysDeptEntityVo sysDept);
-
-    void save(SysDeptEntity sysDept);
-
-    void update(SysDeptEntity sysDept);
-
-    void update(SysDeptEntityVo dept);
-
-    void delete(Long deptId);
-
-    /**
-     * 查询子部门ID列表
-     *
-     * @param parentId 上级部门ID
-     */
-    List<Long> queryDetpIdList(Long parentId);
-
-    /**
-     * 获取子部门ID(包含本部门ID),用于数据过滤
-     */
-    String getSubDeptIdList(Long deptId);
-
-    List<Long> getSubDeptIdLongList(Long deptId);
-
-}

+ 0 - 147
platform-common/src/main/java/com/platform/service/impl/SysDeptServiceImpl.java

@@ -1,147 +0,0 @@
-package com.platform.service.impl;
-
-import com.platform.dao.SysDeptDao;
-import com.platform.entity.SysDeptEntity;
-import com.platform.entity.UserWindowDto;
-import com.platform.page.Page;
-import com.platform.page.PageHelper;
-import com.platform.service.SysDeptService;
-import com.platform.utils.Constant;
-import com.platform.utils.DateUtils;
-import com.platform.vos.SysDeptEntityVo;
-import com.qiniu.util.StringUtils;
-import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.util.ObjectUtils;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-@Service("sysDeptService")
-public class SysDeptServiceImpl implements SysDeptService {
-    @Autowired
-    private SysDeptDao sysDeptDao;
-
-
-    @Override
-    public int countQueryListByName(String name, List<Long> deptIdList) {
-        return sysDeptDao.queryListByNameCount(name , deptIdList);
-    }
-
-    @Override
-    public List<SysDeptEntity> queryListByName(String name, List<Long> deptIdList) {
-        return sysDeptDao.queryListByName(name , deptIdList);
-    }
-
-    @Override
-    public SysDeptEntity queryObject(Long deptId) {
-        return sysDeptDao.queryObject(deptId);
-    }
-
-
-    @Override
-    public SysDeptEntity getDeptByParentDeptId(Long parentDeptId) {
-        return sysDeptDao.getDeptByParentDetpId(parentDeptId);
-    }
-
-    @Override
-    public int queryTotal() {
-        return sysDeptDao.queryTotal();
-    }
-
-    @Override
-    public List<SysDeptEntity> queryList(Map<String, Object> map) {
-        return sysDeptDao.queryList(map);
-    }
-
-    @Override
-    public void save(SysDeptEntity deptEntity) {
-        sysDeptDao.save(deptEntity);
-    }
-
-    @Override
-    public void save(SysDeptEntityVo sysDept) {
-        SysDeptEntity deptEntity = new SysDeptEntity();
-        BeanUtils.copyProperties(sysDept,deptEntity);
-        if(!ObjectUtils.isEmpty(sysDept.getExpirationDate())){
-            Date date = null;
-            try {
-                date = DateUtils.convertStringToDate(sysDept.getExpirationDate());
-            } catch (Exception e) {
-                throw new RuntimeException("时间格式有误,正确格式:yyyy-MM-dd");
-            }
-            deptEntity.setExpirationDate(date);
-        }
-        if(ObjectUtils.isEmpty(sysDept.getDeptId())){
-            save(deptEntity);
-            sysDept.setDeptId(deptEntity.getDeptId());
-        }else{
-            update(sysDept);
-        }
-
-    }
-
-    @Override
-    public void update(SysDeptEntity sysDept) {
-        sysDeptDao.update(sysDept);
-    }
-
-    @Override
-    public void update(SysDeptEntityVo sysDept) {
-        SysDeptEntity deptEntity = new SysDeptEntity();
-        BeanUtils.copyProperties(sysDept,deptEntity);
-        if(!ObjectUtils.isEmpty(sysDept.getExpirationDate())){
-            deptEntity.setExpirationDate(DateUtils.convertStringToDate(sysDept.getExpirationDate()));
-        }
-        sysDeptDao.update(deptEntity);
-    }
-
-    @Override
-    public void delete(Long deptId) {
-        sysDeptDao.delete(deptId);
-    }
-
-    @Override
-    public List<Long> queryDetpIdList(Long parentId) {
-        return sysDeptDao.queryDetpIdList(parentId);
-    }
-
-    @Override
-    public String getSubDeptIdList(Long deptId) {
-        List<Long> deptIdList = getSubDeptIdLongList(deptId);
-        String deptFilter = StringUtils.join(deptIdList, ",");
-        return deptFilter;
-    }
-
-    @Override
-    public List<Long> getSubDeptIdLongList(Long deptId) {
-        //部门及子部门ID列表
-        List<Long> deptIdList = new ArrayList<>();
-
-        //获取子部门ID
-        List<Long> subIdList = queryDetpIdList(deptId);
-        getDeptTreeList(subIdList, deptIdList);
-
-        //添加本部门
-        deptIdList.add(deptId);
-
-        return deptIdList;
-    }
-
-    /**
-     * 递归
-     */
-    public void getDeptTreeList(List<Long> subIdList, List<Long> deptIdList) {
-        for (Long deptId : subIdList) {
-            List<Long> list = queryDetpIdList(deptId);
-            if (list.size() > 0) {
-                getDeptTreeList(list, deptIdList);
-            }
-
-            deptIdList.add(deptId);
-        }
-    }
-}

+ 8 - 28
platform-common/src/main/java/com/platform/service/impl/SysUserServiceImpl.java

@@ -3,29 +3,31 @@ package com.platform.service.impl;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.github.pagehelper.util.StringUtil;
 import com.platform.dao.SysUserDao;
-import com.platform.entity.*;
+import com.platform.entity.Result;
+import com.platform.entity.SysRoleEntity;
+import com.platform.entity.SysUserEntity;
+import com.platform.entity.UserWindowDto;
 import com.platform.enums.ResultCodeEnum;
 import com.platform.enums.SysRoleEnum;
 import com.platform.exception.CommonBaseException;
 import com.platform.page.Page;
 import com.platform.page.PageHelper;
-import com.platform.service.SysDeptService;
 import com.platform.service.SysRoleService;
 import com.platform.service.SysUserRoleService;
 import com.platform.service.SysUserService;
-import com.platform.utils.*;
+import com.platform.utils.Base64Converter;
+import com.platform.utils.Constant;
+import com.platform.utils.RRException;
+import com.platform.utils.ShiroUtils;
 import com.platform.vos.CurrentUserLoginVo;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.apache.shiro.crypto.hash.Sha256Hash;
-import org.checkerframework.checker.units.qual.A;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.ObjectUtils;
@@ -50,8 +52,6 @@ public class SysUserServiceImpl implements SysUserService {
     private SysUserRoleService sysUserRoleService;
     @Autowired
     private SysRoleService sysRoleService;
-    @Autowired
-    private SysDeptService sysDeptService;
 
     @Autowired
     private ZhiHouseService zhiHouseService;
@@ -228,26 +228,6 @@ public class SysUserServiceImpl implements SysUserService {
 
         //保存用户与角色关系
         sysUserRoleService.saveOrUpdate(user.getUserId(), user.getRoleIdList());
-
-        // 更新企业员工数
-        if (!StringUtils.equals(userEntity.getDeptId()+"",user.getDeptId()+"")) {
-            if (!ObjectUtils.isEmpty(userEntity.getDeptId()) && userEntity.getDeptId() != -1L) {
-                Long userNumOfDept = getUserNumOfDept(userEntity.getDeptId());
-                if(!ObjectUtils.isEmpty(userNumOfDept)){
-                    SysDeptEntity deptEntity = sysDeptService.queryObject(userEntity.getDeptId());
-                    deptEntity.setCurStaffNum(userNumOfDept.intValue());
-                    sysDeptService.update(deptEntity);
-                }
-            }
-            if (!ObjectUtils.isEmpty(user.getDeptId()) && user.getDeptId() != -1L) {
-                Long userNumOfDept = getUserNumOfDept(user.getDeptId());
-                if(!ObjectUtils.isEmpty(userNumOfDept)){
-                    SysDeptEntity deptEntity = sysDeptService.queryObject(user.getDeptId());
-                    deptEntity.setCurStaffNum(userNumOfDept.intValue());
-                    sysDeptService.update(deptEntity);
-                }
-            }
-        }
     }
 
     @Override

+ 18 - 0
platform-common/src/main/java/com/platform/service/impl/ZhiHouseService.java

@@ -183,4 +183,22 @@ public class ZhiHouseService {
 
         return responseEntity.getBody().getMessage();
     }
+
+    public JSONObject getComponyInfo(String phone) {
+        if(org.apache.commons.lang3.StringUtils.isBlank(phone)){
+            throw new CommonBaseException(ResultCodeEnum.D101 , "入参不全,无法获取四维场景列表");
+        }
+        String url = zhiHouseHost + "company/getCompony";
+        Map<String ,Object> params = new HashMap<>(1);
+        params.put("phone",phone);
+        ResponseEntity<ReturnDTO> responseEntity = restTemplate.postForEntity(url,params,ReturnDTO.class);
+        if(responseEntity.getStatusCode()!= HttpStatus.OK){
+            throw new CommonBaseException(ResultCodeEnum.D100);
+        }
+        if (responseEntity.getBody().getCode() != 200) {
+            throw new CommonBaseException(ResultCodeEnum.D100,responseEntity.getBody().getError());
+        }
+        //把信息封装为json
+        return JSONObject.parseObject(JSONObject.toJSONString(responseEntity.getBody().getMessage()));
+    }
 }

+ 10 - 10
platform-common/src/main/java/com/platform/shiro/UserRealm.java

@@ -1,13 +1,13 @@
 package com.platform.shiro;
 
+import com.alibaba.fastjson.JSONObject;
 import com.platform.cache.J2CacheUtils;
-import com.platform.dao.SysDeptDao;
 import com.platform.dao.SysMenuDao;
 import com.platform.dao.SysUserDao;
 import com.platform.dao.SysUserRoleDao;
-import com.platform.entity.SysDeptEntity;
 import com.platform.entity.SysMenuEntity;
 import com.platform.entity.SysUserEntity;
+import com.platform.service.impl.ZhiHouseService;
 import com.platform.utils.Constant;
 import com.platform.vos.CurrentUserLoginVo;
 import org.apache.commons.lang.StringUtils;
@@ -38,10 +38,11 @@ public class UserRealm extends AuthorizingRealm {
     private SysMenuDao sysMenuDao;
 
     @Autowired
-    private SysDeptDao sysDeptDao;
-    @Autowired
     private SysUserRoleDao sysUserRoleDao;
 
+    @Autowired
+    private ZhiHouseService zhiHouseService;
+
     /**
      * 授权(验证权限时调用)
      */
@@ -114,12 +115,11 @@ public class UserRealm extends AuthorizingRealm {
         Session session = subject.getSession(true);
         if(!ObjectUtils.isEmpty(user.getDeptId())){
             // 获取用户所在企业信息
-            SysDeptEntity deptEntity = sysDeptDao.queryObject(user.getDeptId());
-            user.setDeptName(deptEntity.getName());
-            user.setDeptManagerPhoneNum(deptEntity.getManagerPhoneNum());
-            user.setDeptExpirationDate(deptEntity.getExpirationDate());
-            user.setParentDeptId(deptEntity.getParentId());
-            user.setParentDeptName(deptEntity.getParentName());
+            JSONObject deptEntity = zhiHouseService.getComponyInfo(user.getMobile());
+            user.setDeptName(deptEntity.getString("name"));
+            user.setDeptId(deptEntity.getLong("id"));
+            user.setDeptManagerPhoneNum(deptEntity.getString("phone"));
+            user.setDeptExpirationDate(deptEntity.getDate("expirationDate"));
         }
         session.setAttribute(Constant.CURRENT_USER, user);
         List<String> permsList;

+ 0 - 69
platform-common/src/main/java/com/platform/utils/DepartmentUtils.java

@@ -1,69 +0,0 @@
-package com.platform.utils;
-
-import com.alibaba.fastjson.JSON;
-import com.platform.entity.SysDeptEntity;
-import com.platform.service.impl.SysDeptServiceImpl;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author abnerhou
- * @date 2020/10/12 17:08
- * @desciption
- */
-@Service
-@Slf4j
-public class DepartmentUtils {
-
-    @Autowired
-    private SysDeptServiceImpl sysDeptService;
-
-
-    public List<Long> getAllSubDeptIds(Long deptId) {
-        if (null == deptId) {
-            log.info("部门ID为空");
-            return new ArrayList<>();
-        }
-        List<Long> allDeptIdList = new ArrayList<>();
-        int leve = 0;
-        leve = findDeptIdByParent(deptId, 0, allDeptIdList);
-        log.info("获取到当前部门以及所有子部门(10层嵌套以内)的id为:{},部门层级为:{}",
-                JSON.toJSONString(allDeptIdList) , leve);
-        return allDeptIdList;
-    }
-
-    private int findDeptIdByParent(long deptId, int level, List<Long> deptIdList) {
-
-        if (level > 10) {
-            log.info("嵌套层数超过了10层");
-            return level;
-        }
-        deptIdList.add(deptId);
-        //获取所有子部门的id
-        List<Long> subDeptIdList = sysDeptService.queryDetpIdList(deptId);
-        if (CollectionUtils.isEmpty(subDeptIdList)) {
-            //自己算一层,没有子部门,要先加上自己这一层
-            return level + 1;
-        }
-        int maxLevel = 0;
-        for(Long id : subDeptIdList){
-            //遍历所有子部门的子部门,并记下子部门中嵌套最深的层数
-            int tmpLevel = findDeptIdByParent(id, level, deptIdList);
-            if(tmpLevel > maxLevel){
-                maxLevel = tmpLevel;
-            }
-        }
-        //添加子部门的id
-        deptIdList.addAll(subDeptIdList);
-        //叠加子部门的最大层级
-        level += maxLevel;
-        //加上自己这一层
-        level += 1;
-        return level;
-    }
-}

+ 0 - 110
platform-common/src/main/resources/com/platform/dao/SysDeptDao.xml

@@ -1,110 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="com.platform.dao.SysDeptDao">
-
-	<select id="queryObject" resultType="com.platform.entity.SysDeptEntity">
-		select * from sys_dept where dept_id = #{value} and del_flag = 0
-	</select>
-
-
-	<select id="getDeptByParentDetpId" resultType="com.platform.entity.SysDeptEntity">
-		select * from sys_dept where parent_id = #{parentId} and del_flag = 0
-	</select>
-
-
-	<select id="queryTotal" resultType="java.lang.Integer">
-		select count(*) from sys_dept where del_flag = 0
-	</select>
-
-	<select id="queryList" resultType="com.platform.entity.SysDeptEntity">
-		select d.*,(select p.name from sys_dept p where p.dept_id = d.parent_id) as parentName
-		from sys_dept d where d.del_flag = 0
-		<if test="deptFilter != null">
-			and d.dept_id in (${deptFilter})
-		</if>
-		order by d.order_num asc,d.dept_id desc
-
-		<if test="offset != null and limit != null">
-			limit #{offset}, #{limit}
-		</if>
-	</select>
-
-	<select id="queryListByName" resultType="com.platform.entity.SysDeptEntity">
-		select d.*,(select p.name from sys_dept p where p.dept_id = d.parent_id) as parentName
-		from sys_dept d where
-		d.del_flag = 0
-		<if test="name != null and name.trim() != ''">
-			AND d.name LIKE concat('%',#{name},'%')
-		</if>
-
-		<if test="deptIdList != null">
-			AND d.dept_id in
-			<foreach item="id" collection="deptIdList" open="(" separator="," close=")">
-				#{id}
-			</foreach>
-		</if>
-		order by d.order_num asc,d.dept_id desc
-	</select>
-
-	<select id="queryListByNameCount" resultType="java.lang.Integer">
-		select count(*)
-		from sys_dept d where
-		d.del_flag = 0
-		<if test="name != null and name.trim() != ''">
-			AND d.name LIKE concat('%',#{name},'%')
-		</if>
-
-		<if test="deptIdList != null">
-			AND d.dept_id in
-			<foreach item="id" collection="deptIdList" open="(" separator="," close=")">
-				#{id}
-			</foreach>
-		</if>
-	</select>
-	 
-	<insert id="save" parameterType="com.platform.entity.SysDeptEntity" useGeneratedKeys="true" keyProperty="deptId">
-		insert into sys_dept
-		(
-			`parent_id`, 
-			`name`, 
-			`order_num`,
-			`staff_num`,
-			`cur_staff_num`,
-			`expiration_date`,
-			`logo_url`
-		)
-		values
-		(
-			#{parentId}, 
-			#{name}, 
-			#{orderNum},
-			#{staffNum},
-			#{curStaffNum},
-			#{expirationDate},
-			#{logoUrl}
-		)
-	</insert>
-	 
-	<update id="update" parameterType="com.platform.entity.SysDeptEntity">
-		update sys_dept 
-		<set>
-			<if test="parentId != null">`parent_id` = #{parentId}, </if>
-			<if test="name != null">`name` = #{name}, </if>
-			<if test="orderNum != null">`order_num` = #{orderNum},</if>
-			<if test="staffNum != null">`staff_num` = #{staffNum},</if>
-			<if test="curStaffNum != null">`cur_staff_num` = #{curStaffNum},</if>
-			<if test="expirationDate != null">`expiration_date` = #{expirationDate},</if>
-			<if test="logoUrl != null">`logo_url` = #{logoUrl}</if>
-		</set>
-		where dept_id = #{deptId}
-	</update>
-	
-	<update id="delete">
-		update sys_dept set del_flag = -1 where dept_id = #{value}
-	</update>
-	
-	<select id="queryDetpIdList" resultType="long">
-		select dept_id from sys_dept where parent_id = #{value} and del_flag = 0
-	</select>
-</mapper>

+ 3 - 7
platform-shop/src/main/java/com/platform/controller/BrandController.java

@@ -63,9 +63,6 @@ public class BrandController extends AbstractController{
     private SysUserService sysUserService;
 
     @Autowired
-    private DepartmentUtils departmentUtils;
-
-    @Autowired
     private TmBrandTypeService tmBrandTypeService;
 
     @Autowired
@@ -114,7 +111,7 @@ public class BrandController extends AbstractController{
     public Result brandBindList(@RequestParam(name = "page") long page,
                            @RequestParam(name = "limit") long limit,
                            String sceneName,String brandName,Integer type,Integer livestreamStatus) {
-        List<Long> deptIdList = null;
+        List<Long> deptIdList = new ArrayList<>();
         Long userId = null;
         //如果不是超级管理员,则只能查询本部门及子部门数据
         if (getUserId() != Constant.SUPER_ADMIN) {
@@ -126,8 +123,7 @@ public class BrandController extends AbstractController{
                 if(ObjectUtils.isEmpty(getUser().getDeptId())){
                     return Result.failure("该账号未绑定公司!");
                 }
-                // 公司管理员
-                deptIdList = departmentUtils.getAllSubDeptIds(getUser().getDeptId());
+                deptIdList.add(getDeptId());
             }
         }
         IPage<BrandEntity> resultPage = brandService.queryBrandBindList(page , limit , sceneName , brandName,
@@ -303,7 +299,7 @@ public class BrandController extends AbstractController{
             if(null == getDeptId()){
                 return Result.success(new ArrayList<>());
             }
-            params.put("deptIdList", departmentUtils.getAllSubDeptIds(getDeptId()));
+            params.put("deptIdList", getDeptId());
         }
 
         List<BrandEntity> list = brandService.queryList(params);

+ 1 - 10
platform-shop/src/main/java/com/platform/service/custom/LiveRoomInfoService.java

@@ -7,17 +7,12 @@ import com.platform.entity.TmLiveRoomInfo;
 import com.platform.enums.IdStarterEnum;
 import com.platform.service.impl.TmLiveRoomInfoServiceImpl;
 import com.platform.utils.Constant;
-import com.platform.utils.DepartmentUtils;
 import com.platform.utils.StringUtils;
 import com.platform.utils.UUidGenerator;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.time.LocalDate;
 import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.List;
 
 /**
  * @author abnerhou
@@ -28,9 +23,6 @@ import java.util.List;
 @Service
 public class LiveRoomInfoService extends TmLiveRoomInfoServiceImpl {
 
-    @Autowired
-    private DepartmentUtils departmentUtils;
-
     public int addNew(TmLiveRoomInfo tmLiveRoomInfo){
         if(null == tmLiveRoomInfo){
           return -1;
@@ -69,8 +61,7 @@ public class LiveRoomInfoService extends TmLiveRoomInfoServiceImpl {
             if(null == userDeptId){
                 return new Page<TmLiveRoomInfo>(pageNum , pageSize);
             }
-            List<Long> deptIds = departmentUtils.getAllSubDeptIds(userDeptId);
-            queryWrapper.in("create_user_dept_id" , deptIds);
+            queryWrapper.eq("create_user_dept_id" , userDeptId);
         }
         return getBaseMapper().selectPage(page , queryWrapper);
     }