| | |
| | | SysCompany add = Convert.convert(SysCompany.class, bo); |
| | | validEntityBeforeSave(add); |
| | | boolean save = this.save(add); |
| | | addCompanyUser(add); |
| | | addCompanyUser(add, 0); |
| | | return save; |
| | | } |
| | | |
| | |
| | | if (!delUser) { |
| | | throw new BaseException("原企业用户清除失败,请联系管理员!"); |
| | | } |
| | | this.addCompanyUser(update); |
| | | this.addCompanyUser(update, 0); |
| | | } |
| | | validEntityBeforeSave(update); |
| | | return this.updateById(update); |
| | | } |
| | | |
| | | @Override//状态开关 |
| | | @Transactional |
| | | public Boolean updStatus(SysCompanyBo bo) |
| | | { |
| | | if (bo.getCompanyId()==null || bo.getCompanyStatus()==null) { |
| | | throw new BaseException("参数有误,状态修改失败!"); |
| | | } |
| | | SysCompany company = this.getById(bo.getCompanyId()); |
| | | company.setCompanyStatus(bo.getCompanyStatus()); |
| | | updCompanyUserStatus(company.getCompanyPhone(), bo.getCompanyStatus()); |
| | | return this.updateById(company); |
| | | } |
| | | |
| | | @Override//删除 |
| | |
| | | }); |
| | | List<SysCompany> companies = Convert.toList(SysCompany.class, resultVo.getVoList()); |
| | | boolean b = this.saveOrUpdateBatch(companies); |
| | | companies.forEach(this::addCompanyUser); |
| | | for (SysCompany company : companies) { |
| | | addCompanyUser(company,1); |
| | | } |
| | | return b; |
| | | } |
| | | |
| | |
| | | * @param entity 企业信息 |
| | | */ |
| | | @Async |
| | | protected void addCompanyUser(SysCompany entity) |
| | | protected void addCompanyUser(SysCompany entity, Integer isImport) |
| | | { |
| | | |
| | | SysUser user = new SysUser(); |
| | | if (isImport==1){ |
| | | user.setStatus("0"); |
| | | } else { |
| | | user.setStatus("1"); |
| | | } |
| | | SysCompany one = this.getOne(lq().eq(SysCompany::getCompanyCode, entity.getCompanyCode())); |
| | | String phone = entity.getCompanyPhone(); |
| | | user.setPhonenumber(phone); |
| | |
| | | userService.insertUser(user); |
| | | } |
| | | |
| | | @Async |
| | | protected void updCompanyUserStatus(String phone, Integer status) |
| | | { |
| | | userService.update(userService.lu().set(SysUser::getStatus,status).eq(SysUser::getPhonenumber, phone)); |
| | | } |
| | | |
| | | /** |
| | | * 删除企业用户 |
| | | * @param companyId 企业id |