江苏企业网站制作哪家好,html编辑器汉化版apk,如何快速优化网站,网络运维招聘背景#xff1a; 因为比较喜欢Layui#xff0c;因为多个项目都是从零开始就使用的layui开发的#xff0c;并且开发过程中借鉴了很多其他项目#xff08;如Ruoyi、Pear Admin#xff09;#xff0c;因此最终选用大部分Pear Admin的项目中使用的一系列解决方案#xff0c;…背景 因为比较喜欢Layui因为多个项目都是从零开始就使用的layui开发的并且开发过程中借鉴了很多其他项目如Ruoyi、Pear Admin因此最终选用大部分Pear Admin的项目中使用的一系列解决方案并再次记录一些对开发非常有帮助的一些用例 1. layui框架表格默认接收格式以及默认的分页规则为了方便开发节省代码因此统一列表返回值为了节省代码使用 PageHelper作为分页插件
Controller.java
SysLogAnnotation(operModul 日志查询, operType 查询, operDesc 操作日志查询)RequestMapping(/getSysLog)public ResultTable getSysLog(SysLog log) {PageInfoSysLog pageInfo logService.getLogList(log);return pageTable(pageInfo.getList(), pageInfo.getTotal());} serviceImpl.java
public PageInfoSysLog getLogList(SysLog s) {PageHelper.startPage(s.getPage(), s.getLimit());ListSysLog list logDao.getLogList(s);return new PageInfo(list); //操作日志中专门解析了分页插件获取的数据} mapper.java
import java.util.List;Mapper //要在java中写sql就需要这个注解 如果使用mybatis plus的基础方法那 Repository一个注解就搞定
Repository
public interface LogMapper{Select({scriptselect * from sys_log where 11 if testcreateTime !null and createTime ! \\ AND substring(createTime::text, 0, 11) gt; substring(#{createTime}, 0, 11) //数据库中的时间10位之前即可前台传的有空格所以是11 AND substring(createTime::text, 0, 11) lt; substring(#{createTime}, 14) /if if testtype !null and type ! \\ AND type #{type} /if if testresult !null and result ! \\ AND result like %|| #{result}||% /if if testusername !null and username ! \\ AND username like %|| #{username}||% /if order by createtime desc /script})ListSysLog getLogList(SysLog l); //查询操作日志}
2. 操作日志获取接口返回值时因为等保的原因公司规定需要把每一项操作的结果返回因此这时就体现出了统一返回值的好处了
if (result instanceof ResultTable) {//分页插件返回layui 格式数据returnResult operType了 ((ResultTable) result).getCount()条数据 ;
}
这样在操作日志切入类中根据返回值类型就能拿到实际的操作结果