企业端用户人员新增
登陆接口调整
This commit is contained in:
parent
1fc3871eaa
commit
637a2ce55f
|
|
@ -42,4 +42,21 @@ public interface EntUserMapper extends BaseMapper<EntUser> {
|
|||
* @return int 成功或失败
|
||||
* */
|
||||
int updateEntUser(@Param("entUser") EntUser entUser);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 验证用户电话和名字
|
||||
* @param mobile 电话
|
||||
* @return int 成功或失败
|
||||
* */
|
||||
EntUser validMobile(@Param("mobile") String mobile);
|
||||
|
||||
/**
|
||||
* 验证用户电话和名字
|
||||
* @param name 名字
|
||||
* @return int 成功或失败
|
||||
* */
|
||||
EntUser validName(@Param("name")String name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModelProperty;
|
|||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 企业用户新增和修改Dto
|
||||
|
|
@ -45,9 +46,32 @@ public class AddOrUpdateEntUserDto {
|
|||
private Date workTime;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "从业时间")
|
||||
@ApiModelProperty(value = "工号")
|
||||
private String jobNumber;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "企业用户ID")
|
||||
private String EntUserId;
|
||||
|
||||
@ApiModelProperty(value = "List证件对象")
|
||||
private List<EntUserCredentialUpdateDto> entUserCredentialUpdateDtos;
|
||||
|
||||
public List<EntUserCredentialUpdateDto> getEntUserCredentialUpdateDtos() {
|
||||
return entUserCredentialUpdateDtos;
|
||||
}
|
||||
|
||||
public void setEntUserCredentialUpdateDtos(List<EntUserCredentialUpdateDto> entUserCredentialUpdateDtos) {
|
||||
this.entUserCredentialUpdateDtos = entUserCredentialUpdateDtos;
|
||||
}
|
||||
|
||||
public String getEntUserId() {
|
||||
return EntUserId;
|
||||
}
|
||||
|
||||
public void setEntUserId(String entUserId) {
|
||||
EntUserId = entUserId;
|
||||
}
|
||||
|
||||
public String getPostId() {
|
||||
return postId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,6 +107,17 @@ public class EntUser implements Serializable {
|
|||
@TableField(exist = false)
|
||||
private double entUserTaskPercent;
|
||||
|
||||
@ApiModelProperty(value = "工号")
|
||||
private String jobNumber;
|
||||
|
||||
public String getJobNumber() {
|
||||
return jobNumber;
|
||||
}
|
||||
|
||||
public void setJobNumber(String jobNumber) {
|
||||
this.jobNumber = jobNumber;
|
||||
}
|
||||
|
||||
public double getEntUserTaskPercent() {
|
||||
return entUserTaskPercent;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,10 +69,30 @@
|
|||
</select>
|
||||
|
||||
<update id="updateEntUser" parameterType="com.rzyc.model.ent.EntUser">
|
||||
update ent_user (post_id,enterprise_id,name,mobile,user_type,age,work_time,passwd,post_path,post_path_name,job_number,modify_time,modify_by)
|
||||
values(entUser.postId,entUser.enterpriseId,entUser.name,entUser.mobile,entUser.userType,entUser.age,entUser.workTime,entUser.passwd,entUser.postPath,entUser.postPathName,entUser.jobNumber,entUser.modifyTime,entUser.modifyBy)
|
||||
update ent_user set post_id = #{entUser.postId},
|
||||
enterprise_id = #{entUser.enterpriseId},
|
||||
name = #{entUser.name},
|
||||
mobile = #{entUser.mobile},
|
||||
user_type = #{entUser.userType},
|
||||
age = #{entUser.age},
|
||||
work_time = #{entUser.workTime},
|
||||
passwd = #{entUser.passwd},
|
||||
post_path = #{entUser.postPath},
|
||||
post_path_name = #{entUser.postPathName},
|
||||
job_number = #{entUser.jobNumber},
|
||||
modify_time = #{entUser.modifyTime},
|
||||
modify_by = #{entUser.modifyBy}
|
||||
where ent_user_id = #{entUser.entUserId}
|
||||
</update>
|
||||
|
||||
<select id="validMobile" resultMap="BaseResultMap">
|
||||
select ent_user_id,name,mobile from ent_user where mobile = #{mobile}
|
||||
</select>
|
||||
|
||||
<select id="validName" resultMap="BaseResultMap">
|
||||
select ent_user_id,name,mobile from ent_user where name = #{name}
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,19 @@
|
|||
package com.rzyc.controller;
|
||||
|
||||
import com.common.utils.model.SingleResult;
|
||||
import com.common.utils.verification.Verification;
|
||||
import com.rzyc.service.PcBusinessService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.OutputStream;
|
||||
|
||||
|
|
@ -27,6 +28,10 @@ import java.io.OutputStream;
|
|||
@Validated
|
||||
public class CommonController extends BaseController{
|
||||
|
||||
@Autowired
|
||||
PcBusinessService pcBusinessService;
|
||||
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
* @param request
|
||||
|
|
@ -48,4 +53,34 @@ public class CommonController extends BaseController{
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 验证企业用户电话
|
||||
* @param mobile
|
||||
* @param entUserId
|
||||
* @return SingleResult
|
||||
* @throws Exception
|
||||
*/
|
||||
@ApiOperation(value = "验证企业用户电话", notes = "验证企业用户电话")
|
||||
@PostMapping(value = "/validEntUserMobile")
|
||||
@ResponseBody
|
||||
public SingleResult validEntUserMobile(@NotNull(message = "电话不能为null") String mobile, @NotNull(message = "用户id不能为null") String entUserId)throws Exception{
|
||||
return pcBusinessService.validEntUserMobile(mobile,entUserId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证企业用户名字
|
||||
* @param name
|
||||
* @param entUserId
|
||||
* @return SingleResult
|
||||
* @throws Exception
|
||||
*/
|
||||
@ApiOperation(value = "验证企业用户名字", notes = "验证企业用户名字")
|
||||
@PostMapping(value = "/validEntUserName")
|
||||
@ResponseBody
|
||||
public SingleResult validEntUserName(@NotNull(message = "名字不能为null") String name, @NotNull(message = "用户id不能为null") String entUserId)throws Exception{
|
||||
return pcBusinessService.validEntUserName(name,entUserId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,10 +22,12 @@ import io.swagger.annotations.ApiImplicitParams;
|
|||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
|
@ -248,7 +250,9 @@ public class PersonalController extends BaseController{
|
|||
@MethodAnnotation(authorizations = {"entUserCredentialUpdate:update"},name = "企业用户证照表-新增,修改")
|
||||
@ResponseBody
|
||||
public SingleResult entUserCredentialUpdate(@RequestBody EntUserCredentialUpdateDto entUserCredentialUpdateDto)throws Exception{
|
||||
return pcBusinessService.entUserCredentialUpdate(entUserCredentialUpdateDto);
|
||||
List<EntUserCredentialUpdateDto>entUserCredentialUpdateDtos = new ArrayList<>();
|
||||
entUserCredentialUpdateDtos.add(entUserCredentialUpdateDto);
|
||||
return pcBusinessService.entUserCredentialUpdate(entUserCredentialUpdateDtos);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -294,7 +298,7 @@ public class PersonalController extends BaseController{
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
/**fore
|
||||
* 新增和修改公司岗位人员
|
||||
* @param addOrUpdateEntUserDto
|
||||
* @return list
|
||||
|
|
@ -305,6 +309,7 @@ public class PersonalController extends BaseController{
|
|||
@PreAuthorize("hasAnyAuthority('addOrUpdateEntUser:update')")
|
||||
@MethodAnnotation(authorizations = {"addOrUpdateEntUser:update"},name = "新增和修改公司岗位人员")
|
||||
@ResponseBody
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public SingleResult addOrUpdateEntUser(@RequestBody AddOrUpdateEntUserDto addOrUpdateEntUserDto)throws Exception{
|
||||
return pcBusinessService.addOrUpdateEntUser(addOrUpdateEntUserDto);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import cn.jiguang.common.TimeUnit;
|
|||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.common.utils.*;
|
||||
import com.common.utils.encryption.MD5;
|
||||
import com.common.utils.model.Code;
|
||||
import com.common.utils.model.Message;
|
||||
import com.common.utils.model.SingleResult;
|
||||
|
|
@ -23,6 +24,8 @@ import org.springframework.beans.BeanUtils;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 企业端pc业务 Service
|
||||
|
|
@ -118,24 +121,26 @@ public class PcBusinessService extends BaseController {
|
|||
return singleResult;
|
||||
}
|
||||
|
||||
public SingleResult entUserCredentialUpdate(EntUserCredentialUpdateDto entUserCredentialUpdateDto) throws Exception {
|
||||
public SingleResult entUserCredentialUpdate(List<EntUserCredentialUpdateDto> entUserCredentialUpdateDto) throws Exception {
|
||||
SingleResult singleResult = new SingleResult();
|
||||
EntUserCredential entUserCredential = new EntUserCredential();
|
||||
BeanUtils.copyProperties(entUserCredentialUpdateDto,entUserCredential);
|
||||
Integer result = 0;
|
||||
for (EntUserCredentialUpdateDto e:entUserCredentialUpdateDto) {
|
||||
EntUserCredential entUserCredential = new EntUserCredential();
|
||||
BeanUtils.copyProperties(e,entUserCredential);
|
||||
if (StringUtils.isNotBlank(entUserCredential.getCredentialId())) {
|
||||
entUserCredential.setModifyBy(getUserId());
|
||||
entUserCredential.setModifyTime(new Date());
|
||||
result = entUserCredentialMapper.updateEntUserCredential(entUserCredential);
|
||||
result += entUserCredentialMapper.updateEntUserCredential(entUserCredential);
|
||||
}else {
|
||||
entUserCredential.setCredentialId(RandomNumber.getUUid());
|
||||
entUserCredential.setCreateBy(getUserId());
|
||||
entUserCredential.setCreateTime(new Date());
|
||||
result = entUserCredentialMapper.insertEntUserCredential(entUserCredential);
|
||||
result += entUserCredentialMapper.insertEntUserCredential(entUserCredential);
|
||||
}
|
||||
if (result==1){
|
||||
singleResult.setCode(Code.SUCCESS.getCode());
|
||||
singleResult.setMessage(Message.SUCCESS);
|
||||
}
|
||||
if (result != entUserCredentialUpdateDto.size()){
|
||||
singleResult.setCode(Code.ERROR.getCode());
|
||||
singleResult.setMessage(Message.ERROR);
|
||||
}
|
||||
return singleResult;
|
||||
}
|
||||
|
|
@ -165,13 +170,25 @@ public class PcBusinessService extends BaseController {
|
|||
return singleResult;
|
||||
}
|
||||
|
||||
public SingleResult addOrUpdateEntUser(AddOrUpdateEntUserDto addOrUpdateEntUserDto){
|
||||
public SingleResult addOrUpdateEntUser(AddOrUpdateEntUserDto addOrUpdateEntUserDto) throws Exception {
|
||||
SingleResult singleResult = new SingleResult();
|
||||
//正则验证手机号
|
||||
String regex = "^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|166|198|199|(147))\\d{8}$";
|
||||
Pattern p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
|
||||
Matcher m = p.matcher(addOrUpdateEntUserDto.getMobile());
|
||||
if (!m.matches()){
|
||||
singleResult.setCode(Code.ERROR.getCode());
|
||||
singleResult.setMessage(Message.MOBILE_IS_ILLEGAL);
|
||||
return singleResult;
|
||||
}
|
||||
//验证数据重复
|
||||
EntUser entUser = new EntUser();
|
||||
BeanUtils.copyProperties(addOrUpdateEntUserDto,entUser);
|
||||
EntPost entPost = entPostMapper.selectById(addOrUpdateEntUserDto.getPostId());
|
||||
entUser.setPostPath(entPost.getPostPath());
|
||||
entUser.setPostPathName(entPost.getPostId());
|
||||
//密码为用户名加手机号
|
||||
entUser.setPasswd(MD5.md5(entUser.getName() + entUser.getMobile()));
|
||||
int result = 0 ;
|
||||
if (StringUtils.isNotBlank(entUser.getEntUserId())){
|
||||
result = entUserMapper.updateEntUser(entUser);
|
||||
|
|
@ -182,10 +199,43 @@ public class PcBusinessService extends BaseController {
|
|||
singleResult.setCode(Code.ERROR.getCode());
|
||||
singleResult.setMessage(Message.ERROR);
|
||||
}
|
||||
//插入证件图
|
||||
singleResult = this.entUserCredentialUpdate(addOrUpdateEntUserDto.getEntUserCredentialUpdateDtos());
|
||||
return singleResult;
|
||||
}
|
||||
|
||||
public SingleResult validEntUserMobile(String mobile, String entUserId){
|
||||
SingleResult singleResult = new SingleResult();
|
||||
//正则验证手机号
|
||||
String regex = "^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|166|198|199|(147))\\d{8}$";
|
||||
Pattern p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
|
||||
Matcher m = p.matcher(mobile);
|
||||
if (!m.matches()){
|
||||
singleResult.setCode(Code.ERROR.getCode());
|
||||
singleResult.setMessage(Message.MOBILE_IS_ILLEGAL);
|
||||
return singleResult;
|
||||
}
|
||||
EntUser entUser = entUserMapper.validMobile(mobile);
|
||||
if (entUser != null && !entUserId.equals(entUser.getEntUserId()) ){
|
||||
singleResult.setCode(Code.ERROR.getCode());
|
||||
singleResult.setMessage(Message.REGISTERED);
|
||||
}
|
||||
return singleResult;
|
||||
}
|
||||
|
||||
public SingleResult validEntUserName(String name, String entUserId){
|
||||
SingleResult singleResult = new SingleResult();
|
||||
EntUser entUser = entUserMapper.validName(name);
|
||||
if (entUser != null && !entUserId.equals(entUser.getEntUserId())){
|
||||
singleResult.setCode(Code.ERROR.getCode());
|
||||
singleResult.setMessage(Message.HAS_USERNAME);
|
||||
}
|
||||
return singleResult;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.rzyc.service;
|
||||
|
||||
|
||||
import com.common.utils.encryption.MD5;
|
||||
import com.common.utils.jwt.JwtUtil;
|
||||
|
||||
import com.rzyc.advice.CustomException;
|
||||
|
|
@ -65,7 +66,7 @@ public class UserLoginService {
|
|||
throw new CustomException("企业不存在或已经禁用");
|
||||
}
|
||||
//这里可能会不对,因为我们是MD5,这个是spring security 中的 encoder加密
|
||||
if (!passwordEncoder.matches(password, userDetails.getPassword())) {
|
||||
if (!passwordEncoder.matches(MD5.md5(password), userDetails.getPassword())) {
|
||||
throw new BadCredentialsException("密码不正确");
|
||||
}
|
||||
//spring security context insert
|
||||
|
|
|
|||
|
|
@ -168,4 +168,6 @@ public class Message {
|
|||
public static final String NOT_BACK = "存在未归还记录";
|
||||
|
||||
public static final String AUTHORIZATION_FAILED="无权限操作";
|
||||
|
||||
public static final String MOBILE_IS_ILLEGAL="手机号非法";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user