修改新增人员问题

master
bynt 3 years ago
parent bff017eb58
commit 796dfe0fa2

@ -27,8 +27,11 @@ public class CompanyController {
@ApiOperation("用户修改公司信息")
@PostMapping("/userUpdateCompany")
public ResponseEntity<Object> userUpdateCompany(@Validated @RequestBody CompanyDto companyDto) throws Exception {
companyService.userUpdateCompany(companyDto);
public ResponseEntity<Object> userUpdateCompany(@Validated @RequestBody CompanyDto companyDto) {
Long companyId = SecurityUtils.getCompanyId();
if (companyId != null){
companyService.userUpdateCompany(companyDto, companyId);
}
return new ResponseEntity<>(HttpStatus.CREATED);
}

@ -15,9 +15,10 @@ public interface CompanyService {
/**
*
* @param companyDto
* @param companyId
* @return CompanyDto
*/
CompanyDto userUpdateCompany(CompanyDto companyDto) throws Exception;
CompanyDto userUpdateCompany(CompanyDto companyDto, Long companyId) ;
/**
*

@ -4,7 +4,6 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.exception.EntityExistException;
import com.baiye.model.enums.ResponseCode;
import com.baiye.modules.security.service.OnlineUserService;
import com.baiye.modules.system.domain.Company;
import com.baiye.modules.system.repository.CompanyRepository;
@ -18,6 +17,8 @@ import com.baiye.util.PageUtil;
import com.baiye.util.QueryHelp;
import com.baiye.util.SecurityUtils;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@ -47,28 +48,26 @@ public class CompanyServiceImpl implements CompanyService {
@Override
@SneakyThrows
@Transactional(rollbackFor = Exception.class)
public CompanyDto userUpdateCompany(CompanyDto companyDto) throws Exception {
Long companyId = SecurityUtils.getCompanyId();
if (companyId != null) {
Company byUserId = companyRepository.findById(companyId).orElseGet(Company::new);
if (byUserId == null) {
throw new EntityExistException(Company.class, "companyName", companyDto.getCompanyName());
}
Integer invitationCode = companyDto.getInvitationCode();
if (invitationCode != null) {
agentService.updateAgentNums(invitationCode);
}
companyDto.setId(byUserId.getId());
companyDto.setUserId(SecurityUtils.getCurrentUserId());
companyDto.setStatus(DefaultNumberConstants.ZERO_NUMBER);
BeanUtil.copyProperties(companyDto, byUserId);
byUserId.setApplicationTime(DateUtil.date());
userRepository.updateStatusById(Boolean.FALSE, SecurityUtils.getCurrentUserId());
onlineUserService.kickOutForUsername(SecurityUtils.getCurrentUsername());
return companyMapper.toDto(companyRepository.save(byUserId));
@CacheEvict(cacheNames = "companyCache", key = "#companyId")
public CompanyDto userUpdateCompany(CompanyDto companyDto, Long companyId) {
Company byUserId = companyRepository.findById(companyId).orElseGet(Company::new);
if (byUserId == null) {
throw new EntityExistException(Company.class, "companyName", companyDto.getCompanyName());
}
Integer invitationCode = companyDto.getInvitationCode();
if (invitationCode != null) {
agentService.updateAgentNums(invitationCode);
}
throw new EntityExistException(Long.class, "companyId", ResponseCode.USER_INFORMATION_ERROR.getDesc());
companyDto.setId(byUserId.getId());
companyDto.setUserId(SecurityUtils.getCurrentUserId());
companyDto.setStatus(DefaultNumberConstants.ZERO_NUMBER);
BeanUtil.copyProperties(companyDto, byUserId);
byUserId.setApplicationTime(DateUtil.date());
userRepository.updateStatusById(Boolean.FALSE, SecurityUtils.getCurrentUserId());
onlineUserService.kickOutForUsername(SecurityUtils.getCurrentUsername());
return companyMapper.toDto(companyRepository.save(byUserId));
}
@Override

@ -1,6 +1,6 @@
spring:
application:
name: ad-platform-service-jt
name: @artifactId@
profiles:
active: dev
server:

@ -214,9 +214,9 @@ public class ClueServiceImpl implements ClueService {
@Transactional(rollbackFor = Exception.class)
public void update(ClueMiddle clueMiddle) {
//乐观锁,不用jpa查询(jpa有缓存这个坑)
if (clueMiddle.getOptimisticVersion() != null){
if (clueMiddle.getOptimisticVersion() != null) {
Integer version = clueMiddleRepository.lookUpOptimisticVersion(clueMiddle.getClueId());
if (version != clueMiddle.getOptimisticVersion()){
if (version != clueMiddle.getOptimisticVersion()) {
throw new BadRequestException("刷新后重试");
}
}
@ -279,7 +279,7 @@ public class ClueServiceImpl implements ClueService {
@Override
public Boolean judgeMember(Long memberId) {
Long clueId = clueMiddleRepository.judgeMember(memberId);
if (clueId != null){
if (clueId != null) {
return true;
}
return false;
@ -295,9 +295,9 @@ public class ClueServiceImpl implements ClueService {
Long taskId = baseExcelVo.getTaskId();
Long userId = baseExcelVo.getUserId();
Integer taskNum = clueMiddleRepository.findTaskNum(taskId);
if (taskNum == null || taskNum == 0){
taskClient.sendErrMessage("导入资源合规条数0条,请检查文件重新导入",userId);
log.info("=======================导入资源合规条数为0条,请检查文件重新导入==============================");
if (taskNum == null || taskNum == 0) {
taskClient.sendErrMessage("导入资源合规条数0条,请检查文件重新导入", userId);
throw new BadRequestException("导入资源合规条数为0条,请检查文件重新导入");
}
int lastIndexOf = oneFileName.lastIndexOf(".");
String nameStr = oneFileName.substring(0, lastIndexOf);

Loading…
Cancel
Save