Commit 6a1ca2209073cf100e57d4e5647d897b83cebe4a
1 parent
104c663464
Exists in
master
and in
1 other branch
update
Showing 8 changed files with 167 additions and 33 deletions
- talkonlineweb/pom.xml
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/annotation/LogAnnotation.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/aop/CrudCommandAop.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/config/DataScopeInterceptor.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/HospitalController.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/LymsLogsController.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsLogsCrud.java
- talkonlineweb/src/main/resources/mapper/LymsLogsCrudMapper.xml
talkonlineweb/pom.xml
View file @
6a1ca22
| ... | ... | @@ -76,6 +76,10 @@ |
| 76 | 76 | <artifactId>lombok</artifactId> |
| 77 | 77 | <optional>true</optional> |
| 78 | 78 | </dependency> |
| 79 | + <dependency> | |
| 80 | + <groupId>org.springframework.boot</groupId> | |
| 81 | + <artifactId>spring-boot-starter-aop</artifactId> | |
| 82 | + </dependency> | |
| 79 | 83 | <!-- <dependency>--> |
| 80 | 84 | <!-- <groupId>log4j</groupId>--> |
| 81 | 85 | <!-- <artifactId>log4j</artifactId>--> |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/annotation/LogAnnotation.java
View file @
6a1ca22
talkonlineweb/src/main/java/com/lyms/talkonlineweb/aop/CrudCommandAop.java
View file @
6a1ca22
| 1 | +package com.lyms.talkonlineweb.aop; | |
| 2 | + | |
| 3 | +import com.alibaba.fastjson.JSON; | |
| 4 | +import com.lyms.talkonlineweb.annotation.LogAnnotation; | |
| 5 | +import com.lyms.talkonlineweb.domain.LymsLogsCrud; | |
| 6 | +import com.lyms.talkonlineweb.service.LymsLogsCrudService; | |
| 7 | +import org.aspectj.lang.JoinPoint; | |
| 8 | +import org.aspectj.lang.annotation.AfterReturning; | |
| 9 | +import org.aspectj.lang.annotation.Aspect; | |
| 10 | +import org.aspectj.lang.annotation.Pointcut; | |
| 11 | +import org.aspectj.lang.reflect.MethodSignature; | |
| 12 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 13 | +import org.springframework.stereotype.Component; | |
| 14 | + | |
| 15 | +import javax.servlet.http.HttpServletRequest; | |
| 16 | +import javax.xml.ws.spi.http.HttpContext; | |
| 17 | +import java.lang.reflect.Method; | |
| 18 | +import java.util.Date; | |
| 19 | + | |
| 20 | +@Aspect | |
| 21 | +@Component | |
| 22 | +public class CrudCommandAop { | |
| 23 | + | |
| 24 | + @Autowired | |
| 25 | + private LymsLogsCrudService lymsLogsCrudService; | |
| 26 | + | |
| 27 | + //定义切点 @Pointcut | |
| 28 | + //在注解的位置切入代码 | |
| 29 | + @Pointcut("@annotation( com.lyms.talkonlineweb.annotation.LogAnnotation)") | |
| 30 | + public void logPoinCut() { | |
| 31 | + } | |
| 32 | + | |
| 33 | + //切面 配置通知 | |
| 34 | + @AfterReturning("logPoinCut()") | |
| 35 | + public void saveSysLog(JoinPoint joinPoint) { | |
| 36 | + System.out.println("切面。。。。。"); | |
| 37 | + //日志实体 | |
| 38 | + LymsLogsCrud lymsLogsCrud = new LymsLogsCrud(); | |
| 39 | + | |
| 40 | + //从切面织入点处通过反射机制获取织入点处的方法 | |
| 41 | +// MethodSignature signature = (MethodSignature) joinPoint.getSignature(); | |
| 42 | + //获取切入点所在的方法 | |
| 43 | +// Method method = signature.getMethod(); | |
| 44 | + | |
| 45 | + //获取操作 | |
| 46 | +// LogAnnotation logAnnotation =method.getAnnotation(LogAnnotation.class); | |
| 47 | +// if (logAnnotation != null) { | |
| 48 | +// String value = logAnnotation.value(); | |
| 49 | +// lymsLogsCrud.setCrud(value);//保存获取的操作 | |
| 50 | +// } | |
| 51 | + | |
| 52 | + //获取请求的类名 | |
| 53 | +// String className = joinPoint.getTarget().getClass().getName(); | |
| 54 | + //获取请求的方法名 | |
| 55 | +// String methodName = method.getName(); | |
| 56 | +// lymsLogsCrud.setMethod(className + "." + methodName); | |
| 57 | + | |
| 58 | + //请求的参数 | |
| 59 | +// Object[] args = joinPoint.getArgs(); | |
| 60 | + //将参数所在的数组转换成json | |
| 61 | +// String params = JSON.toJSONString(args); | |
| 62 | +// lymsLogsCrud.setParams(params); | |
| 63 | + | |
| 64 | +// lymsLogsCrud.setCreatdata(new Date()); | |
| 65 | + //获取用户名 | |
| 66 | +// lymsLogsCrud.setUsername(ShiroUtils.getUserEntity().getUsername()); | |
| 67 | + | |
| 68 | + | |
| 69 | + //调用service保存 LymsLogsCrud实体类到数据库 | |
| 70 | +// lymsLogsCrudService.save(lymsLogsCrud); | |
| 71 | + } | |
| 72 | +} |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/config/DataScopeInterceptor.java
View file @
6a1ca22
| ... | ... | @@ -35,15 +35,15 @@ |
| 35 | 35 | if (!SqlCommandType.SELECT.equals(mappedStatement.getSqlCommandType())) { |
| 36 | 36 | return invocation.proceed(); |
| 37 | 37 | } |
| 38 | - if (!SqlCommandType.INSERT.equals(mappedStatement.getSqlCommandType())) { | |
| 38 | + if (SqlCommandType.INSERT.equals(mappedStatement.getSqlCommandType())) { | |
| 39 | 39 | System.out.println("新增。。。。。。。。。。。。。。。。。。。。。。。。"); |
| 40 | 40 | return invocation.proceed(); |
| 41 | 41 | } |
| 42 | - if (!SqlCommandType.UPDATE.equals(mappedStatement.getSqlCommandType())) { | |
| 42 | + if (SqlCommandType.UPDATE.equals(mappedStatement.getSqlCommandType())) { | |
| 43 | 43 | System.out.println("修改。。。。。。。。。。。。。。。。。。。。。。。。"); |
| 44 | 44 | return invocation.proceed(); |
| 45 | 45 | } |
| 46 | - if (!SqlCommandType.DELETE.equals(mappedStatement.getSqlCommandType())) { | |
| 46 | + if (SqlCommandType.DELETE.equals(mappedStatement.getSqlCommandType())) { | |
| 47 | 47 | System.out.println("删除。。。。。。。。。。。。。。。。。。。。。。。。"); |
| 48 | 48 | return invocation.proceed(); |
| 49 | 49 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/HospitalController.java
View file @
6a1ca22
| ... | ... | @@ -4,10 +4,12 @@ |
| 4 | 4 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| 5 | 5 | import com.lyms.talkonlineweb.domain.LymsDict; |
| 6 | 6 | import com.lyms.talkonlineweb.domain.LymsHospital; |
| 7 | +import com.lyms.talkonlineweb.domain.LymsLogsCrud; | |
| 7 | 8 | import com.lyms.talkonlineweb.domain.LymsRole; |
| 8 | 9 | import com.lyms.talkonlineweb.result.BaseResponse; |
| 9 | 10 | import com.lyms.talkonlineweb.service.LymsDictService; |
| 10 | 11 | import com.lyms.talkonlineweb.service.LymsHospitalService; |
| 12 | +import com.lyms.talkonlineweb.service.LymsLogsCrudService; | |
| 11 | 13 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | 14 | import org.springframework.web.bind.annotation.*; |
| 13 | 15 | |
| ... | ... | @@ -27,6 +29,9 @@ |
| 27 | 29 | @Autowired |
| 28 | 30 | private LymsHospitalService lymsHospitalService; |
| 29 | 31 | |
| 32 | + @Autowired | |
| 33 | + private LymsLogsCrudService lymsLogsCrudService; | |
| 34 | + | |
| 30 | 35 | /** |
| 31 | 36 | * 获取医院列表 |
| 32 | 37 | * @param hospital |
| ... | ... | @@ -114,6 +119,15 @@ |
| 114 | 119 | hospital.setUpdatedtime(new Date()); |
| 115 | 120 | } |
| 116 | 121 | boolean f=lymsHospitalService.saveOrUpdate(hospital); |
| 122 | + | |
| 123 | + //操作记录 | |
| 124 | + LymsLogsCrud lymsLogsCrud=new LymsLogsCrud(); | |
| 125 | + lymsLogsCrud.setUname(hospital.getCreator()); | |
| 126 | + lymsLogsCrud.setCrudtype(hospital.getHid()==null?"新增医院":"编辑医院"); | |
| 127 | + lymsLogsCrud.setHname(hospital.getHname()); | |
| 128 | + lymsLogsCrud.setCreatdata(new Date()); | |
| 129 | + lymsLogsCrudService.save(lymsLogsCrud); | |
| 130 | + | |
| 117 | 131 | baseResponse.setErrorcode(f==true?0:1); |
| 118 | 132 | return baseResponse; |
| 119 | 133 | } |
| ... | ... | @@ -127,6 +141,7 @@ |
| 127 | 141 | public BaseResponse delHosp(int hid){ |
| 128 | 142 | BaseResponse baseResponse=new BaseResponse(); |
| 129 | 143 | boolean f=lymsHospitalService.removeById(hid); |
| 144 | + | |
| 130 | 145 | baseResponse.setErrorcode(f==true?0:1); |
| 131 | 146 | return baseResponse; |
| 132 | 147 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/LymsLogsController.java
View file @
6a1ca22
| 1 | +package com.lyms.talkonlineweb.controller; | |
| 2 | + | |
| 3 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
| 4 | +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |
| 5 | +import com.lyms.talkonlineweb.domain.LymsLogsCrud; | |
| 6 | +import com.lyms.talkonlineweb.result.BaseResponse; | |
| 7 | +import com.lyms.talkonlineweb.service.LymsLogsCrudService; | |
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 9 | +import org.springframework.web.bind.annotation.*; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 医院管理 | |
| 13 | + */ | |
| 14 | +@RestController | |
| 15 | +@RequestMapping("logs") | |
| 16 | +public class LymsLogsController { | |
| 17 | + | |
| 18 | + @Autowired | |
| 19 | + private LymsLogsCrudService lymsLogsCrudService; | |
| 20 | + /** | |
| 21 | + * 获取logscrud记录 | |
| 22 | + * | |
| 23 | + * @return | |
| 24 | + */ | |
| 25 | + @GetMapping("logscrud") | |
| 26 | + public BaseResponse logscrud(LymsLogsCrud lymsLogsCrud, int current, int size){ | |
| 27 | + BaseResponse baseResponse=new BaseResponse(); | |
| 28 | + Page<LymsLogsCrud> page=new Page<>(current,size); | |
| 29 | + Page<LymsLogsCrud> lymsLogsCrudPage=lymsLogsCrudService.page(page,Wrappers.query(lymsLogsCrud).orderByDesc("creatdata")); | |
| 30 | + baseResponse.setObject(lymsLogsCrudPage); | |
| 31 | + return baseResponse; | |
| 32 | + } | |
| 33 | +} |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsLogsCrud.java
View file @
6a1ca22
| ... | ... | @@ -22,28 +22,28 @@ |
| 22 | 22 | private Integer id; |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | - * 操作用户id | |
| 25 | + * 操作用户名字 | |
| 26 | 26 | */ |
| 27 | - @TableField(value = "uid") | |
| 28 | - private Integer uid; | |
| 27 | + @TableField(value = "uname") | |
| 28 | + private String uname; | |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | - * 1:增,2:删,3:改 | |
| 31 | + * crud相关操作 | |
| 32 | 32 | */ |
| 33 | - @TableField(value = "crud") | |
| 34 | - private Integer crud; | |
| 33 | + @TableField(value = "crudtype") | |
| 34 | + private String crudtype; | |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | - * 医院id | |
| 37 | + * 医院名称 | |
| 38 | 38 | */ |
| 39 | - @TableField(value = "hoid") | |
| 40 | - private Integer hoid; | |
| 39 | + @TableField(value = "hname") | |
| 40 | + private String hname; | |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | - * 科室id | |
| 43 | + * 科室名称 | |
| 44 | 44 | */ |
| 45 | - @TableField(value = "hdid") | |
| 46 | - private Integer hdid; | |
| 45 | + @TableField(value = "hdname") | |
| 46 | + private String hdname; | |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * 操作时间 |
| ... | ... | @@ -67,10 +67,10 @@ |
| 67 | 67 | } |
| 68 | 68 | LymsLogsCrud other = (LymsLogsCrud) that; |
| 69 | 69 | return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) |
| 70 | - && (this.getUid() == null ? other.getUid() == null : this.getUid().equals(other.getUid())) | |
| 71 | - && (this.getCrud() == null ? other.getCrud() == null : this.getCrud().equals(other.getCrud())) | |
| 72 | - && (this.getHoid() == null ? other.getHoid() == null : this.getHoid().equals(other.getHoid())) | |
| 73 | - && (this.getHdid() == null ? other.getHdid() == null : this.getHdid().equals(other.getHdid())) | |
| 70 | + && (this.getUname() == null ? other.getUname() == null : this.getUname().equals(other.getUname())) | |
| 71 | + && (this.getCrudtype() == null ? other.getCrudtype() == null : this.getCrudtype().equals(other.getCrudtype())) | |
| 72 | + && (this.getHname() == null ? other.getHname() == null : this.getHname().equals(other.getHname())) | |
| 73 | + && (this.getHdname() == null ? other.getHdname() == null : this.getHdname().equals(other.getHdname())) | |
| 74 | 74 | && (this.getCreatdata() == null ? other.getCreatdata() == null : this.getCreatdata().equals(other.getCreatdata())); |
| 75 | 75 | } |
| 76 | 76 | |
| ... | ... | @@ -79,10 +79,10 @@ |
| 79 | 79 | final int prime = 31; |
| 80 | 80 | int result = 1; |
| 81 | 81 | result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); |
| 82 | - result = prime * result + ((getUid() == null) ? 0 : getUid().hashCode()); | |
| 83 | - result = prime * result + ((getCrud() == null) ? 0 : getCrud().hashCode()); | |
| 84 | - result = prime * result + ((getHoid() == null) ? 0 : getHoid().hashCode()); | |
| 85 | - result = prime * result + ((getHdid() == null) ? 0 : getHdid().hashCode()); | |
| 82 | + result = prime * result + ((getUname() == null) ? 0 : getUname().hashCode()); | |
| 83 | + result = prime * result + ((getCrudtype() == null) ? 0 : getCrudtype().hashCode()); | |
| 84 | + result = prime * result + ((getHname() == null) ? 0 : getHname().hashCode()); | |
| 85 | + result = prime * result + ((getHdname() == null) ? 0 : getHdname().hashCode()); | |
| 86 | 86 | result = prime * result + ((getCreatdata() == null) ? 0 : getCreatdata().hashCode()); |
| 87 | 87 | return result; |
| 88 | 88 | } |
| ... | ... | @@ -94,10 +94,10 @@ |
| 94 | 94 | sb.append(" ["); |
| 95 | 95 | sb.append("Hash = ").append(hashCode()); |
| 96 | 96 | sb.append(", id=").append(id); |
| 97 | - sb.append(", uid=").append(uid); | |
| 98 | - sb.append(", crud=").append(crud); | |
| 99 | - sb.append(", hoid=").append(hoid); | |
| 100 | - sb.append(", hdid=").append(hdid); | |
| 97 | + sb.append(", uname=").append(uname); | |
| 98 | + sb.append(", crudtype=").append(crudtype); | |
| 99 | + sb.append(", hname=").append(hname); | |
| 100 | + sb.append(", hdname=").append(hdname); | |
| 101 | 101 | sb.append(", creatdata=").append(creatdata); |
| 102 | 102 | sb.append(", serialVersionUID=").append(serialVersionUID); |
| 103 | 103 | sb.append("]"); |
talkonlineweb/src/main/resources/mapper/LymsLogsCrudMapper.xml
View file @
6a1ca22
| ... | ... | @@ -6,16 +6,16 @@ |
| 6 | 6 | |
| 7 | 7 | <resultMap id="BaseResultMap" type="com.lyms.talkonlineweb.domain.LymsLogsCrud"> |
| 8 | 8 | <id property="id" column="id" jdbcType="INTEGER"/> |
| 9 | - <result property="uid" column="uid" jdbcType="INTEGER"/> | |
| 10 | - <result property="crud" column="crud" jdbcType="INTEGER"/> | |
| 11 | - <result property="hoid" column="hoid" jdbcType="INTEGER"/> | |
| 12 | - <result property="hdid" column="hdid" jdbcType="INTEGER"/> | |
| 9 | + <result property="uname" column="uname" jdbcType="VARCHAR"/> | |
| 10 | + <result property="crudtype" column="crudtype" jdbcType="VARCHAR"/> | |
| 11 | + <result property="hname" column="hname" jdbcType="VARCHAR"/> | |
| 12 | + <result property="hdname" column="hdname" jdbcType="VARCHAR"/> | |
| 13 | 13 | <result property="creatdata" column="creatdata" jdbcType="TIMESTAMP"/> |
| 14 | 14 | </resultMap> |
| 15 | 15 | |
| 16 | 16 | <sql id="Base_Column_List"> |
| 17 | - id,uid,crud, | |
| 18 | - hoid,hdid,creatdata | |
| 17 | + id,uname,crudtype, | |
| 18 | + hname,hdname,creatdata | |
| 19 | 19 | </sql> |
| 20 | 20 | </mapper> |