mitao
2025-01-21 de8b6e50653a9b774d1512e55a94d7b2084f0566
ruoyi-modules/ruoyi-company/src/main/java/com/ruoyi/company/service/impl/CompanyServiceImpl.java
@@ -34,9 +34,11 @@
public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> implements CompanyService {
    private final UserService userService;
    private final HttpServletResponse response;
    private final AliyunCloudAuthUtil aliyunCloudAuthUtil;
    /**
     * 获取企业列表
     *
     * @param query
     * @return
     */
@@ -65,6 +67,7 @@
    /**
     * 获取企业详情
     *
     * @param id
     * @return
     */
@@ -86,6 +89,7 @@
    /**
     * 新增企业
     *
     * @param dto
     * @return
     */
@@ -118,11 +122,12 @@
    /**
     * 编辑企业
     *
     * @param dto
     */
    @Override
    public void editCompany(MgtCompanyDTO dto) {
        if (Objects.isNull(dto.getId())){
        if (Objects.isNull(dto.getId())) {
            throw new ServiceException("企业id不能为空");
        }
        //查询企业
@@ -141,12 +146,14 @@
        }
        //用户信息
        User userUpd = BeanUtils.copyBean(dto, User.class);
        userUpd.setPassword(SecurityUtils.encryptPassword(dto.getPassword()));
        if (StringUtils.isNotBlank(dto.getPassword())) {
            userUpd.setPassword(SecurityUtils.encryptPassword(dto.getPassword()));
        }
        userUpd.setUserId(user.getUserId());
        userUpd.setUpdateBy(SecurityUtils.getUserId());
        userService.updateById(userUpd);
        //根据公司名称查询数据库
        Long count = this.lambdaQuery().ne(Company::getId,dto.getId()).eq(Company::getCompanyName, company.getCompanyName()).count();
        Long count = this.lambdaQuery().ne(Company::getId, dto.getId()).eq(Company::getCompanyName, company.getCompanyName()).count();
        if (count > 0) {
            throw new ServiceException("该公司账号已存在");
        }
@@ -162,6 +169,7 @@
    /**
     * 删除企业
     *
     * @param id
     */
    @Override
@@ -172,7 +180,7 @@
            throw new ServiceException("删除失败,该企业不存在");
        }
        //删除企业账号
         userService.removeById(company.getUserId());
        userService.removeById(company.getUserId());
        //删除企业信息
        this.removeById(id);