From cdeaa3ef13d373825dfb579a5ff63ee2a411e17e Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Sat, 26 Jun 2021 18:28:02 +0800 Subject: [PATCH] add jhy apply --- gc-user/src/main/java/com/xzx/gc/user/mapper/JhyInfoMapper.java | 16 +++++ gc-user/src/main/java/com/xzx/gc/user/service/JhyInfoService.java | 41 +++++++++++++ gc-user/src/main/java/com/xzx/gc/user/dto/JhyApplyDto.java | 37 ++++++++++++ gc-user/src/main/java/com/xzx/gc/user/controller/ApiJhyInfoController.java | 40 +++++++++++++ gc-core/src/main/java/com/xzx/gc/entity/JhyInfo.java | 5 + gc-user/src/main/resources/mapper/user/JhyInfoMapper.xml | 20 ++++++ 6 files changed, 159 insertions(+), 0 deletions(-) diff --git a/gc-core/src/main/java/com/xzx/gc/entity/JhyInfo.java b/gc-core/src/main/java/com/xzx/gc/entity/JhyInfo.java index 1f12d08..5429742 100644 --- a/gc-core/src/main/java/com/xzx/gc/entity/JhyInfo.java +++ b/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; } diff --git a/gc-user/src/main/java/com/xzx/gc/user/controller/ApiJhyInfoController.java b/gc-user/src/main/java/com/xzx/gc/user/controller/ApiJhyInfoController.java new file mode 100644 index 0000000..e67fd7e --- /dev/null +++ b/gc-user/src/main/java/com/xzx/gc/user/controller/ApiJhyInfoController.java @@ -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); + } +} diff --git a/gc-user/src/main/java/com/xzx/gc/user/dto/JhyApplyDto.java b/gc-user/src/main/java/com/xzx/gc/user/dto/JhyApplyDto.java new file mode 100644 index 0000000..b485014 --- /dev/null +++ b/gc-user/src/main/java/com/xzx/gc/user/dto/JhyApplyDto.java @@ -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; +} diff --git a/gc-user/src/main/java/com/xzx/gc/user/mapper/JhyInfoMapper.java b/gc-user/src/main/java/com/xzx/gc/user/mapper/JhyInfoMapper.java new file mode 100644 index 0000000..7e4a0b2 --- /dev/null +++ b/gc-user/src/main/java/com/xzx/gc/user/mapper/JhyInfoMapper.java @@ -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); +} diff --git a/gc-user/src/main/java/com/xzx/gc/user/service/JhyInfoService.java b/gc-user/src/main/java/com/xzx/gc/user/service/JhyInfoService.java new file mode 100644 index 0000000..ddb94da --- /dev/null +++ b/gc-user/src/main/java/com/xzx/gc/user/service/JhyInfoService.java @@ -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(); + } +} diff --git a/gc-user/src/main/resources/mapper/user/JhyInfoMapper.xml b/gc-user/src/main/resources/mapper/user/JhyInfoMapper.xml new file mode 100644 index 0000000..2dd4a67 --- /dev/null +++ b/gc-user/src/main/resources/mapper/user/JhyInfoMapper.xml @@ -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> \ No newline at end of file -- Gitblit v1.9.1