Commit b65eb887 by fsn

日志记录的完善

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