Compare View
Commits (2)
Showing
8 changed files
Show diff stats
cloud/dahua/src/main/resources/xiaoanmapper/SearchMapper.xml
| 1 | 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
| 3 | -<mapper namespace="com.example.dahua.dao.SearchDao" > | |
| 3 | +<mapper namespace="com.example.dahua.xiananDao.SearchMapper" > | |
| 4 | 4 | |
| 5 | 5 | |
| 6 | 6 | <resultMap id="resultMap" type="com.example.dahua.bean.CheckIn"> |
| 7 | 7 | <result column="arr" property="out" jdbcType="VARCHAR" /> |
| 8 | 8 | <result column="iscuccess" property="isSuccess" jdbcType="INTEGER" /> |
| 9 | 9 | </resultMap> |
| 10 | - <insert id="checkIn" parameterType="com.example.dahua.bean.CheckIn" statementType="CALLABLE" > | |
| 10 | + | |
| 11 | + <insert id="checkIn" parameterType="com.example.dahua.bean.CheckIn" statementType="CALLABLE"> | |
| 11 | 12 | {call AttendanceService( |
| 12 | 13 | #{deviceId,mode=IN} , #{cardNo,mode=IN} , #{funNo,mode=IN}, #{flag,mode=IN} , #{checkTime,mode=IN}, |
| 13 | 14 | #{out,mode=OUT,jdbcType=VARCHAR,resultMap=resultMap},#{isSuccess,mode=OUT,jdbcType=INTEGER,resultMap=resultMap} |
| 14 | 15 | )} |
| 15 | 16 | </insert> |
| 16 | 17 | |
| 17 | - <resultMap id="User" type="com.example.dahua.bean.User" > | |
| 18 | - <result column="school_id" property="schoolId" jdbcType="INTEGER" /> | |
| 19 | - <result column="class_id" property="classId" jdbcType="INTEGER" /> | |
| 20 | - <result column="name" property="name" jdbcType="VARCHAR" /> | |
| 21 | - <result column="student_id" property="studentId" jdbcType="INTEGER" /> | |
| 22 | - </resultMap> | |
| 23 | - <select id="selectUserByCardNum" parameterType="java.lang.String" resultMap="User"> | |
| 24 | - select school_id , class_id ,name ,student_id from | |
| 25 | - (select top 1 b.school_id, b.class_id, b.name, student_id from SZ_V_Card a | |
| 26 | - inner join SZ_V_School_Student b on a.user_id = b.student_id | |
| 27 | - and b.role_state = 1 where a.type = 2 and a.num = #{cardNum} | |
| 28 | - union | |
| 29 | - select top 1 b.school_id, 0 as class_id, b.name,b.teacher_id as student_id from SZ_V_Card a | |
| 30 | - inner join SZ_V_School_Teacher b on a.user_id = b.teacher_id | |
| 31 | - and b.role_state = 1 where a.type = 0 and a.num = #{cardNum} | |
| 32 | - ) x | |
| 33 | - </select> | |
| 34 | - | |
| 35 | 18 | </mapper> |
| 36 | 19 | \ No newline at end of file | ... | ... |
| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | +package com.example.dahua; | |
| 2 | + | |
| 3 | + | |
| 4 | +import org.junit.runner.RunWith; | |
| 5 | +import org.springframework.boot.test.context.SpringBootTest; | |
| 6 | +import org.springframework.test.context.junit4.SpringRunner; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * 单元测试继承该类即可 | |
| 10 | + */ | |
| 11 | +@RunWith(SpringRunner.class) | |
| 12 | +@SpringBootTest | |
| 13 | +public abstract class Tester {} | |
| 14 | + | |
| 15 | + | |
| 16 | + | ... | ... |
cloud/dahua/src/test/java/com/example/dahua/mapper/SearchMapperTest.java
0 → 100644
| ... | ... | @@ -0,0 +1,64 @@ |
| 1 | +package com.example.dahua.mapper; | |
| 2 | + | |
| 3 | +import com.alibaba.fastjson.JSON; | |
| 4 | +import com.example.dahua.Tester; | |
| 5 | +import com.example.dahua.bean.CheckIn; | |
| 6 | +import com.example.dahua.bean.ShortMsg; | |
| 7 | +import com.example.dahua.dao.UserDao; | |
| 8 | +import com.example.dahua.utils.DateUtils; | |
| 9 | +import com.example.dahua.xiananDao.SearchMapper; | |
| 10 | +import org.junit.Test; | |
| 11 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 12 | + | |
| 13 | +import java.util.Date; | |
| 14 | + | |
| 15 | +/** | |
| 16 | + * TODO | |
| 17 | + * | |
| 18 | + * @author xuquan | |
| 19 | + * @date 2020/11/11 12:13 | |
| 20 | + */ | |
| 21 | + | |
| 22 | +public class SearchMapperTest extends Tester { | |
| 23 | + | |
| 24 | + @Autowired | |
| 25 | + private SearchMapper searchMapper; | |
| 26 | + | |
| 27 | + @Autowired | |
| 28 | + private UserDao userDao; | |
| 29 | + | |
| 30 | + @Test | |
| 31 | + public void test(){ | |
| 32 | + //有效刷卡调考勤存储过程 | |
| 33 | + CheckIn checkIn = new CheckIn(); | |
| 34 | + checkIn.setDeviceId("1212"); | |
| 35 | + checkIn.setCardNo("24234"); | |
| 36 | + checkIn.setFunNo(8); | |
| 37 | + checkIn.setFlag(1); | |
| 38 | + checkIn.setCheckTime("2020-11-11 12:19:12"); | |
| 39 | + searchMapper.checkIn(checkIn); | |
| 40 | + System.out.println(JSON.toJSON(checkIn)); | |
| 41 | + } | |
| 42 | + | |
| 43 | + @Test | |
| 44 | + public void test2(){ | |
| 45 | + userDao.checkLeave("234232"); | |
| 46 | + System.out.println(JSON.toJSON(userDao.checkLeave("234232"))); | |
| 47 | + userDao.selectByParentMobile("234232"); | |
| 48 | + System.out.println(JSON.toJSON(userDao.checkLeave("234232"))); | |
| 49 | + userDao.checkLeave("234232"); | |
| 50 | + System.out.println(JSON.toJSON(userDao.checkLeave("234232"))); | |
| 51 | + } | |
| 52 | + | |
| 53 | + @Test | |
| 54 | + public void test3(){ | |
| 55 | + ShortMsg shortMsg = new ShortMsg(); | |
| 56 | + String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); | |
| 57 | + shortMsg.setTableName("smsNew" + tableSuffix); | |
| 58 | + shortMsg.setSchoolId(23); | |
| 59 | + shortMsg.setMobile("124124242"); | |
| 60 | + userDao.insertMessage(); | |
| 61 | + System.out.println(JSON.toJSON(userDao.checkLeave("234232"))); | |
| 62 | + | |
| 63 | + } | |
| 64 | +} | ... | ... |