Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
guns-vip
Commits
a35329e0
Commit
a35329e0
authored
Feb 22, 2018
by
stylefeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
日志dao合并
parent
964f3fc2
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
91 additions
and
116 deletions
+91
-116
guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/LogController.java
+3
-7
guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/LoginLogController.java
+4
-4
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/LogDao.java
+0
-33
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/LoginLogMapper.java
+12
-0
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/OperationLogMapper.java
+11
-0
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/LogDao.xml
+0
-58
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/LoginLogMapper.xml
+25
-0
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/OperationLogMapper.xml
+28
-0
guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/DictServiceImpl.java
+5
-11
guns-admin/src/test/java/com/stylefeng/guns/system/DictTest.java
+3
-3
No files found.
guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/LogController.java
View file @
a35329e0
...
...
@@ -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
);
}
...
...
guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/LoginLogController.java
View file @
a35329e0
...
...
@@ -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
Log
Dao
logDao
;
private
Log
inLogMapper
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
=
log
Dao
.
getLoginLogs
(
page
,
beginTime
,
endTime
,
logName
,
page
.
getOrderByField
(),
page
.
isAsc
());
List
<
Map
<
String
,
Object
>>
result
=
log
inLogMapper
.
getLoginLogs
(
page
,
beginTime
,
endTime
,
logName
,
page
.
getOrderByField
(),
page
.
isAsc
());
page
.
setRecords
((
List
<
OperationLog
>)
new
LogWarpper
(
result
).
warp
());
return
super
.
packForBT
(
page
);
}
...
...
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/LogDao.java
deleted
100644 → 0
View file @
964f3fc2
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
);
}
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/LoginLogMapper.java
View file @
a35329e0
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>
...
...
@@ -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
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/OperationLogMapper.java
View file @
a35329e0
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>
...
...
@@ -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
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/LogDao.xml
deleted
100644 → 0
View file @
964f3fc2
<?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
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/LoginLogMapper.xml
View file @
a35329e0
...
...
@@ -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>
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/OperationLogMapper.xml
View file @
a35329e0
...
...
@@ -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>
guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/DictServiceImpl.java
View file @
a35329e0
...
...
@@ -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
...
...
guns-admin/src/test/java/com/stylefeng/guns/system/DictTest.java
View file @
a35329e0
package
com
.
stylefeng
.
guns
.
system
;
import
com.stylefeng.guns.base.BaseJunit
;
import
com.stylefeng.guns.modular.system.dao.Dict
Dao
;
import
com.stylefeng.guns.modular.system.dao.Dict
Mapper
;
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
Dict
Dao
dictDao
;
Dict
Mapper
dictMapper
;
@Test
public
void
addTest
()
{
...
...
@@ -43,7 +43,7 @@ public class DictTest extends BaseJunit {
@Test
public
void
listTest
()
{
List
<
Map
<
String
,
Object
>>
list
=
this
.
dict
Dao
.
list
(
"性别"
);
List
<
Map
<
String
,
Object
>>
list
=
this
.
dict
Mapper
.
list
(
"性别"
);
Assert
.
assertTrue
(
list
.
size
()
>
0
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment