You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
125 lines
5.7 KiB
Java
125 lines
5.7 KiB
Java
package com.glxp.api.controller.purchase;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.glxp.api.common.enums.ResultEnum;
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
import com.glxp.api.entity.sup.UserPersonEntity;
|
|
import com.glxp.api.exception.JsonException;
|
|
import com.glxp.api.req.auth.UserPersonFilterRequest;
|
|
import com.glxp.api.res.PageSimpleResponse;
|
|
import com.glxp.api.service.sup.UserPersonService;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.validation.BindingResult;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.context.request.RequestContextHolder;
|
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* @author : zhangsan
|
|
* @date : 2023/5/18 9:38
|
|
* @modyified By :
|
|
*/
|
|
@Api(tags = "用户个人相关接口")
|
|
@RestController
|
|
public class userPersonController {
|
|
@Resource
|
|
private UserPersonService userPersonService;
|
|
|
|
@ApiOperation(value = "获取用户个人信息", response = UserPersonEntity.class)
|
|
@GetMapping("/sup/company/person/filterList")
|
|
public BaseResponse filterCompanyCert(UserPersonFilterRequest userPersonFilterRequest, BindingResult bindingResult) {
|
|
|
|
System.out.println(userPersonFilterRequest.toString());
|
|
if (bindingResult.hasErrors()) {
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
}
|
|
if (StrUtil.isBlank(userPersonFilterRequest.getCompanyId())) {
|
|
userPersonFilterRequest.setCompanyId(getCompanyId());
|
|
}
|
|
QueryWrapper<UserPersonEntity> and;
|
|
if (StrUtil.isNotBlank(userPersonFilterRequest.getUserName())) {
|
|
and = new QueryWrapper<UserPersonEntity>().like("userName", userPersonFilterRequest.getUserName()).and(i -> i.eq("companyId", userPersonFilterRequest.getCompanyId()));
|
|
} else {
|
|
and = new QueryWrapper<UserPersonEntity>().eq("companyId", userPersonFilterRequest.getCompanyId());
|
|
}
|
|
List<UserPersonEntity> list = userPersonService.list(and);
|
|
PageInfo<UserPersonEntity> pageInfo;
|
|
pageInfo = new PageInfo<>(list);
|
|
PageSimpleResponse<UserPersonEntity> pageSimpleResponse = new PageSimpleResponse<>();
|
|
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
|
pageSimpleResponse.setList(list);
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
}
|
|
|
|
@ApiOperation(value = "更新企业负责人信息", response = BaseResponse.class)
|
|
@PostMapping("/sup/company/person/updatePerSon")
|
|
public BaseResponse updatePerSon(@RequestBody UserPersonFilterRequest userPersonFilterRequest, BindingResult bindingResult) {
|
|
if (bindingResult.hasErrors()) {
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
}
|
|
|
|
UserPersonEntity userPerson = new UserPersonEntity();
|
|
BeanUtils.copyProperties(userPersonFilterRequest, userPerson);
|
|
userPerson.setPassword(userPersonFilterRequest.getCheckPassword());
|
|
userPersonService.update(userPerson);
|
|
|
|
return ResultVOUtils.success();
|
|
}
|
|
|
|
@ApiOperation(value = "删除企业负责人信息", response = BaseResponse.class)
|
|
@PostMapping("/sup/company/person/daletePerSon")
|
|
public BaseResponse daletePerSon(@RequestBody UserPersonFilterRequest userPersonFilterRequest, BindingResult bindingResult) {
|
|
if (bindingResult.hasErrors()) {
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
}
|
|
|
|
UserPersonEntity userPerson = new UserPersonEntity();
|
|
BeanUtils.copyProperties(userPersonFilterRequest, userPerson);
|
|
userPersonService.delete(userPerson);
|
|
|
|
return ResultVOUtils.success();
|
|
}
|
|
|
|
@ApiOperation(value = "新增本企业负责人信息", response = BaseResponse.class)
|
|
@PostMapping("/sup/company/person/addPerSon")
|
|
public BaseResponse addPerSon(@RequestBody UserPersonFilterRequest userPersonFilterRequest, BindingResult bindingResult) {
|
|
if (bindingResult.hasErrors()) {
|
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
|
}
|
|
UserPersonEntity userPerson = new UserPersonEntity();
|
|
BeanUtils.copyProperties(userPersonFilterRequest, userPerson);
|
|
userPerson.setPassword(userPersonFilterRequest.getCheckPassword());
|
|
//userPerson.setCompanyId(Long.valueOf(userPersonFilterRequest.getCompanyId()));
|
|
// userPerson.setId(Long.valueOf(Long.parseLong(userPersonFilterRequest.getCompanyId())));
|
|
userPerson.setCreateTime(new Date());
|
|
userPerson.setCompanyId(Long.valueOf(getCompanyId()));
|
|
userPersonService.add(userPerson);
|
|
return ResultVOUtils.success();
|
|
}
|
|
|
|
public String getCompanyId() {
|
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
|
if (attributes == null) {
|
|
throw new JsonException(ResultEnum.NOT_NETWORK);
|
|
}
|
|
HttpServletRequest request = attributes.getRequest();
|
|
String companyId = request.getHeader("companyId");
|
|
return companyId;
|
|
}
|
|
|
|
|
|
}
|