Browse Source

添加学生体检预约。

lighter 4 years ago
parent
commit
da7b60e06d

+ 41 - 0
src/main/java/thyyxxk/wxservice_server/controller/IsolationsController.java

@@ -0,0 +1,41 @@
+package thyyxxk.wxservice_server.controller;
+
+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.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
+import thyyxxk.wxservice_server.dao.IsolationsDao;
+import thyyxxk.wxservice_server.entity.ResultVo;
+import thyyxxk.wxservice_server.entity.isolations.StudentInspection;
+import thyyxxk.wxservice_server.utils.ResultVoUtil;
+
+/**
+ * @description: 独立页面控制器
+ * @author: DingJie
+ * @create: 2021-06-01 16:27:00
+ **/
+@Slf4j
+@RestController
+@RequestMapping("/isolations")
+public class IsolationsController {
+    private final IsolationsDao dao;
+
+    @Autowired
+    public IsolationsController(IsolationsDao dao) {
+        this.dao = dao;
+    }
+
+    @PostMapping("/saveStudentInspection")
+    public ResultVo<String> saveStudentInspection(@RequestBody StudentInspection inspection) {
+        Integer count = dao.selectSameOrderCount(inspection.getIdcard(), inspection.getOrderCode());
+        if (null != count && count > 0) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您当天已保存过此项目,请勿重复提交。");
+        }
+        dao.insertStudentInspection(inspection);
+        log.info("保存学生体检预约信息:{}", inspection);
+        return ResultVoUtil.success("保存预约信息成功。");
+    }
+}

+ 35 - 0
src/main/java/thyyxxk/wxservice_server/dao/IsolationsDao.java

@@ -0,0 +1,35 @@
+package thyyxxk.wxservice_server.dao;
+
+import org.apache.ibatis.annotations.Insert;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import thyyxxk.wxservice_server.entity.isolations.StudentInspection;
+
+/**
+ * @description: 独立页面mapper
+ * @author: DingJie
+ * @create: 2021-06-01 16:27:56
+ **/
+@Mapper
+public interface IsolationsDao {
+
+    /**
+     * 查询同一个人同一天插入的同一种体检项目
+     * @param idcard 身份证
+     * @param orderCode 项目编码
+     * @return 符合条件的数量
+     * */
+    @Select("select count(1) from t_student_inspection where idcard=#{idcard} and " +
+            "order_code=#{orderCode} and datediff(day,getdate(),create_datetime)=0")
+    Integer selectSameOrderCount(@Param("idcard") String idcard, @Param("orderCode") String orderCode);
+
+    /**
+     * 插入学生体检预约信息
+     * @param inspection 生体检预约信息实体类
+     * */
+    @Insert("insert into t_student_inspection (name, idcard, phone, school, tclass, order_code, order_name, order_price) " +
+            "values (#{name},#{idcard},#{phone},#{school},#{tclass},#{orderCode},#{orderName},#{orderPrice})")
+    void insertStudentInspection(StudentInspection inspection);
+
+}

+ 20 - 0
src/main/java/thyyxxk/wxservice_server/entity/isolations/StudentInspection.java

@@ -0,0 +1,20 @@
+package thyyxxk.wxservice_server.entity.isolations;
+
+import lombok.Data;
+
+/**
+ * @description: 学生体检预约信息
+ * @author: DingJie
+ * @create: 2021-06-01 16:24:25
+ **/
+@Data
+public class StudentInspection {
+    private String name;
+    private String idcard;
+    private String phone;
+    private String school;
+    private String tclass;
+    private String orderCode;
+    private String orderName;
+    private Double orderPrice;
+}