fix
Helius
2022-07-12 3dc1ca272294451ba48277e201a22d596d10e645
fix
2 files modified
93 ■■■■■ changed files
README.md 35 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/CompanyServiceImpl.java 58 ●●●● patch | view | raw | blame | history
README.md
@@ -1,35 +1,6 @@
# kss-framework
# Farmer-CMS
#### 介绍
{**以下是码云平台说明,您可以替换此简介**
码云是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台
无论是个人、团队、或是企业,都能够用码云实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)}
#### 软件架构
软件架构说明
#### 安装教程
1.  xxxx
2.  xxxx
3.  xxxx
#### 使用说明
1.  mapstruct
https://mapstruct.org/documentation/stable/reference/html/
2.  mybatis-plus
https://mybatis.plus/guide/#%E7%89%B9%E6%80%A7
3.  参数校验
https://mp.weixin.qq.com/s/yRuLmtUkARG3OziHB9dJPw
#### 参与贡献
1.  Fork 本仓库
2.  新建 Feat_xxx 分支
3.  提交代码
4.  新建 Pull Request
#### 待开发
中英文切换、手机端
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/CompanyServiceImpl.java
@@ -11,10 +11,7 @@
import com.xcong.farmer.cms.modules.system.dto.AdminBelongDto;
import com.xcong.farmer.cms.modules.system.dto.AdminDeleteDto;
import com.xcong.farmer.cms.modules.system.dto.AdminUpdateCompanyDto;
import com.xcong.farmer.cms.modules.system.entity.CompanyEntity;
import com.xcong.farmer.cms.modules.system.entity.MenuEntity;
import com.xcong.farmer.cms.modules.system.entity.RoleEntity;
import com.xcong.farmer.cms.modules.system.entity.UserEntity;
import com.xcong.farmer.cms.modules.system.entity.*;
import com.xcong.farmer.cms.modules.system.mapper.*;
import com.xcong.farmer.cms.modules.system.service.ICompanyService;
import com.xcong.farmer.cms.modules.system.util.LoginUserUtil;
@@ -25,6 +22,7 @@
import java.util.ArrayList;
import java.util.List;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
@@ -46,6 +44,8 @@
    private MenuMapper menuMapper;
    @Resource
    private UserMapper userMapper;
    @Resource
    private WebSetMapper webSetMapper;
    @Override
    public Result getBelongInPage(AdminBelongDto adminBelongDto) {
@@ -54,10 +54,10 @@
        Page<AdminCompanyVo> page = new Page<>(adminBelongDto.getPageNum(), adminBelongDto.getPageSize());
        CompanyEntity companyEntity = new CompanyEntity();
        String name = adminBelongDto.getName();
        if(StrUtil.isNotEmpty(name)){
        if (StrUtil.isNotEmpty(name)) {
            companyEntity.setName(name);
        }
        if(belongId != UserEntity.USER_BELONG_TOP){
        if (belongId != UserEntity.USER_BELONG_TOP) {
            companyEntity.setId(belongId);
        }
        IPage<AdminCompanyVo> list = this.baseMapper.selectAdminBelongInPage(page, companyEntity);
@@ -70,20 +70,24 @@
        String name = adminAddCompanyDto.getName();
        String code = adminAddCompanyDto.getCode();
        QueryWrapper<CompanyEntity> objectQueryWrapper = new QueryWrapper<>();
        objectQueryWrapper.eq("code",code);
        objectQueryWrapper.eq("code", code);
        List<CompanyEntity> belongEntities = this.baseMapper.selectList(objectQueryWrapper);
        if(CollUtil.isNotEmpty(belongEntities)){
        if (CollUtil.isNotEmpty(belongEntities)) {
            return Result.fail("编码已存在,请重新输入");
        }
        CompanyEntity companyEntity = new CompanyEntity();
        companyEntity.setName(name);
        companyEntity.setCode(code);
        String webAddress = adminAddCompanyDto.getWebAddress();
            companyEntity.setWebAddress(webAddress);
        companyEntity.setWebAddress(webAddress);
        String remark = adminAddCompanyDto.getRemark();
            companyEntity.setRemark(remark);
        companyEntity.setRemark(remark);
        String pic = adminAddCompanyDto.getPic();
            companyEntity.setPic(pic);
        companyEntity.setPic(pic);
        WebSettingEntity webSettingEntity = new WebSettingEntity();
        webSettingEntity.setCompanyId(companyEntity.getId());
        this.webSetMapper.insert(webSettingEntity);
        this.baseMapper.insert(companyEntity);
        return Result.ok("添加成功");
    }
@@ -91,7 +95,7 @@
    @Override
    public Result seeBelongInfo(Long id) {
        CompanyEntity companyEntity = this.baseMapper.selectById(id);
        if(ObjectUtil.isEmpty(companyEntity)){
        if (ObjectUtil.isEmpty(companyEntity)) {
            Result.fail("所属公司不存在");
        }
        AdminSeeCompanyInfoVo adminSeeCompanyInfoVo = new AdminSeeCompanyInfoVo();
@@ -109,17 +113,17 @@
    public Result updateBelong(AdminUpdateCompanyDto adminUpdateCompanyDto) {
        Long id = adminUpdateCompanyDto.getId();
        CompanyEntity companyEntity = this.baseMapper.selectById(id);
        if(ObjectUtil.isEmpty(companyEntity)){
        if (ObjectUtil.isEmpty(companyEntity)) {
            Result.fail("所属公司不存在");
        }
        String name = adminUpdateCompanyDto.getName();
        companyEntity.setName(name);
        String code = adminUpdateCompanyDto.getCode();
        if(!companyEntity.getCode().equals(code)){
        if (!companyEntity.getCode().equals(code)) {
            QueryWrapper<CompanyEntity> objectQueryWrapper = new QueryWrapper<>();
            objectQueryWrapper.eq("code",code);
            objectQueryWrapper.eq("code", code);
            List<CompanyEntity> belongEntities = this.baseMapper.selectList(objectQueryWrapper);
            if(CollUtil.isNotEmpty(belongEntities)){
            if (CollUtil.isNotEmpty(belongEntities)) {
                return Result.fail("编码已存在,请重新输入");
            }
            companyEntity.setCode(code);
@@ -136,13 +140,13 @@
        UserEntity userlogin = LoginUserUtil.getLoginUser();
        Long companyId = userlogin.getCompanyId();
        QueryWrapper<CompanyEntity> objectQueryWrapper = new QueryWrapper<>();
        if(companyId != UserEntity.USER_BELONG_TOP){
            objectQueryWrapper.eq("id",companyId);
        if (companyId != UserEntity.USER_BELONG_TOP) {
            objectQueryWrapper.eq("id", companyId);
        }
        List<CompanyEntity> belongEntities = this.baseMapper.selectList(objectQueryWrapper);
        List<AdminCompanyVo> adminCompanyVos = new ArrayList<>();
        if(CollUtil.isNotEmpty(belongEntities)){
            for(CompanyEntity companyEntity : belongEntities){
        if (CollUtil.isNotEmpty(belongEntities)) {
            for (CompanyEntity companyEntity : belongEntities) {
                AdminCompanyVo adminCompanyVo = new AdminCompanyVo();
                adminCompanyVo.setId(companyEntity.getId());
                adminCompanyVo.setName(companyEntity.getName());
@@ -158,23 +162,23 @@
    public Result delObjs(AdminDeleteDto adminDeleteDto) {
        String ids = adminDeleteDto.getIds();
        UserEntity userlogin = LoginUserUtil.getLoginUser();
        if(userlogin.getCompanyId() != UserEntity.USER_BELONG_TOP){
        if (userlogin.getCompanyId() != UserEntity.USER_BELONG_TOP) {
            return Result.fail("没有删除权限");
        }
        if(StrUtil.isNotEmpty(ids)){
        if (StrUtil.isNotEmpty(ids)) {
            String[] companyIds = ids.split(StringPool.COMMA);
            for(String companyIdStr : companyIds){
            for (String companyIdStr : companyIds) {
                Long companyId = Long.valueOf(companyIdStr);
                QueryWrapper<UserEntity> userQueryWrapper = new QueryWrapper<>();
                userQueryWrapper.eq("company_id",companyId);
                userQueryWrapper.eq("company_id", companyId);
                List<UserEntity> userEntities = userMapper.selectList(userQueryWrapper);
                if(CollUtil.isNotEmpty(userEntities)){
                if (CollUtil.isNotEmpty(userEntities)) {
                    return Result.fail("请先清空属于该公司的用户");
                }
                QueryWrapper<RoleEntity> roleQueryWrapper = new QueryWrapper<>();
                roleQueryWrapper.eq("company_id",companyId);
                roleQueryWrapper.eq("company_id", companyId);
                List<RoleEntity> roleEntities = roleMapper.selectList(roleQueryWrapper);
                if(CollUtil.isNotEmpty(roleEntities)){
                if (CollUtil.isNotEmpty(roleEntities)) {
                    return Result.fail("请先清空属于该公司的角色");
                }
                this.baseMapper.deleteById(companyId);