Commit e8020d799b3be7cf7cad2978c83b284fe99d1206

Authored by changpengfei
Exists in master

Merge remote-tracking branch 'origin/master'

Showing 12 changed files

talkonlineweb/src/main/java/com/lyms/talkonlineweb/config/DataScopeInterceptor.java View file @ e8020d7
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 @ e8020d7
  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 +
  55 + /**
  56 + * 医生端问诊统计
  57 + * @param tkrecordInfo(需给did赋值)
  58 + * @return 本月问诊数量themonth、上月问诊数量lastmonth、总问诊数量alltotal
  59 + */
  60 + @GetMapping("queryTkRecordStatisticsByDid")
  61 + public BaseResponse queryTkRecordStatisticsByDid(TkrecordInfo tkrecordInfo){
  62 + BaseResponse baseResponse=new BaseResponse();
  63 + try {
  64 + baseResponse.setObject(tkrecordInfoService.getOne(Wrappers.query(tkrecordInfo)));
  65 + baseResponse.setErrormsg("成功");
  66 + } catch (Exception e) {
  67 + baseResponse.setErrormsg("失败");
  68 + e.printStackTrace();
  69 + }
  70 +
  71 + return baseResponse;
  72 + }
  73 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsTkrecord.java View file @ e8020d7
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/domain/TkrecordInfo.java View file @ e8020d7
  1 +package com.lyms.talkonlineweb.domain;
  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;
  7 +import java.io.Serializable;
  8 +import lombok.Data;
  9 +
  10 +/**
  11 + *
  12 + * @TableName tkrecord_info
  13 + */
  14 +@TableName(value ="tkrecord_info")
  15 +@Data
  16 +public class TkrecordInfo implements Serializable {
  17 + /**
  18 + * 医生id
  19 + */
  20 + @TableField(value = "did")
  21 + private Integer did;
  22 +
  23 + /**
  24 + * 本月接诊数量
  25 + */
  26 + @TableField(value = "themonth")
  27 + private Long themonth;
  28 +
  29 + /**
  30 + * 上月接诊数量
  31 + */
  32 + @TableField(value = "lastmonth")
  33 + private Long lastmonth;
  34 +
  35 + /**
  36 + * 总接诊数量
  37 + */
  38 + @TableField(value = "alltotal")
  39 + private Long alltotal;
  40 +
  41 + @TableField(exist = false)
  42 + private static final long serialVersionUID = 1L;
  43 +
  44 + @Override
  45 + public boolean equals(Object that) {
  46 + if (this == that) {
  47 + return true;
  48 + }
  49 + if (that == null) {
  50 + return false;
  51 + }
  52 + if (getClass() != that.getClass()) {
  53 + return false;
  54 + }
  55 + TkrecordInfo other = (TkrecordInfo) that;
  56 + return (this.getDid() == null ? other.getDid() == null : this.getDid().equals(other.getDid()))
  57 + && (this.getThemonth() == null ? other.getThemonth() == null : this.getThemonth().equals(other.getThemonth()))
  58 + && (this.getLastmonth() == null ? other.getLastmonth() == null : this.getLastmonth().equals(other.getLastmonth()))
  59 + && (this.getAlltotal() == null ? other.getAlltotal() == null : this.getAlltotal().equals(other.getAlltotal()));
  60 + }
  61 +
  62 + @Override
  63 + public int hashCode() {
  64 + final int prime = 31;
  65 + int result = 1;
  66 + result = prime * result + ((getDid() == null) ? 0 : getDid().hashCode());
  67 + result = prime * result + ((getThemonth() == null) ? 0 : getThemonth().hashCode());
  68 + result = prime * result + ((getLastmonth() == null) ? 0 : getLastmonth().hashCode());
  69 + result = prime * result + ((getAlltotal() == null) ? 0 : getAlltotal().hashCode());
  70 + return result;
  71 + }
  72 +
  73 + @Override
  74 + public String toString() {
  75 + StringBuilder sb = new StringBuilder();
  76 + sb.append(getClass().getSimpleName());
  77 + sb.append(" [");
  78 + sb.append("Hash = ").append(hashCode());
  79 + sb.append(", did=").append(did);
  80 + sb.append(", themonth=").append(themonth);
  81 + sb.append(", lastmonth=").append(lastmonth);
  82 + sb.append(", alltotal=").append(alltotal);
  83 + sb.append(", serialVersionUID=").append(serialVersionUID);
  84 + sb.append("]");
  85 + return sb.toString();
  86 + }
  87 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsTkrecordMapper.java View file @ e8020d7
  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/mapper/TkrecordInfoMapper.java View file @ e8020d7
  1 +package com.lyms.talkonlineweb.mapper;
  2 +
  3 +import com.lyms.talkonlineweb.domain.TkrecordInfo;
  4 +import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  5 +
  6 +/**
  7 + * @Entity com.lyms.talkonlineweb.domain.TkrecordInfo
  8 + */
  9 +public interface TkrecordInfoMapper extends BaseMapper<TkrecordInfo> {
  10 +
  11 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsTkrecordService.java View file @ e8020d7
  1 +package com.lyms.talkonlineweb.service;
  2 +
  3 +import com.lyms.talkonlineweb.domain.LymsTkrecord;
  4 +import com.baomidou.mybatisplus.extension.service.IService;
  5 +
  6 +/**
  7 + *
  8 + */
  9 +public interface LymsTkrecordService extends IService<LymsTkrecord> {
  10 +
  11 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/TkrecordInfoService.java View file @ e8020d7
  1 +package com.lyms.talkonlineweb.service;
  2 +
  3 +import com.lyms.talkonlineweb.domain.TkrecordInfo;
  4 +import com.baomidou.mybatisplus.extension.service.IService;
  5 +
  6 +/**
  7 + *
  8 + */
  9 +public interface TkrecordInfoService extends IService<TkrecordInfo> {
  10 +
  11 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsTkrecordServiceImpl.java View file @ e8020d7
  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/java/com/lyms/talkonlineweb/service/impl/TkrecordInfoServiceImpl.java View file @ e8020d7
  1 +package com.lyms.talkonlineweb.service.impl;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  4 +import com.lyms.talkonlineweb.domain.TkrecordInfo;
  5 +import com.lyms.talkonlineweb.service.TkrecordInfoService;
  6 +import com.lyms.talkonlineweb.mapper.TkrecordInfoMapper;
  7 +import org.springframework.stereotype.Service;
  8 +
  9 +/**
  10 + *
  11 + */
  12 +@Service
  13 +public class TkrecordInfoServiceImpl extends ServiceImpl<TkrecordInfoMapper, TkrecordInfo>
  14 + implements TkrecordInfoService{
  15 +
  16 +}
talkonlineweb/src/main/resources/mapper/LymsTkrecordMapper.xml View file @ e8020d7
  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>
talkonlineweb/src/main/resources/mapper/TkrecordInfoMapper.xml View file @ e8020d7
  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.TkrecordInfoMapper">
  6 +
  7 + <resultMap id="BaseResultMap" type="com.lyms.talkonlineweb.domain.TkrecordInfo">
  8 + <result property="did" column="did" jdbcType="INTEGER"/>
  9 + <result property="themonth" column="themonth" jdbcType="DECIMAL"/>
  10 + <result property="lastmonth" column="lastmonth" jdbcType="DECIMAL"/>
  11 + <result property="alltotal" column="alltotal" jdbcType="BIGINT"/>
  12 + </resultMap>
  13 +
  14 + <sql id="Base_Column_List">
  15 + did,themonth,lastmonth,
  16 + alltotal
  17 + </sql>
  18 +</mapper>