修改公司信息

master
bynt 3 years ago
parent f3b73ddde8
commit 1c782c7fbb

@ -19,6 +19,7 @@ import com.baiye.exception.BadRequestException;
import com.baiye.feign.RemoteUserService; import com.baiye.feign.RemoteUserService;
import com.baiye.model.dto.JwtUserDto; import com.baiye.model.dto.JwtUserDto;
import com.baiye.model.dto.UserDto; import com.baiye.model.dto.UserDto;
import com.baiye.model.enums.ResponseCode;
import com.baiye.properties.bean.LoginProperties; import com.baiye.properties.bean.LoginProperties;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority;
@ -65,12 +66,12 @@ public class UserDetailsServiceImpl implements UserDetailsService {
UserDto user; UserDto user;
try { try {
user = remoteUserService.findByName(username); user = remoteUserService.findByName(username);
} catch (EntityNotFoundException e) { } catch (BadRequestException e) {
// SpringSecurity会自动转换UsernameNotFoundException为BadCredentialsException // SpringSecurity会自动转换UsernameNotFoundException为BadCredentialsException
throw new BadRequestException("用户名或密码不正确"); throw new BadRequestException(ResponseCode.WRONG_USER_NAME_PASSWORD.getDesc());
} }
if (user == null) { if (user == null) {
throw new BadRequestException("用户名或密码不正确!"); throw new BadRequestException(ResponseCode.WRONG_USER_NAME_PASSWORD.getDesc());
} else { } else {
if (Boolean.FALSE.equals(user.getEnabled())) { if (Boolean.FALSE.equals(user.getEnabled())) {
throw new BadRequestException("账号未激活!"); throw new BadRequestException("账号未激活!");

@ -27,6 +27,15 @@ public enum ResponseCode {
*/ */
CALL_ERROR("1014", "呼叫失败"), CALL_ERROR("1014", "呼叫失败"),
/**
* axb
*/
AXB_CONFIGURATION_ERROR("1015", "axb参数配置错误"),
/**
* axb
*/
WRONG_USER_NAME_PASSWORD("1016", "用户名或密码不正确"),
DECRYPTION_FAILED("1012", "数据解析失败"); DECRYPTION_FAILED("1012", "数据解析失败");

@ -84,6 +84,4 @@ public class Company extends BaseEntity implements Serializable {
@ApiModelProperty("axb请求字段") @ApiModelProperty("axb请求字段")
@Column(name = "tel_x") @Column(name = "tel_x")
private String telX; private String telX;
} }

@ -25,9 +25,16 @@ public class CompanyController {
private final CompanyService companyService; private final CompanyService companyService;
@ApiOperation("修改公司") @ApiOperation("用户修改公司信息")
@PostMapping("/userUpdateCompany")
public ResponseEntity<Object> userUpdateCompany(@Validated @RequestBody CompanyDto companyDto) throws Exception {
companyService.userUpdateCompany(companyDto);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@ApiOperation("管理员修改公司")
@PostMapping("/updateCompany") @PostMapping("/updateCompany")
public ResponseEntity<Object> create(@Validated @RequestBody CompanyDto companyDto) throws Exception { public ResponseEntity<Object> updateCompany(@Validated @RequestBody CompanyDto companyDto) {
companyService.updateCompany(companyDto); companyService.updateCompany(companyDto);
return new ResponseEntity<>(HttpStatus.CREATED); return new ResponseEntity<>(HttpStatus.CREATED);
} }

@ -17,7 +17,7 @@ public interface CompanyService {
* @param companyDto * @param companyDto
* @return CompanyDto * @return CompanyDto
*/ */
CompanyDto updateCompany(CompanyDto companyDto) throws Exception; CompanyDto userUpdateCompany(CompanyDto companyDto) throws Exception;
/** /**
* *
@ -49,9 +49,12 @@ public interface CompanyService {
CompanyDto createCompany(CompanyDto companyDto); CompanyDto createCompany(CompanyDto companyDto);
/** /**
* *
* @param status * @param status
* @param id * @param id
*/ */
void updateCompanyStatus(Integer status, Long id); void updateCompanyStatus(Integer status, Long id);
void updateCompany(CompanyDto companyDto);
} }

@ -21,6 +21,7 @@ import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import javax.persistence.Column;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import java.io.Serializable; import java.io.Serializable;
@ -38,15 +39,33 @@ public class CompanyDto extends BaseDTO implements Serializable {
private Long id; private Long id;
private Long userId;
@ApiModelProperty("axb请求字段")
private String xGroup;
@ApiModelProperty("axb请求字段")
private String axbGroup;
@ApiModelProperty("axb请求字段")
private String telX;
@ApiModelProperty("公司状态 1正常 0审核中 -1 未通过")
private Integer status;
@NotBlank @NotBlank
@ApiModelProperty("公司名称")
private String companyName; private String companyName;
@ApiModelProperty("公司编码")
private String companyCode; private String companyCode;
@ApiModelProperty("营业执照") @ApiModelProperty("营业执照")
private String businessLicense; private String businessLicense;
@ApiModelProperty("邀请码")
private Integer invitationCode;
@ApiModelProperty("法人身份证") @ApiModelProperty("法人身份证")
private String legalPersonIdFront; private String legalPersonIdFront;
@ -60,12 +79,6 @@ public class CompanyDto extends BaseDTO implements Serializable {
private String managerIdReverse; private String managerIdReverse;
@ApiModelProperty("公司状态 1正常 0审核中 -1 未通过")
private Integer status;
private Long userId;
private Integer invitationCode;
} }

@ -9,7 +9,6 @@ import com.baiye.modules.security.service.OnlineUserService;
import com.baiye.modules.system.domain.Company; import com.baiye.modules.system.domain.Company;
import com.baiye.modules.system.repository.CompanyRepository; import com.baiye.modules.system.repository.CompanyRepository;
import com.baiye.modules.system.repository.UserRepository; import com.baiye.modules.system.repository.UserRepository;
import com.baiye.modules.system.service.AgentService; import com.baiye.modules.system.service.AgentService;
import com.baiye.modules.system.service.CompanyService; import com.baiye.modules.system.service.CompanyService;
import com.baiye.modules.system.service.dto.CompanyDto; import com.baiye.modules.system.service.dto.CompanyDto;
@ -19,7 +18,6 @@ import com.baiye.util.PageUtil;
import com.baiye.util.QueryHelp; import com.baiye.util.QueryHelp;
import com.baiye.util.SecurityUtils; import com.baiye.util.SecurityUtils;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
@ -50,7 +48,7 @@ public class CompanyServiceImpl implements CompanyService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public CompanyDto updateCompany(CompanyDto companyDto) throws Exception { public CompanyDto userUpdateCompany(CompanyDto companyDto) throws Exception {
Long companyId = SecurityUtils.getCompanyId(); Long companyId = SecurityUtils.getCompanyId();
if (companyId != null) { if (companyId != null) {
Company byUserId = companyRepository.findById(companyId).orElseGet(Company::new); Company byUserId = companyRepository.findById(companyId).orElseGet(Company::new);
@ -86,7 +84,7 @@ public class CompanyServiceImpl implements CompanyService {
} }
@Override @Override
@Cacheable(cacheNames = "companyCache",key = "#companyId") @Cacheable(cacheNames = "companyCache", key = "#companyId")
public Company findById(Long companyId) { public Company findById(Long companyId) {
return companyRepository.findById(companyId).orElseGet(Company::new); return companyRepository.findById(companyId).orElseGet(Company::new);
} }
@ -112,4 +110,19 @@ public class CompanyServiceImpl implements CompanyService {
} }
companyRepository.updateCompanyStatus(id, status); companyRepository.updateCompanyStatus(id, status);
} }
@Override
public void updateCompany(CompanyDto companyDto) {
Long id = companyDto.getId();
if (id != null) {
Company byUserId = companyRepository.findById(id).orElseGet(Company::new);
if (byUserId == null) {
throw new EntityExistException
(Company.class, "companyName", companyDto.getCompanyName());
}
BeanUtil.copyProperties(companyDto, byUserId);
byUserId.setXGroup(companyDto.getAxbGroup());
companyRepository.save(byUserId);
}
}
} }

@ -18,26 +18,21 @@ package com.baiye.modules.system.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.text.StrPool; import cn.hutool.core.text.StrPool;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.EasyExcelFactory; import com.alibaba.excel.EasyExcelFactory;
import com.baiye.config.properties.FileProperties; import com.baiye.config.properties.FileProperties;
import com.baiye.constant.DefaultNumberConstants; import com.baiye.constant.DefaultNumberConstants;
import com.baiye.exception.BadRequestException; import com.baiye.exception.BadRequestException;
import com.baiye.exception.EntityExistException; import com.baiye.exception.EntityExistException;
import com.baiye.exception.EntityNotFoundException;
import com.baiye.model.dto.TreeUserDTO; import com.baiye.model.dto.TreeUserDTO;
import com.baiye.model.dto.UserDto; import com.baiye.model.dto.UserDto;
import com.baiye.model.dto.UserFavorOfExcel; import com.baiye.model.dto.UserFavorOfExcel;
import com.baiye.modules.security.service.OnlineUserService; import com.baiye.modules.security.service.OnlineUserService;
import com.baiye.modules.system.domain.Company; import com.baiye.modules.system.domain.Company;
import com.baiye.modules.system.domain.OrganizeUser; import com.baiye.modules.system.domain.OrganizeUser;
import com.baiye.modules.system.repository.OrganizeUserRepository;
import com.baiye.modules.system.service.CompanyService;
import com.baiye.service.UserCacheClean;
import com.baiye.modules.system.domain.Role; import com.baiye.modules.system.domain.Role;
import com.baiye.modules.system.domain.User; import com.baiye.modules.system.domain.User;
import com.baiye.modules.system.repository.OrganizeUserRepository;
import com.baiye.modules.system.repository.RoleRepository; import com.baiye.modules.system.repository.RoleRepository;
import com.baiye.modules.system.repository.UserRepository; import com.baiye.modules.system.repository.UserRepository;
import com.baiye.modules.system.service.CompanyService; import com.baiye.modules.system.service.CompanyService;
@ -52,8 +47,6 @@ import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -315,7 +308,7 @@ public class UserServiceImpl implements UserService {
} }
return convert; return convert;
} }
throw new UsernameNotFoundException("user not found"); return null;
} }
@Override @Override

