Helius
2021-06-26 cdeaa3ef13d373825dfb579a5ff63ee2a411e17e
add jhy apply
5 files added
1 files modified
159 ■■■■■ changed files
gc-core/src/main/java/com/xzx/gc/entity/JhyInfo.java 5 ●●●●● patch | view | raw | blame | history
gc-user/src/main/java/com/xzx/gc/user/controller/ApiJhyInfoController.java 40 ●●●●● patch | view | raw | blame | history
gc-user/src/main/java/com/xzx/gc/user/dto/JhyApplyDto.java 37 ●●●●● patch | view | raw | blame | history
gc-user/src/main/java/com/xzx/gc/user/mapper/JhyInfoMapper.java 16 ●●●●● patch | view | raw | blame | history
gc-user/src/main/java/com/xzx/gc/user/service/JhyInfoService.java 41 ●●●●● patch | view | raw | blame | history
gc-user/src/main/resources/mapper/user/JhyInfoMapper.xml 20 ●●●●● patch | view | raw | blame | history
gc-core/src/main/java/com/xzx/gc/entity/JhyInfo.java
@@ -32,4 +32,9 @@
     * 是否集物员 1-是 2-否
     */
    private String isJyh;
    /**
     * 审核状态 1-待审核 2-审核通过 3-审核拒绝
     */
    private Integer status;
}
gc-user/src/main/java/com/xzx/gc/user/controller/ApiJhyInfoController.java
New file
@@ -0,0 +1,40 @@
package com.xzx.gc.user.controller;
import com.xzx.gc.common.Result;
import com.xzx.gc.common.request.BaseController;
import com.xzx.gc.user.dto.JhyApplyDto;
import com.xzx.gc.user.service.JhyInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
@RestController
@Api(tags = {"集物员--集物员管理"})
@Slf4j
public class ApiJhyInfoController extends BaseController {
    @Autowired
    private JhyInfoService jhyInfoService;
    @ApiOperation("申请集物员")
    @PostMapping(value = "/jhy/apply")
    public Result<String> apply(@RequestBody JhyApplyDto applyDto, HttpServletRequest request) {
        String userId = getUserId(request);
        applyDto.setUserId(userId);
        jhyInfoService.applyJhy(applyDto);
        return Result.success();
    }
    @ApiOperation("获取集物员审核状态")
    @PostMapping(value = "/jhy/applyStatus")
    public Result<Integer> applyStatus(HttpServletRequest request) {
        int status = jhyInfoService.applyStatus(getUserId(request));
        return Result.success(status);
    }
}
gc-user/src/main/java/com/xzx/gc/user/dto/JhyApplyDto.java
New file
@@ -0,0 +1,37 @@
package com.xzx.gc.user.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "JhyApplyDto", description = "集物员申请接收参数类")
public class JhyApplyDto {
    @ApiModelProperty(value = "姓名")
    private String username;
    @ApiModelProperty(value ="性别 男/女")
    private String gender;
    @ApiModelProperty(value = "手机号")
    private String mobile;
    @ApiModelProperty(value = "身份证号")
    private String identity;
    @ApiModelProperty(value = "地址")
    private String address;
    @ApiModelProperty(value = "经度")
    private String lon;
    @ApiModelProperty(value = "纬度")
    private String lat;
    @ApiModelProperty(value = "身份证照片")
    private String cardPos;
    @ApiModelProperty(hidden = true)
    private String userId;
}
gc-user/src/main/java/com/xzx/gc/user/mapper/JhyInfoMapper.java
New file
@@ -0,0 +1,16 @@
package com.xzx.gc.user.mapper;
import com.xzx.gc.entity.JhyInfo;
import com.xzx.gc.util.GcMapper;
import org.apache.ibatis.annotations.Param;
public interface JhyInfoMapper extends GcMapper<JhyInfo> {
    JhyInfo selectJhyInfoByMobile(@Param("mobile") String mobile);
    JhyInfo selectJhyInfoByIdentity(@Param("identity") String Identity);
    JhyInfo selectJhyInfoByUserId(@Param("userId") String userId);
    JhyInfo selectExistJhyByIndeityOrMobile(@Param("mobile") String mobile, @Param("identity") String Identity);
}
gc-user/src/main/java/com/xzx/gc/user/service/JhyInfoService.java
New file
@@ -0,0 +1,41 @@
package com.xzx.gc.user.service;
import cn.hutool.core.bean.BeanUtil;
import com.xzx.gc.common.exception.RestException;
import com.xzx.gc.entity.JhyInfo;
import com.xzx.gc.user.dto.JhyApplyDto;
import com.xzx.gc.user.mapper.JhyInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
public class JhyInfoService {
    @Autowired
    private JhyInfoMapper jhyInfoMapper;
    public void applyJhy(JhyApplyDto applyDto) {
        JhyInfo mobileIsExist = jhyInfoMapper.selectExistJhyByIndeityOrMobile(applyDto.getMobile(), applyDto.getIdentity());
        if (mobileIsExist != null) {
            if (applyDto.getUserId().equals(mobileIsExist.getUserId())) {
                throw new RestException(-3, "审核中或审核成功, 请勿重复提交");
            }
            throw new RestException(-3, "手机号/身份证号已注册集物员");
        }
        JhyInfo jhyInfo = new JhyInfo();
        BeanUtil.copyProperties(applyDto, jhyInfo);
        jhyInfo.setCreatedTime(new Date());
        jhyInfoMapper.insert(jhyInfo);
    }
    public int applyStatus(String userId) {
        JhyInfo jhyInfo = jhyInfoMapper.selectJhyInfoByUserId(userId);
        if (jhyInfo == null) {
            return 0;
        }
        return jhyInfo.getStatus();
    }
}
gc-user/src/main/resources/mapper/user/JhyInfoMapper.xml
New file
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xzx.gc.user.mapper.JhyInfoMapper">
    <select id="selectJhyInfoByMobile" resultType="com.xzx.gc.entity.JhyInfo">
        select * from xzx_jhy_info where mobile=#{mobile}
    </select>
    <select id="selectJhyInfoByIdentity" resultType="com.xzx.gc.entity.JhyInfo">
        select * from xzx_jhy_info where identity = #{identity}
    </select>
    <select id="selectJhyInfoByUserId" resultType="com.xzx.gc.entity.JhyInfo">
        select * from xzx_jhy_info where user_id=#{userId}
    </select>
    <select id="selectExistJhyByIndeityOrMobile" resultType="com.xzx.gc.entity.JhyInfo">
        select * from xzx_jhy_info where (mobile=#{mobile} or identity = #{identity}) and status in (1, 2)
    </select>
</mapper>