Commit b6c0f1219d684cbbdf1d71a1437681796f00f55b
1 parent
c32c280ee0
Exists in
master
问诊记录
Showing 7 changed files with 171 additions and 7 deletions
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/config/DataScopeInterceptor.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/TkRecordController.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsTkrecord.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsTkrecordMapper.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsTkrecordService.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsTkrecordServiceImpl.java
- talkonlineweb/src/main/resources/mapper/LymsTkrecordMapper.xml
talkonlineweb/src/main/java/com/lyms/talkonlineweb/config/DataScopeInterceptor.java
View file @
b6c0f12
1 | 1 | package com.lyms.talkonlineweb.config; |
2 | 2 | |
3 | +import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; | |
3 | 4 | import com.baomidou.mybatisplus.core.toolkit.PluginUtils; |
4 | 5 | import com.baomidou.mybatisplus.extension.handlers.AbstractSqlParserHandler; |
5 | 6 | import lombok.AllArgsConstructor; |
... | ... | @@ -15,6 +16,7 @@ |
15 | 16 | |
16 | 17 | import javax.sql.DataSource; |
17 | 18 | import java.sql.Connection; |
19 | +import java.util.Date; | |
18 | 20 | import java.util.Properties; |
19 | 21 | |
20 | 22 | //mybatis 自定义拦截器 |
... | ... | @@ -22,7 +24,7 @@ |
22 | 24 | @AllArgsConstructor |
23 | 25 | @Intercepts({@Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})}) |
24 | 26 | @Component |
25 | -public class DataScopeInterceptor extends AbstractSqlParserHandler implements Interceptor { | |
27 | +public class DataScopeInterceptor extends AbstractSqlParserHandler implements Interceptor, MetaObjectHandler { | |
26 | 28 | private DataSource dataSource; |
27 | 29 | |
28 | 30 | @Override |
... | ... | @@ -79,6 +81,28 @@ |
79 | 81 | */ |
80 | 82 | @Override |
81 | 83 | public void setProperties(Properties properties) { |
84 | + | |
85 | + } | |
86 | + | |
87 | + /** | |
88 | + * 注解形式新增时给属性赋值 | |
89 | + * @param metaObject | |
90 | + */ | |
91 | + @Override | |
92 | + public void insertFill(MetaObject metaObject) { | |
93 | + //新增时对类属性”createdtime“字段赋值,在属性上面加@TableField(value = "createdtime" ,fill = FieldFill.INSERT)主要是fill起作用 | |
94 | + this.setInsertFieldValByName("createdtime", new Date(), metaObject); | |
95 | + | |
96 | + } | |
97 | + | |
98 | + /** | |
99 | + * 注解形式修改时给属性赋值 | |
100 | + * @param metaObject | |
101 | + */ | |
102 | + @Override | |
103 | + public void updateFill(MetaObject metaObject) { | |
104 | + //新增时对类属性”updatedTime“字段更新,在属性上面加@TableField(value = "updated_time" ,fill = FieldFill.UPDATE)主要是fill起作用 | |
105 | + this.setInsertFieldValByName("updatedTime", new Date(), metaObject); | |
82 | 106 | |
83 | 107 | } |
84 | 108 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/TkRecordController.java
View file @
b6c0f12
1 | +package com.lyms.talkonlineweb.controller; | |
2 | + | |
3 | +import com.baomidou.mybatisplus.core.conditions.Wrapper; | |
4 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |
5 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
6 | +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |
7 | +import com.lyms.talkonlineweb.domain.LymsDoctor; | |
8 | +import com.lyms.talkonlineweb.domain.LymsTkrecord; | |
9 | +import com.lyms.talkonlineweb.domain.TkrecordInfo; | |
10 | +import com.lyms.talkonlineweb.result.BaseResponse; | |
11 | +import com.lyms.talkonlineweb.service.LymsTkrecordService; | |
12 | +import com.lyms.talkonlineweb.service.TkrecordInfoService; | |
13 | +import lombok.extern.log4j.Log4j2; | |
14 | +import org.springframework.beans.factory.annotation.Autowired; | |
15 | +import org.springframework.validation.annotation.Validated; | |
16 | +import org.springframework.web.bind.annotation.*; | |
17 | + | |
18 | +@RestController | |
19 | +@RequestMapping("tk") | |
20 | +@Log4j2 | |
21 | +public class TkRecordController { | |
22 | + | |
23 | + @Autowired | |
24 | + private LymsTkrecordService lymsTkrecordService; | |
25 | + @Autowired | |
26 | + private TkrecordInfoService tkrecordInfoService; | |
27 | + | |
28 | + @PostMapping("saveTkRecord") | |
29 | + public BaseResponse saveTkRecord(@RequestBody @Validated LymsTkrecord tkrecord){ | |
30 | + BaseResponse baseResponse=new BaseResponse(); | |
31 | + try { | |
32 | + lymsTkrecordService.save(tkrecord); | |
33 | + baseResponse.setErrormsg("成功"); | |
34 | + } catch (Exception e) { | |
35 | + baseResponse.setErrormsg("失败"); | |
36 | + e.printStackTrace(); | |
37 | + } | |
38 | + | |
39 | + return baseResponse; | |
40 | + } | |
41 | + @PostMapping("deleteTkRecord") | |
42 | + public BaseResponse deleteTkRecord(Integer tkid){ | |
43 | + BaseResponse baseResponse=new BaseResponse(); | |
44 | + try { | |
45 | + lymsTkrecordService.removeById(tkid); | |
46 | + baseResponse.setErrormsg("成功"); | |
47 | + } catch (Exception e) { | |
48 | + baseResponse.setErrormsg("失败"); | |
49 | + e.printStackTrace(); | |
50 | + } | |
51 | + | |
52 | + return baseResponse; | |
53 | + } | |
54 | + @GetMapping("queryTkRecordStatisticsByDid") | |
55 | + public BaseResponse queryTkRecordStatisticsByDid(Integer tkid){ | |
56 | + BaseResponse baseResponse=new BaseResponse(); | |
57 | + try { | |
58 | + TkrecordInfo tkrecordInfo=new TkrecordInfo(); | |
59 | + tkrecordInfo.setDid(tkid); | |
60 | + tkrecordInfo= tkrecordInfoService.getOne(Wrappers.query(tkrecordInfo)); | |
61 | + baseResponse.setObject(tkrecordInfo); | |
62 | + baseResponse.setErrormsg("成功"); | |
63 | + } catch (Exception e) { | |
64 | + baseResponse.setErrormsg("失败"); | |
65 | + e.printStackTrace(); | |
66 | + } | |
67 | + | |
68 | + return baseResponse; | |
69 | + } | |
70 | +} |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsTkrecord.java
View file @
b6c0f12
1 | 1 | package com.lyms.talkonlineweb.domain; |
2 | 2 | |
3 | -import com.baomidou.mybatisplus.annotation.IdType; | |
4 | -import com.baomidou.mybatisplus.annotation.TableField; | |
5 | -import com.baomidou.mybatisplus.annotation.TableId; | |
6 | -import com.baomidou.mybatisplus.annotation.TableName; | |
3 | +import com.baomidou.mybatisplus.annotation.*; | |
7 | 4 | import lombok.Data; |
8 | 5 | import lombok.ToString; |
6 | +import org.springframework.format.annotation.DateTimeFormat; | |
9 | 7 | |
10 | 8 | import java.io.Serializable; |
11 | 9 | import java.util.Date; |
... | ... | @@ -60,7 +58,8 @@ |
60 | 58 | /** |
61 | 59 | * 创建时间 |
62 | 60 | */ |
63 | - @TableField(value = "createdtime") | |
61 | + @TableField(value = "createdtime",fill = FieldFill.INSERT) | |
62 | + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |
64 | 63 | private Date createdtime; |
65 | 64 | |
66 | 65 | /** |
... | ... | @@ -72,7 +71,8 @@ |
72 | 71 | /** |
73 | 72 | * 更新时间 |
74 | 73 | */ |
75 | - @TableField(value = "updated_time") | |
74 | + @TableField(value = "updated_time",fill = FieldFill.UPDATE) | |
75 | + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |
76 | 76 | private Date updatedTime; |
77 | 77 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsTkrecordMapper.java
View file @
b6c0f12
1 | +package com.lyms.talkonlineweb.mapper; | |
2 | + | |
3 | +import com.lyms.talkonlineweb.domain.LymsTkrecord; | |
4 | +import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |
5 | + | |
6 | +/** | |
7 | + * @Entity com.lyms.talkonlineweb.domain.LymsTkrecord | |
8 | + */ | |
9 | +public interface LymsTkrecordMapper extends BaseMapper<LymsTkrecord> { | |
10 | + | |
11 | +} |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsTkrecordService.java
View file @
b6c0f12
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsTkrecordServiceImpl.java
View file @
b6c0f12
1 | +package com.lyms.talkonlineweb.service.impl; | |
2 | + | |
3 | +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |
4 | +import com.lyms.talkonlineweb.domain.LymsTkrecord; | |
5 | +import com.lyms.talkonlineweb.service.LymsTkrecordService; | |
6 | +import com.lyms.talkonlineweb.mapper.LymsTkrecordMapper; | |
7 | +import org.springframework.stereotype.Service; | |
8 | + | |
9 | +/** | |
10 | + * | |
11 | + */ | |
12 | +@Service | |
13 | +public class LymsTkrecordServiceImpl extends ServiceImpl<LymsTkrecordMapper, LymsTkrecord> | |
14 | + implements LymsTkrecordService{ | |
15 | + | |
16 | +} |
talkonlineweb/src/main/resources/mapper/LymsTkrecordMapper.xml
View file @
b6c0f12
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<!DOCTYPE mapper | |
3 | + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |
4 | + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
5 | +<mapper namespace="com.lyms.talkonlineweb.mapper.LymsTkrecordMapper"> | |
6 | + | |
7 | + <resultMap id="BaseResultMap" type="com.lyms.talkonlineweb.domain.LymsTkrecord"> | |
8 | + <id property="id" column="id" jdbcType="INTEGER"/> | |
9 | + <result property="pid" column="pid" jdbcType="INTEGER"/> | |
10 | + <result property="pcid" column="pcid" jdbcType="INTEGER"/> | |
11 | + <result property="did" column="did" jdbcType="INTEGER"/> | |
12 | + <result property="stat" column="stat" jdbcType="INTEGER"/> | |
13 | + <result property="createdby" column="createdby" jdbcType="INTEGER"/> | |
14 | + <result property="createdtime" column="createdtime" jdbcType="TIMESTAMP"/> | |
15 | + <result property="updatedby" column="updatedby" jdbcType="INTEGER"/> | |
16 | + <result property="updatedTime" column="updated_time" jdbcType="TIMESTAMP"/> | |
17 | + </resultMap> | |
18 | + | |
19 | + <sql id="Base_Column_List"> | |
20 | + id,pid,pcid, | |
21 | + did,stat,createdby, | |
22 | + createdtime,updatedby,updated_time | |
23 | + </sql> | |
24 | +</mapper> |