@ -4,7 +4,9 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.baiye.constant.DefaultNumberConstants; import com.baiye.constant.DefaultNumberConstants;
import com.baiye.exception.BadRequestException;
import com.baiye.http.CommonResponse; import com.baiye.http.CommonResponse;
import com.baiye.model.enums.ResponseCode;
import com.baiye.modules.system.domain.Company; import com.baiye.modules.system.domain.Company;
import com.baiye.modules.system.domain.Organize; import com.baiye.modules.system.domain.Organize;
import com.baiye.modules.system.service.CompanyService; import com.baiye.modules.system.service.CompanyService;
@ -16,9 +18,9 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import springfox.documentation.spring.web.json.Json;
/** /**
* @author wjt * @author wjt
@ -50,13 +52,16 @@ public class TelephoneCallController {
Company byId = companyService.findById(SecurityUtils.getCompanyId()); Company byId = companyService.findById(SecurityUtils.getCompanyId());
if (organize != null && byId != null) { if (organize != null && byId != null) {
telephoneCallReqDTO.setCompanyName(byId.getCompanyName()); telephoneCallReqDTO.setCompanyName(byId.getCompanyName());
telephoneCallReqDTO.setXGroup(byId.getXGroup());
if (organize.getCallMode() != null) { if (organize.getCallMode() != null) {
switch (organize.getCallMode()) { switch (organize.getCallMode()) {
case DefaultNumberConstants.ZERO_NUMBER: case DefaultNumberConstants.ZERO_NUMBER:
return telephoneCallService.doubleCallReq(telephoneCallReqDTO); return telephoneCallService.doubleCallReq(telephoneCallReqDTO);
case DefaultNumberConstants.TWO_NUMBER: case DefaultNumberConstants.TWO_NUMBER:
if (StringUtils.isBlank(byId.getXGroup()) || StringUtils.isBlank(byId.getTelX())) {
throw new BadRequestException(ResponseCode.AXB_CONFIGURATION_ERROR.getDesc());
}
telephoneCallReqDTO.setTelX(byId.getTelX());
telephoneCallReqDTO.setXGroup(byId.getXGroup());
return telephoneCallService.axbDialNumber(telephoneCallReqDTO); return telephoneCallService.axbDialNumber(telephoneCallReqDTO);
case DefaultNumberConstants.ONE_NUMBER: case DefaultNumberConstants.ONE_NUMBER:
return telephoneCallService.rollCallReq(telephoneCallReqDTO); return telephoneCallService.rollCallReq(telephoneCallReqDTO);

@ -25,6 +25,10 @@ public class TelephoneCallReqDTO implements Serializable {
@NotNull @NotNull
private String telB; private String telB;
@ApiModelProperty("telX")
private String telX;
private String requestId; private String requestId;
@ApiModelProperty("具体线索id") @ApiModelProperty("具体线索id")

@ -30,6 +30,7 @@ public class AxbRequest {
public String call(TelephoneCallReqDTO telephoneCallReqDTO) { public String call(TelephoneCallReqDTO telephoneCallReqDTO) {
AxbCallRequestDTO axbCallRequestDTO = new AxbCallRequestDTO(); AxbCallRequestDTO axbCallRequestDTO = new AxbCallRequestDTO();
BeanUtil.copyProperties(telephoneCallReqDTO, axbCallRequestDTO); BeanUtil.copyProperties(telephoneCallReqDTO, axbCallRequestDTO);
axbCallRequestDTO.setTelX(telephoneCallReqDTO.getTelX());
axbCallRequestDTO.setAppid(axbProperties.getAppid()); axbCallRequestDTO.setAppid(axbProperties.getAppid());
axbCallRequestDTO.setXGroup(telephoneCallReqDTO.getXGroup()); axbCallRequestDTO.setXGroup(telephoneCallReqDTO.getXGroup());
axbCallRequestDTO.setCdrUrl(axbProperties.getCdrUrl()); axbCallRequestDTO.setCdrUrl(axbProperties.getCdrUrl());

@ -9,7 +9,7 @@ spring:
freemarker: freemarker:
check-template-location: false check-template-location: false
profiles: profiles:
active: prod active: dev
jackson: jackson:
time-zone: GMT+8 time-zone: GMT+8
data: data:

@ -6,7 +6,7 @@ spring:
freemarker: freemarker:
check-template-location: false check-template-location: false
profiles: profiles:
active: prod active: dev
application: application:
name: @artifactId@ name: @artifactId@
jackson: jackson:

Loading…
Cancel
Save