| | |
| | | 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; |
| | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | |
| | | private MenuMapper menuMapper; |
| | | @Resource |
| | | private UserMapper userMapper; |
| | | @Resource |
| | | private WebSetMapper webSetMapper; |
| | | |
| | | @Override |
| | | public Result getBelongInPage(AdminBelongDto adminBelongDto) { |
| | |
| | | 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); |
| | |
| | | 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("添加成功"); |
| | | } |
| | |
| | | @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(); |
| | |
| | | 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); |
| | |
| | | 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()); |
| | |
| | | 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); |