Commit b65eb887 by fsn

日志记录的完善

parent a1c700f4
...@@ -59,7 +59,6 @@ ...@@ -59,7 +59,6 @@
<groupId>org.apache.velocity</groupId> <groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId> <artifactId>velocity</artifactId>
<version>1.7</version> <version>1.7</version>
<scope>test</scope>
</dependency> </dependency>
<!--END--> <!--END-->
......
package com.stylefeng.guns.common.constant;
/**
* 一些服务的快捷获取
*
* @author fengshuonan
* @date 2017-03-30 15:58
*/
public class Cst {
private Cst() {
}
private static Cst cst = new Cst();
public static Cst me() {
return cst;
}
}
package com.stylefeng.guns.common.constant;
/**
* 多数据源的枚举
*
* @author fengshuonan
* @date 2017年3月5日 上午10:15:02
*/
public interface DSEnum {
String dataSourceGuns = "dataSourceGuns"; //Guns的数据源
}
package com.stylefeng.guns.common.constant.state;
/**
* 用户的状态
*
* @author fengshuonan
* @Date 2017年1月22日 下午12:14:59
*/
public enum LogSucceed {
SUCCESS("成功"),
FAIL("失败");
String message;
LogSucceed(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
package com.stylefeng.guns.common.constant.state;
/**
* 用户的状态
*
* @author fengshuonan
* @Date 2017年1月22日 下午12:14:59
*/
public enum LogType {
LOGIN("登录日志"),
EXIT("退出日志"),
EXCEPTION("异常日志"),
BUSSINESS("业务日志");
String message;
LogType(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
...@@ -91,7 +91,7 @@ public class BaseController { ...@@ -91,7 +91,7 @@ public class BaseController {
* @date 2017年2月28日 下午2:53:19 * @date 2017年2月28日 下午2:53:19
*/ */
protected ResponseEntity<byte[]> renderFile(String fileName, String filePath) { protected ResponseEntity<byte[]> renderFile(String fileName, String filePath) {
byte[] bytes = FileUtil.toByteArray2(filePath); byte[] bytes = FileUtil.toByteArray(filePath);
return renderFile(fileName, bytes); return renderFile(fileName, bytes);
} }
......
...@@ -3,10 +3,9 @@ package com.stylefeng.guns.core.aop; ...@@ -3,10 +3,9 @@ package com.stylefeng.guns.core.aop;
import com.stylefeng.guns.common.constant.tips.ErrorTip; import com.stylefeng.guns.common.constant.tips.ErrorTip;
import com.stylefeng.guns.common.exception.BizExceptionEnum; import com.stylefeng.guns.common.exception.BizExceptionEnum;
import com.stylefeng.guns.common.exception.BussinessException; import com.stylefeng.guns.common.exception.BussinessException;
import com.stylefeng.guns.core.log.ILog; import com.stylefeng.guns.core.log.LogManager;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.support.HttpKit; import com.stylefeng.guns.core.support.HttpKit;
import com.stylefeng.guns.core.util.SpringContextHolder;
import com.stylefeng.guns.core.util.ToolUtil;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.CredentialsException; import org.apache.shiro.authc.CredentialsException;
...@@ -33,9 +32,6 @@ public class GlobalExceptionHandler { ...@@ -33,9 +32,6 @@ public class GlobalExceptionHandler {
private Logger log = Logger.getLogger(this.getClass()); private Logger log = Logger.getLogger(this.getClass());
private ILog logFactory = SpringContextHolder.getBean(ILog.class);
/** /**
* 拦截业务异常 * 拦截业务异常
* *
...@@ -45,7 +41,7 @@ public class GlobalExceptionHandler { ...@@ -45,7 +41,7 @@ public class GlobalExceptionHandler {
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody @ResponseBody
public ErrorTip notFount(BussinessException e) { public ErrorTip notFount(BussinessException e) {
logFactory.doLog("业务异常", e.toString(), false); LogManager.exceptionLog(ShiroKit.getUser().getId(), e);
HttpKit.getRequest().setAttribute("tip", e.getMessage()); HttpKit.getRequest().setAttribute("tip", e.getMessage());
return new ErrorTip(e.getCode(), e.getMessage()); return new ErrorTip(e.getCode(), e.getMessage());
} }
...@@ -59,9 +55,7 @@ public class GlobalExceptionHandler { ...@@ -59,9 +55,7 @@ public class GlobalExceptionHandler {
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody @ResponseBody
public ErrorTip notFount(RuntimeException e) { public ErrorTip notFount(RuntimeException e) {
String msg = ToolUtil.getExceptionMsg(e); LogManager.exceptionLog(ShiroKit.getUser().getId(), e);
logFactory.doLog("Runtime异常", msg, false);
log.error("服务器异常:", e);
HttpKit.getRequest().setAttribute("tip", "服务器未知运行时异常"); HttpKit.getRequest().setAttribute("tip", "服务器未知运行时异常");
return new ErrorTip(BizExceptionEnum.SERVER_ERROR); return new ErrorTip(BizExceptionEnum.SERVER_ERROR);
} }
......
package com.stylefeng.guns.core.aop; package com.stylefeng.guns.core.aop;
import com.stylefeng.guns.core.log.ILog; import com.stylefeng.guns.core.log.LogManager;
import com.stylefeng.guns.core.shiro.ShiroKit; import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.shiro.ShiroUser; import com.stylefeng.guns.core.shiro.ShiroUser;
import com.stylefeng.guns.core.support.StrKit; import com.stylefeng.guns.core.support.StrKit;
...@@ -12,14 +12,14 @@ import org.aspectj.lang.annotation.Around; ...@@ -12,14 +12,14 @@ import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature; import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.lang.reflect.Method; import java.lang.reflect.Method;
/** /**
* 日志记录
*
* @author fengshuonan * @author fengshuonan
* @Description 日志记录
* @date 2016年12月6日 下午8:48:30 * @date 2016年12月6日 下午8:48:30
*/ */
@Aspect @Aspect
...@@ -28,9 +28,6 @@ public class LogAop { ...@@ -28,9 +28,6 @@ public class LogAop {
private Logger log = Logger.getLogger(this.getClass()); private Logger log = Logger.getLogger(this.getClass());
@Autowired
ILog factory;
@Pointcut("execution(* com.stylefeng.guns..service.*.*(..))") @Pointcut("execution(* com.stylefeng.guns..service.*.*(..))")
public void cutService() { public void cutService() {
} }
...@@ -60,9 +57,9 @@ public class LogAop { ...@@ -60,9 +57,9 @@ public class LogAop {
} }
String msg = ToolUtil.format("[时间]:{} [类名]:{} [方法]:{} [参数]:{}", DateUtil.getTime(), className, methodName, sb.toString()); String msg = ToolUtil.format("[时间]:{} [类名]:{} [方法]:{} [参数]:{}", DateUtil.getTime(), className, methodName, sb.toString());
log.info(StrKit.removeSuffix(msg, "& ")); msg = StrKit.removeSuffix(msg, "& ");
factory.doLog(methodName, StrKit.removeSuffix(msg, "& "), true); log.info(msg);
LogManager.bussinessLog(user.getId(),className,methodName,msg);
return point.proceed(); return point.proceed();
} }
} }
\ No newline at end of file
...@@ -10,15 +10,13 @@ import java.util.List; ...@@ -10,15 +10,13 @@ import java.util.List;
* <p> * <p>
* 便捷数据库操作类 * 便捷数据库操作类
* <p> * <p>
*
* <p> * <p>
* 本类的两种情景:<br> * 本类的使用情景:
* <br> * <p>
* 1.现有Mapper不满足简单业务的查询!<br> * 1.单纯想创建现有的Mapper
* Db.create(UserLoginMapper.class).selectByPhone("18200001111");<br> * <p>例如:
* <br>
* 2.单纯想创建现有的Mapper<br>
* Db.getMapper(UserLoginMapper.class).selectById("14779707158513204");<br> * Db.getMapper(UserLoginMapper.class).selectById("14779707158513204");<br>
* <p>
* *
* @author fengshuonan * @author fengshuonan
* @date 2017年2月22日 下午8:07:17 * @date 2017年2月22日 下午8:07:17
......
package com.stylefeng.guns.core.log;
import java.util.HashMap;
/**
* 方法名和具体日志记录名称的映射管理
*
* @author fengshuonan
* @date 2017-03-30 19:22
*/
public class ConcreteLogNameHolder {
private HashMap<String, String> mapping = new HashMap<>();
private void init(){
mapping.put("setAuthority","分配角色权限");
}
private ConcreteLogNameHolder() {
init();
}
private static ConcreteLogNameHolder holder = new ConcreteLogNameHolder();
public static ConcreteLogNameHolder me(){
return holder;
}
public String get(String key){
return mapping.get(key);
}
}
package com.stylefeng.guns.core.log;
/**
* 日志记录的接口
*
* @author fengshuonan
* @date 2016年12月6日 下午9:17:23
*/
public interface ILog {
/**
* 日志记录
*
* @author fengshuonan
*/
void doLog(String logName, String msg, boolean succeed);
}
package com.stylefeng.guns.core.log; package com.stylefeng.guns.core.log;
import com.stylefeng.guns.core.shiro.ShiroKit; import com.stylefeng.guns.common.constant.state.LogSucceed;
import com.stylefeng.guns.core.shiro.ShiroUser; import com.stylefeng.guns.common.constant.state.LogType;
import com.stylefeng.guns.persistence.dao.OperationLogMapper; import com.stylefeng.guns.core.support.HttpKit;
import com.stylefeng.guns.persistence.model.LoginLog;
import com.stylefeng.guns.persistence.model.OperationLog; import com.stylefeng.guns.persistence.model.OperationLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date; import java.util.Date;
/** /**
* 日志记录工厂 * 日志对象创建工厂
* *
* @author fengshuonan * @author fengshuonan
* @date 2016年12月6日 下午9:18:27 * @date 2016年12月6日 下午9:18:27
*/ */
@Component public class LogFactory {
public class LogFactory implements ILog {
@Autowired /**
OperationLogMapper operationLogMapper; * 创建操作日志
*
@Override * @author fengshuonan
public void doLog(String logName, String msg, boolean succeed) { * @Date 2017/3/30 18:45
ShiroUser user = ShiroKit.getUser(); */
OperationLog log = new OperationLog(); public static OperationLog createOperationLog(LogType logType, Integer userId, String clazzName, String methodName, String msg) {
log.setMethod(msg); OperationLog operationLog = new OperationLog();
log.setCreatetime(new Date()); operationLog.setLogtype(logType.getMessage());
log.setSucceed((succeed) ? "1" : "0"); operationLog.setLogname(ConcreteLogNameHolder.me().get(methodName));
log.setUserid(String.valueOf(user.getId())); operationLog.setUserid(userId);
log.setLogname(logName); operationLog.setClassname(clazzName);
try { operationLog.setMethod(methodName);
operationLogMapper.insert(log); operationLog.setCreatetime(new Date());
}catch (Exception e){ operationLog.setSucceed(LogSucceed.SUCCESS.getMessage());
//e.printStackTrace(); operationLog.setMessage(msg);
return operationLog;
} }
/**
* 创建登录日志
*
* @author fengshuonan
* @Date 2017/3/30 18:46
*/
public static LoginLog createLoginLog(LogType logType, Integer userId) {
LoginLog loginLog = new LoginLog();
loginLog.setLogname(logType.getMessage());
loginLog.setUserid(userId);
loginLog.setCreatetime(new Date());
loginLog.setSucceed(LogSucceed.SUCCESS.getMessage());
loginLog.setIp(HttpKit.getRequest().getRemoteHost());
return loginLog;
} }
} }
package com.stylefeng.guns.core.log;
import com.stylefeng.guns.common.constant.state.LogType;
import com.stylefeng.guns.core.db.Db;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.persistence.dao.LoginLogMapper;
import com.stylefeng.guns.persistence.dao.OperationLogMapper;
import com.stylefeng.guns.persistence.model.LoginLog;
import com.stylefeng.guns.persistence.model.OperationLog;
import org.apache.log4j.Logger;
/**
* 日志管理器
*
* @author fengshuonan
* @date 2017-03-30 16:29
*/
public class LogManager {
private static Logger logger = Logger.getLogger(LogManager.class);
private static LoginLogMapper loginLogMapper = Db.getMapper(LoginLogMapper.class);
private static OperationLogMapper operationLogMapper = Db.getMapper(OperationLogMapper.class);
public static void loginLog(Integer userId) {
LoginLog loginLog = LogFactory.createLoginLog(LogType.LOGIN, userId);
try {
loginLogMapper.insert(loginLog);
} catch (Exception e) {
logger.error("创建登录日志异常!", e);
}
}
public static void exitLog(Integer userId) {
LoginLog loginLog = LogFactory.createLoginLog(LogType.EXIT, userId);
try {
loginLogMapper.insert(loginLog);
} catch (Exception e) {
logger.error("创建退出日志异常!", e);
}
}
public static void bussinessLog(Integer userId, String clazzName, String methodName, String msg) {
OperationLog operationLog = LogFactory.createOperationLog(LogType.BUSSINESS, userId, clazzName, methodName, msg);
try {
operationLogMapper.insert(operationLog);
} catch (Exception e) {
logger.error("创建业务日志异常!", e);
}
}
public static void exceptionLog(Integer userId, Exception exception) {
String msg = ToolUtil.getExceptionMsg(exception);
OperationLog operationLog = LogFactory.createOperationLog(LogType.EXCEPTION, userId, "", "", msg);
try {
operationLogMapper.insert(operationLog);
} catch (Exception e) {
logger.error("创建异常日志异常!", e);
}
}
}
package com.stylefeng.guns.core.util; package com.stylefeng.guns.core.util;
import com.stylefeng.guns.common.exception.BizExceptionEnum;
import com.stylefeng.guns.common.exception.BussinessException;
import org.apache.log4j.Logger;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import org.apache.log4j.Logger;
import com.stylefeng.guns.common.exception.BizExceptionEnum;
import com.stylefeng.guns.common.exception.BussinessException;
public class FileUtil { public class FileUtil {
private static Logger log = Logger.getLogger(FileUtil.class); private static Logger log = Logger.getLogger(FileUtil.class);
...@@ -18,7 +17,7 @@ public class FileUtil { ...@@ -18,7 +17,7 @@ public class FileUtil {
/** /**
* NIO way * NIO way
*/ */
public static byte[] toByteArray2(String filename) { public static byte[] toByteArray(String filename) {
File f = new File(filename); File f = new File(filename);
if (!f.exists()) { if (!f.exists()) {
......
package com.stylefeng.guns.modular.system.controller; package com.stylefeng.guns.modular.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.stylefeng.guns.common.controller.BaseController; import com.stylefeng.guns.common.controller.BaseController;
import com.stylefeng.guns.common.node.MenuNode;
import com.stylefeng.guns.core.log.LogManager;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.shiro.ShiroUser;
import com.stylefeng.guns.modular.system.dao.MenuDao;
import org.apache.shiro.authc.UsernamePasswordToken; import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject; import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -13,10 +14,7 @@ import org.springframework.ui.Model; ...@@ -13,10 +14,7 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import com.stylefeng.guns.common.node.MenuNode; import java.util.List;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.shiro.ShiroUser;
import com.stylefeng.guns.modular.system.dao.MenuDao;
/** /**
* 登录控制器 * 登录控制器
...@@ -60,7 +58,7 @@ public class LoginController extends BaseController { ...@@ -60,7 +58,7 @@ public class LoginController extends BaseController {
* 点击登录执行的动作 * 点击登录执行的动作
*/ */
@RequestMapping(value = "/login", method = RequestMethod.POST) @RequestMapping(value = "/login", method = RequestMethod.POST)
public String loginVali(HttpServletRequest req) { public String loginVali() {
String username = super.getPara("username"); String username = super.getPara("username");
String password = super.getPara("password"); String password = super.getPara("password");
...@@ -73,6 +71,8 @@ public class LoginController extends BaseController { ...@@ -73,6 +71,8 @@ public class LoginController extends BaseController {
ShiroUser shiroUser = ShiroKit.getUser(); ShiroUser shiroUser = ShiroKit.getUser();
super.getSession().setAttribute("shiroUser", shiroUser); super.getSession().setAttribute("shiroUser", shiroUser);
LogManager.loginLog(shiroUser.getId());
return REDIRECT + "/"; return REDIRECT + "/";
} }
...@@ -81,6 +81,7 @@ public class LoginController extends BaseController { ...@@ -81,6 +81,7 @@ public class LoginController extends BaseController {
*/ */
@RequestMapping(value = "/logout", method = RequestMethod.GET) @RequestMapping(value = "/logout", method = RequestMethod.GET)
public String logOut() { public String logOut() {
LogManager.exitLog(ShiroKit.getUser().getId());
ShiroKit.getSubject().logout(); ShiroKit.getSubject().logout();
super.getSession().invalidate(); super.getSession().invalidate();
return REDIRECT + "/login"; return REDIRECT + "/login";
......
...@@ -48,6 +48,9 @@ public class MenuController extends BaseController { ...@@ -48,6 +48,9 @@ public class MenuController extends BaseController {
*/ */
@RequestMapping("") @RequestMapping("")
public String index() { public String index() {
int i = 1/0;
return PREFIX + "menu.html"; return PREFIX + "menu.html";
} }
......
...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper; ...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
public interface AttachMapper extends BaseMapper<Attach> { public interface AttachMapper extends BaseMapper<Attach> {
......
...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper; ...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
public interface DeptMapper extends BaseMapper<Dept> { public interface DeptMapper extends BaseMapper<Dept> {
......
...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper; ...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
public interface DictMapper extends BaseMapper<Dict> { public interface DictMapper extends BaseMapper<Dict> {
......
...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper; ...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
public interface GenerateMapper extends BaseMapper<Generate> { public interface GenerateMapper extends BaseMapper<Generate> {
......
...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper; ...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
public interface LoginLogMapper extends BaseMapper<LoginLog> { public interface LoginLogMapper extends BaseMapper<LoginLog> {
......
...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper; ...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
public interface MenuMapper extends BaseMapper<Menu> { public interface MenuMapper extends BaseMapper<Menu> {
......
...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper; ...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
public interface NoticeMapper extends BaseMapper<Notice> { public interface NoticeMapper extends BaseMapper<Notice> {
......
...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper; ...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
public interface OperationLogMapper extends BaseMapper<OperationLog> { public interface OperationLogMapper extends BaseMapper<OperationLog> {
......
...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper; ...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
public interface ParameterMapper extends BaseMapper<Parameter> { public interface ParameterMapper extends BaseMapper<Parameter> {
......
...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper; ...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
public interface RelationMapper extends BaseMapper<Relation> { public interface RelationMapper extends BaseMapper<Relation> {
......
...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper; ...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
public interface RoleExtMapper extends BaseMapper<RoleExt> { public interface RoleExtMapper extends BaseMapper<RoleExt> {
......
...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper; ...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
public interface RoleMapper extends BaseMapper<Role> { public interface RoleMapper extends BaseMapper<Role> {
......
...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper; ...@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
public interface UserMapper extends BaseMapper<User> { public interface UserMapper extends BaseMapper<User> {
......
...@@ -7,11 +7,10 @@ ...@@ -7,11 +7,10 @@
<id column="id" property="id" /> <id column="id" property="id" />
<result column="logname" property="logname" /> <result column="logname" property="logname" />
<result column="userid" property="userid" /> <result column="userid" property="userid" />
<result column="classname" property="classname" />
<result column="method" property="method" />
<result column="createtime" property="createtime" /> <result column="createtime" property="createtime" />
<result column="succeed" property="succeed" /> <result column="succeed" property="succeed" />
<result column="message" property="message" /> <result column="message" property="message" />
<result column="ip" property="ip" />
</resultMap> </resultMap>
</mapper> </mapper>
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<!-- 通用查询映射结果 --> <!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.stylefeng.guns.persistence.model.OperationLog"> <resultMap id="BaseResultMap" type="com.stylefeng.guns.persistence.model.OperationLog">
<id column="id" property="id" /> <id column="id" property="id" />
<result column="logtype" property="logtype" />
<result column="logname" property="logname" /> <result column="logname" property="logname" />
<result column="userid" property="userid" /> <result column="userid" property="userid" />
<result column="classname" property="classname" /> <result column="classname" property="classname" />
......
...@@ -13,7 +13,7 @@ import com.baomidou.mybatisplus.annotations.TableId; ...@@ -13,7 +13,7 @@ import com.baomidou.mybatisplus.annotations.TableId;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
@TableName("_attach") @TableName("_attach")
public class Attach extends Model<Attach> { public class Attach extends Model<Attach> {
......
...@@ -12,7 +12,7 @@ import com.baomidou.mybatisplus.annotations.TableId; ...@@ -12,7 +12,7 @@ import com.baomidou.mybatisplus.annotations.TableId;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
@TableName("_dept") @TableName("_dept")
public class Dept extends Model<Dept> { public class Dept extends Model<Dept> {
......
...@@ -12,7 +12,7 @@ import com.baomidou.mybatisplus.annotations.TableId; ...@@ -12,7 +12,7 @@ import com.baomidou.mybatisplus.annotations.TableId;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
@TableName("_dict") @TableName("_dict")
public class Dict extends Model<Dict> { public class Dict extends Model<Dict> {
......
...@@ -12,7 +12,7 @@ import com.baomidou.mybatisplus.annotations.TableId; ...@@ -12,7 +12,7 @@ import com.baomidou.mybatisplus.annotations.TableId;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
@TableName("_generate") @TableName("_generate")
public class Generate extends Model<Generate> { public class Generate extends Model<Generate> {
......
...@@ -13,7 +13,7 @@ import com.baomidou.mybatisplus.annotations.TableId; ...@@ -13,7 +13,7 @@ import com.baomidou.mybatisplus.annotations.TableId;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
@TableName("_login_log") @TableName("_login_log")
public class LoginLog extends Model<LoginLog> { public class LoginLog extends Model<LoginLog> {
...@@ -23,12 +23,11 @@ public class LoginLog extends Model<LoginLog> { ...@@ -23,12 +23,11 @@ public class LoginLog extends Model<LoginLog> {
@TableId @TableId
private Integer id; private Integer id;
private String logname; private String logname;
private String userid; private Integer userid;
private String classname;
private String method;
private Date createtime; private Date createtime;
private String succeed; private String succeed;
private String message; private String message;
private String ip;
public Integer getId() { public Integer getId() {
...@@ -47,30 +46,14 @@ public class LoginLog extends Model<LoginLog> { ...@@ -47,30 +46,14 @@ public class LoginLog extends Model<LoginLog> {
this.logname = logname; this.logname = logname;
} }
public String getUserid() { public Integer getUserid() {
return userid; return userid;
} }
public void setUserid(String userid) { public void setUserid(Integer userid) {
this.userid = userid; this.userid = userid;
} }
public String getClassname() {
return classname;
}
public void setClassname(String classname) {
this.classname = classname;
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public Date getCreatetime() { public Date getCreatetime() {
return createtime; return createtime;
} }
...@@ -95,6 +78,14 @@ public class LoginLog extends Model<LoginLog> { ...@@ -95,6 +78,14 @@ public class LoginLog extends Model<LoginLog> {
this.message = message; this.message = message;
} }
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
@Override @Override
protected Serializable pkVal() { protected Serializable pkVal() {
return this.id; return this.id;
......
...@@ -12,7 +12,7 @@ import com.baomidou.mybatisplus.annotations.TableId; ...@@ -12,7 +12,7 @@ import com.baomidou.mybatisplus.annotations.TableId;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
@TableName("_menu") @TableName("_menu")
public class Menu extends Model<Menu> { public class Menu extends Model<Menu> {
......
...@@ -13,7 +13,7 @@ import com.baomidou.mybatisplus.annotations.TableId; ...@@ -13,7 +13,7 @@ import com.baomidou.mybatisplus.annotations.TableId;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
@TableName("_notice") @TableName("_notice")
public class Notice extends Model<Notice> { public class Notice extends Model<Notice> {
......
package com.stylefeng.guns.persistence.model; package com.stylefeng.guns.persistence.model;
import com.baomidou.mybatisplus.activerecord.Model; import com.baomidou.mybatisplus.activerecord.Model;
import java.util.Date; import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.annotations.TableName;
import java.io.Serializable; import java.io.Serializable;
import com.baomidou.mybatisplus.annotations.TableId; import java.util.Date;
/** /**
...@@ -13,7 +14,7 @@ import com.baomidou.mybatisplus.annotations.TableId; ...@@ -13,7 +14,7 @@ import com.baomidou.mybatisplus.annotations.TableId;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
@TableName("_operation_log") @TableName("_operation_log")
public class OperationLog extends Model<OperationLog> { public class OperationLog extends Model<OperationLog> {
...@@ -22,8 +23,9 @@ public class OperationLog extends Model<OperationLog> { ...@@ -22,8 +23,9 @@ public class OperationLog extends Model<OperationLog> {
@TableId @TableId
private Integer id; private Integer id;
private String logtype;
private String logname; private String logname;
private String userid; private Integer userid;
private String classname; private String classname;
private String method; private String method;
private Date createtime; private Date createtime;
...@@ -39,6 +41,14 @@ public class OperationLog extends Model<OperationLog> { ...@@ -39,6 +41,14 @@ public class OperationLog extends Model<OperationLog> {
this.id = id; this.id = id;
} }
public String getLogtype() {
return logtype;
}
public void setLogtype(String logtype) {
this.logtype = logtype;
}
public String getLogname() { public String getLogname() {
return logname; return logname;
} }
...@@ -47,11 +57,11 @@ public class OperationLog extends Model<OperationLog> { ...@@ -47,11 +57,11 @@ public class OperationLog extends Model<OperationLog> {
this.logname = logname; this.logname = logname;
} }
public String getUserid() { public Integer getUserid() {
return userid; return userid;
} }
public void setUserid(String userid) { public void setUserid(Integer userid) {
this.userid = userid; this.userid = userid;
} }
......
...@@ -12,7 +12,7 @@ import com.baomidou.mybatisplus.annotations.TableId; ...@@ -12,7 +12,7 @@ import com.baomidou.mybatisplus.annotations.TableId;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
@TableName("_parameter") @TableName("_parameter")
public class Parameter extends Model<Parameter> { public class Parameter extends Model<Parameter> {
......
...@@ -12,7 +12,7 @@ import com.baomidou.mybatisplus.annotations.TableId; ...@@ -12,7 +12,7 @@ import com.baomidou.mybatisplus.annotations.TableId;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
@TableName("_relation") @TableName("_relation")
public class Relation extends Model<Relation> { public class Relation extends Model<Relation> {
......
...@@ -12,7 +12,7 @@ import com.baomidou.mybatisplus.annotations.TableId; ...@@ -12,7 +12,7 @@ import com.baomidou.mybatisplus.annotations.TableId;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
@TableName("_role") @TableName("_role")
public class Role extends Model<Role> { public class Role extends Model<Role> {
......
...@@ -12,7 +12,7 @@ import com.baomidou.mybatisplus.annotations.TableId; ...@@ -12,7 +12,7 @@ import com.baomidou.mybatisplus.annotations.TableId;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
@TableName("_role_ext") @TableName("_role_ext")
public class RoleExt extends Model<RoleExt> { public class RoleExt extends Model<RoleExt> {
......
...@@ -13,7 +13,7 @@ import com.baomidou.mybatisplus.annotations.TableId; ...@@ -13,7 +13,7 @@ import com.baomidou.mybatisplus.annotations.TableId;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-03-26 * @since 2017-03-30
*/ */
@TableName("_user") @TableName("_user")
public class User extends Model<User> { public class User extends Model<User> {
......
...@@ -61,8 +61,6 @@ public class MpGenerator { ...@@ -61,8 +61,6 @@ public class MpGenerator {
StrategyConfig strategy = new StrategyConfig(); StrategyConfig strategy = new StrategyConfig();
strategy.setTablePrefix(new String[]{"_"});// 此处可以修改为您的表前缀 strategy.setTablePrefix(new String[]{"_"});// 此处可以修改为您的表前缀
strategy.setNaming(NamingStrategy.remove_prefix_and_camel);// 表名生成策略 strategy.setNaming(NamingStrategy.remove_prefix_and_camel);// 表名生成策略
// strategy.setInclude(new String[] { "user" }); // 需要生成的表
// strategy.setExclude(new String[]{"test"}); // 排除生成的表
// 字段名生成策略 // 字段名生成策略
strategy.setFieldNaming(NamingStrategy.nochange); strategy.setFieldNaming(NamingStrategy.nochange);
mpg.setStrategy(strategy); mpg.setStrategy(strategy);
...@@ -73,9 +71,9 @@ public class MpGenerator { ...@@ -73,9 +71,9 @@ public class MpGenerator {
pc.setEntity("com.stylefeng.guns.persistence.model"); pc.setEntity("com.stylefeng.guns.persistence.model");
pc.setMapper("com.stylefeng.guns.persistence.dao"); pc.setMapper("com.stylefeng.guns.persistence.dao");
pc.setXml("com.stylefeng.guns.persistence.dao.mapping"); pc.setXml("com.stylefeng.guns.persistence.dao.mapping");
pc.setService("TTT"); pc.setService("TTT"); //本项目没用
pc.setServiceImpl("TTT"); pc.setServiceImpl("TTT"); //本项目没用
pc.setController("TTT"); pc.setController("TTT"); //本项目没用
mpg.setPackageInfo(pc); mpg.setPackageInfo(pc);
// 注入自定义配置,可以在 VM 中使用 cfg.abc 设置的值 // 注入自定义配置,可以在 VM 中使用 cfg.abc 设置的值
......
package com.stylefeng.guns.base; package com.stylefeng.guns.base;
import com.stylefeng.guns.core.log.ILog;
import com.stylefeng.guns.core.util.SpringContextHolder;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
...@@ -16,8 +14,6 @@ public class BaseTest { ...@@ -16,8 +14,6 @@ public class BaseTest {
@Test @Test
public void test() { public void test() {
ILog logFactory = SpringContextHolder.getBean(ILog.class);
logFactory.doLog("12", "message", true);
} }
} }
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