ww
chengqf 2 years ago
parent f8051c6c3d
commit 1eef2dbd71

@ -0,0 +1,117 @@
package com.glxp.api.controller.sup;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import javax.validation.Valid;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.controller.BaseController;
import com.glxp.api.entity.sup.UserCertEntity;
import com.glxp.api.entity.sup.UserPersonEntity;
import com.glxp.api.entity.sup.UserRegisterEntity;
import com.glxp.api.service.sup.UserCertService;
import com.glxp.api.service.sup.UserPersonService;
import com.glxp.api.service.sup.UserRegisterService;
import com.glxp.api.util.CaptchaUtils;
import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
@RestController
@Slf4j
public class UserRegisterController extends BaseController {
private static final Logger logger = LoggerFactory.getLogger(UserRegisterController.class);
@Resource
private UserRegisterService userRegisterService;
@Resource
private UserPersonService userPersonService;
@Resource
private UserCertService userCertService;
@PostMapping("/admin/auth/register/getCheckcode")
public BaseResponse getCheckcode(@RequestBody Map<String,Object> params, HttpSession httpSession) {
return CaptchaUtils.getCheckcode(params,httpSession);
}
@PostMapping("/admin/auth/register/checkCode")
public BaseResponse checkCode(@RequestBody Map<String,Object> params) {
return CaptchaUtils.checkCode(params);
}
/**
*
*
* @param mobile
*/
@GetMapping("/admin/auth/register/get/{mobile}")
public BaseResponse getInfo(@PathVariable String mobile) {
UserRegisterEntity userRegisterEntity = userRegisterService.getOne(new QueryWrapper<UserRegisterEntity>().eq("mobile", mobile));
if(userRegisterEntity==null) {
userRegisterEntity = new UserRegisterEntity();
} else {
List<UserPersonEntity> userPersons = userPersonService.list(new QueryWrapper<UserPersonEntity>().eq("registerId", userRegisterEntity.getId()));
userRegisterEntity.setUserPersons(userPersons);
List<UserCertEntity> userCerts = userCertService.list(new QueryWrapper<UserCertEntity>().eq("registerId", userRegisterEntity.getId()));
userRegisterEntity.setUserCerts(userCerts);
}
return ResultVOUtils.success(userRegisterEntity);
}
@PostMapping("/admin/auth/register/save")
public BaseResponse saveRegister(@RequestBody @Valid UserRegisterEntity userRegisterEntity, HttpSession httpSession,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
//校验邮箱是否正确
if (StrUtil.isNotBlank(userRegisterEntity.getEmail())) {
boolean match = ReUtil.isMatch("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$", userRegisterEntity.getEmail());
if (!match) {
return ResultVOUtils.error(500, "邮箱格式错误");
}
}
UserRegisterEntity userRegisterEntity2 = userRegisterService.getOne(new QueryWrapper<UserRegisterEntity>().eq("companyName", userRegisterEntity.getCompanyName()));
if (userRegisterEntity2 !=null ) {
if(userRegisterEntity.getId()==null)
return ResultVOUtils.error(500, "该单位已被注册!");
if(userRegisterEntity2.getId()!=userRegisterEntity.getId())
return ResultVOUtils.error(500, "该单位已被注册!");
}
if(StringUtils.isEmpty(userRegisterEntity.getCheckStatus()))
userRegisterEntity.setCheckStatus("0");
boolean b = false;
b = userRegisterService.saveOrUpdate(userRegisterEntity);
if (!b) {
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
}
return ResultVOUtils.success();
}
@GetMapping("/admin/auth/register/list")
public BaseResponse list(@RequestBody Map<String,Object> params, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
return ResultVOUtils.success(userRegisterService.list(new QueryWrapper<UserRegisterEntity>().allEq(params)));
}
}

@ -1,11 +1,14 @@
package com.glxp.api.entity.sup;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
@Data
@ -110,5 +113,9 @@ public class UserRegisterEntity implements Serializable {
@TableField(value = "checkTime")
private Date checkTime;
//负责人列表
private List<UserPersonEntity> userPersons;
//证书列表
private List<UserCertEntity> userCerts;
private static final long serialVersionUID = 1L;
}

Loading…
Cancel
Save