Commit a35329e0 by stylefeng

日志dao合并

parent 964f3fc2
......@@ -2,16 +2,15 @@ package com.stylefeng.guns.modular.system.controller;
import com.baomidou.mybatisplus.mapper.SqlRunner;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.common.annotion.BussinessLog;
import com.stylefeng.guns.core.common.annotion.Permission;
import com.stylefeng.guns.core.common.constant.Const;
import com.stylefeng.guns.core.common.constant.factory.PageFactory;
import com.stylefeng.guns.core.common.constant.state.BizLogType;
import com.stylefeng.guns.core.support.BeanKit;
import com.stylefeng.guns.modular.system.dao.OperationLogMapper;
import com.stylefeng.guns.modular.system.model.OperationLog;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.support.BeanKit;
import com.stylefeng.guns.modular.system.dao.LogDao;
import com.stylefeng.guns.modular.system.warpper.LogWarpper;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
......@@ -38,9 +37,6 @@ public class LogController extends BaseController {
@Resource
private OperationLogMapper operationLogMapper;
@Resource
private LogDao logDao;
/**
* 跳转到日志管理的首页
*/
......@@ -57,7 +53,7 @@ public class LogController extends BaseController {
@ResponseBody
public Object list(@RequestParam(required = false) String beginTime, @RequestParam(required = false) String endTime, @RequestParam(required = false) String logName, @RequestParam(required = false) Integer logType) {
Page<OperationLog> page = new PageFactory<OperationLog>().defaultPage();
List<Map<String, Object>> result = logDao.getOperationLogs(page, beginTime, endTime, logName, BizLogType.valueOf(logType), page.getOrderByField(), page.isAsc());
List<Map<String, Object>> result = operationLogMapper.getOperationLogs(page, beginTime, endTime, logName, BizLogType.valueOf(logType), page.getOrderByField(), page.isAsc());
page.setRecords((List<OperationLog>) new LogWarpper(result).warp());
return super.packForBT(page);
}
......
......@@ -2,13 +2,13 @@ package com.stylefeng.guns.modular.system.controller;
import com.baomidou.mybatisplus.mapper.SqlRunner;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.common.annotion.BussinessLog;
import com.stylefeng.guns.core.common.annotion.Permission;
import com.stylefeng.guns.core.common.constant.Const;
import com.stylefeng.guns.core.common.constant.factory.PageFactory;
import com.stylefeng.guns.modular.system.dao.LoginLogMapper;
import com.stylefeng.guns.modular.system.model.OperationLog;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.modular.system.dao.LogDao;
import com.stylefeng.guns.modular.system.warpper.LogWarpper;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -32,7 +32,7 @@ public class LoginLogController extends BaseController {
private static String PREFIX = "/system/log/";
@Resource
private LogDao logDao;
private LoginLogMapper loginLogMapper;
/**
* 跳转到日志管理的首页
......@@ -50,7 +50,7 @@ public class LoginLogController extends BaseController {
@ResponseBody
public Object list(@RequestParam(required = false) String beginTime, @RequestParam(required = false) String endTime, @RequestParam(required = false) String logName) {
Page<OperationLog> page = new PageFactory<OperationLog>().defaultPage();
List<Map<String, Object>> result = logDao.getLoginLogs(page, beginTime, endTime, logName, page.getOrderByField(), page.isAsc());
List<Map<String, Object>> result = loginLogMapper.getLoginLogs(page, beginTime, endTime, logName, page.getOrderByField(), page.isAsc());
page.setRecords((List<OperationLog>) new LogWarpper(result).warp());
return super.packForBT(page);
}
......
package com.stylefeng.guns.modular.system.dao;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.modular.system.model.OperationLog;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 日志记录dao
*
* @author stylefeng
* @Date 2017/4/16 23:44
*/
public interface LogDao {
/**
* 获取操作日志
*
* @author stylefeng
* @Date 2017/4/16 23:48
*/
List<Map<String, Object>> getOperationLogs(@Param("page") Page<OperationLog> page, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("logName") String logName, @Param("logType") String logType, @Param("orderByField") String orderByField, @Param("isAsc") boolean isAsc);
/**
* 获取登录日志
*
* @author stylefeng
* @Date 2017/4/16 23:48
*/
List<Map<String, Object>> getLoginLogs(@Param("page") Page<OperationLog> page, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("logName") String logName, @Param("orderByField") String orderByField, @Param("isAsc") boolean isAsc);
}
package com.stylefeng.guns.modular.system.dao;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.modular.system.model.LoginLog;
import com.stylefeng.guns.modular.system.model.OperationLog;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* <p>
* 登录记录 Mapper 接口
* 登录记录 Mapper 接口
* </p>
*
* @author stylefeng
......@@ -13,4 +19,9 @@ import com.stylefeng.guns.modular.system.model.LoginLog;
*/
public interface LoginLogMapper extends BaseMapper<LoginLog> {
/**
* 获取登录日志
*/
List<Map<String, Object>> getLoginLogs(@Param("page") Page<OperationLog> page, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("logName") String logName, @Param("orderByField") String orderByField, @Param("isAsc") boolean isAsc);
}
\ No newline at end of file
package com.stylefeng.guns.modular.system.dao;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.modular.system.model.OperationLog;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* <p>
* 操作日志 Mapper 接口
* 操作日志 Mapper 接口
* </p>
*
* @author stylefeng
......@@ -13,4 +18,9 @@ import com.stylefeng.guns.modular.system.model.OperationLog;
*/
public interface OperationLogMapper extends BaseMapper<OperationLog> {
/**
* 获取操作日志
*/
List<Map<String, Object>> getOperationLogs(@Param("page") Page<OperationLog> page, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("logName") String logName, @Param("logType") String logType, @Param("orderByField") String orderByField, @Param("isAsc") boolean isAsc);
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.stylefeng.guns.modular.system.dao.LogDao">
<select id="getOperationLogs" resultType="map">
select * from sys_operation_log where 1 = 1
<if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
and (createTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
</if>
<if test="logName != null and logName !=''">
and logname like CONCAT('%',#{logName},'%')
</if>
<if test="logType != null and logType !=''">
and logtype like CONCAT('%',#{logType},'%')
</if>
<choose>
<when test="orderByField != null and orderByField !=''">
<choose>
<when test="isAsc == true">
order by ${orderByField} ASC
</when>
<otherwise>
order by ${orderByField} DESC
</otherwise>
</choose>
</when>
<otherwise>
order by createtime DESC
</otherwise>
</choose>
</select>
<select id="getLoginLogs" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page">
select * from sys_login_log where 1 = 1
<if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
and (createTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
</if>
<if test="logName != null and logName !=''">
and logname like CONCAT('%',#{logName},'%')
</if>
<choose>
<when test="orderByField != null and orderByField !=''">
<choose>
<when test="isAsc == true">
order by ${orderByField} ASC
</when>
<otherwise>
order by ${orderByField} DESC
</otherwise>
</choose>
</when>
<otherwise>
order by createtime DESC
</otherwise>
</choose>
</select>
</mapper>
\ No newline at end of file
......@@ -13,4 +13,29 @@
<result column="ip" property="ip" />
</resultMap>
<select id="getLoginLogs" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page">
select * from sys_login_log where 1 = 1
<if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
and (createTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
</if>
<if test="logName != null and logName !=''">
and logname like CONCAT('%',#{logName},'%')
</if>
<choose>
<when test="orderByField != null and orderByField !=''">
<choose>
<when test="isAsc == true">
order by ${orderByField} ASC
</when>
<otherwise>
order by ${orderByField} DESC
</otherwise>
</choose>
</when>
<otherwise>
order by createtime DESC
</otherwise>
</choose>
</select>
</mapper>
......@@ -15,4 +15,32 @@
<result column="message" property="message" />
</resultMap>
<select id="getOperationLogs" resultType="map">
select * from sys_operation_log where 1 = 1
<if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
and (createTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
</if>
<if test="logName != null and logName !=''">
and logname like CONCAT('%',#{logName},'%')
</if>
<if test="logType != null and logType !=''">
and logtype like CONCAT('%',#{logType},'%')
</if>
<choose>
<when test="orderByField != null and orderByField !=''">
<choose>
<when test="isAsc == true">
order by ${orderByField} ASC
</when>
<otherwise>
order by ${orderByField} DESC
</otherwise>
</choose>
</when>
<otherwise>
order by createtime DESC
</otherwise>
</choose>
</select>
</mapper>
......@@ -3,10 +3,9 @@ package com.stylefeng.guns.modular.system.service.impl;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.stylefeng.guns.core.common.exception.BizExceptionEnum;
import com.stylefeng.guns.core.exception.GunsException;
import com.stylefeng.guns.modular.system.dao.DictMapper;
import com.stylefeng.guns.modular.system.model.Dict;
import com.stylefeng.guns.core.exception.GunsException;
import com.stylefeng.guns.modular.system.dao.DictDao;
import com.stylefeng.guns.modular.system.service.IDictService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -15,25 +14,20 @@ import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import static com.stylefeng.guns.core.common.constant.factory.MutiStrFactory.MUTI_STR_KEY;
import static com.stylefeng.guns.core.common.constant.factory.MutiStrFactory.MUTI_STR_VALUE;
import static com.stylefeng.guns.core.common.constant.factory.MutiStrFactory.parseKeyValue;
import static com.stylefeng.guns.core.common.constant.factory.MutiStrFactory.*;
@Service
@Transactional
public class DictServiceImpl implements IDictService {
@Resource
DictDao dictDao;
@Resource
DictMapper dictMapper;
@Override
public void addDict(String dictName, String dictValues) {
//判断有没有该字典
List<Dict> dicts = dictMapper.selectList(new EntityWrapper<Dict>().eq("name", dictName).and().eq("pid", 0));
if(dicts != null && dicts.size() > 0){
if (dicts != null && dicts.size() > 0) {
throw new GunsException(BizExceptionEnum.DICT_EXISTED);
}
......@@ -56,7 +50,7 @@ public class DictServiceImpl implements IDictService {
itemDict.setName(name);
try {
itemDict.setNum(Integer.valueOf(num));
}catch (NumberFormatException e){
} catch (NumberFormatException e) {
throw new GunsException(BizExceptionEnum.DICT_MUST_BE_NUMBER);
}
this.dictMapper.insert(itemDict);
......@@ -69,7 +63,7 @@ public class DictServiceImpl implements IDictService {
this.delteDict(dictId);
//重新添加新的字典
this.addDict(dictName,dicts);
this.addDict(dictName, dicts);
}
@Override
......
package com.stylefeng.guns.system;
import com.stylefeng.guns.base.BaseJunit;
import com.stylefeng.guns.modular.system.dao.DictDao;
import com.stylefeng.guns.modular.system.dao.DictMapper;
import com.stylefeng.guns.modular.system.service.IDictService;
import org.junit.Assert;
import org.junit.Test;
......@@ -22,7 +22,7 @@ public class DictTest extends BaseJunit {
IDictService dictService;
@Resource
DictDao dictDao;
DictMapper dictMapper;
@Test
public void addTest() {
......@@ -43,7 +43,7 @@ public class DictTest extends BaseJunit {
@Test
public void listTest() {
List<Map<String, Object>> list = this.dictDao.list("性别");
List<Map<String, Object>> list = this.dictMapper.list("性别");
Assert.assertTrue(list.size() > 0);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment