commit
e85019a665
|
|
@ -1,5 +1,6 @@
|
|||
package com.engine.organization.annotation;
|
||||
|
||||
import com.engine.organization.enums.LogModuleNameEnum;
|
||||
import com.engine.organization.enums.OperateTypeEnum;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
|
@ -19,4 +20,9 @@ public @interface Log {
|
|||
* 操作说明
|
||||
*/
|
||||
String operateDesc() default "";
|
||||
|
||||
/**
|
||||
* 操作模块
|
||||
*/
|
||||
LogModuleNameEnum operateModule() default LogModuleNameEnum.OTHER;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class LoggerContext implements Serializable {
|
|||
private String operatorName;
|
||||
|
||||
// 创建时间(yyyy-MM-dd HH:mm:ss)
|
||||
@JSONField(format="yyyy-MM-dd HH:mm:ss")
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
//操作类型增删改查等
|
||||
|
|
@ -58,4 +58,10 @@ public class LoggerContext implements Serializable {
|
|||
//是否删除
|
||||
private int deleteType;
|
||||
|
||||
// 操作模块名称
|
||||
private String operateModuleName;
|
||||
|
||||
// 日志信息
|
||||
private String message;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
package com.engine.organization.enums;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/07/04
|
||||
* @version: 1.0
|
||||
*/
|
||||
public enum LogModuleNameEnum {
|
||||
SCHEME("等级方案"),
|
||||
LEVEL("职等"),
|
||||
GRADE("职级"),
|
||||
SEQUENCE("岗位序列"),
|
||||
POST("职务分类"),
|
||||
POSTINFO("职务管理"),
|
||||
GROUP("集团管理"),
|
||||
COMPANY("公司/分部"),
|
||||
DEPARTMENT("部门管理"),
|
||||
JOB("岗位管理"),
|
||||
RESOURCE("人员管理"),
|
||||
STAFFPLAN("编制方案"),
|
||||
STAFF("编制上报"),
|
||||
OTHER("其他模块");
|
||||
|
||||
private String value;
|
||||
|
||||
LogModuleNameEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
@ -17,7 +17,9 @@
|
|||
|
||||
<!-- 表字段 -->
|
||||
<sql id="baseColumns">
|
||||
t.id
|
||||
t
|
||||
.
|
||||
id
|
||||
, t.operate_desc
|
||||
, t.operator_id
|
||||
, t.operator_name
|
||||
|
|
@ -45,7 +47,9 @@
|
|||
client_ip,
|
||||
method_name,
|
||||
class_name,
|
||||
delete_type
|
||||
delete_type,
|
||||
operate_module_name,
|
||||
message
|
||||
</trim>
|
||||
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
|
||||
#{operateDesc},
|
||||
|
|
@ -57,12 +61,11 @@
|
|||
#{clientIp},
|
||||
#{methodName},
|
||||
#{className},
|
||||
#{deleteType}
|
||||
#{deleteType},
|
||||
#{operateModuleName},
|
||||
#{message}
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
@ -1,22 +1,13 @@
|
|||
package com.engine.organization.service.impl;
|
||||
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.organization.annotation.Log;
|
||||
import com.engine.organization.entity.LoggerContext;
|
||||
import com.engine.organization.entity.po.Demo;
|
||||
import com.engine.organization.enums.OperateTypeEnum;
|
||||
import com.engine.organization.mapper.DemoMapper;
|
||||
import com.engine.organization.service.DemoService;
|
||||
import com.engine.organization.util.HrmI18nUtil;
|
||||
import com.engine.organization.util.LogAspect;
|
||||
import com.engine.organization.util.OrganizationAssert;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
//import com.weaverboot.frame.ioc.anno.classAnno.WeaIocReplaceComponent;
|
||||
//import com.weaverboot.frame.ioc.anno.classAnno.WeaIocService;
|
||||
//import com.weaverboot.frame.ioc.anno.methodAnno.WeaReplaceAfter;
|
||||
//import com.weaverboot.frame.ioc.handler.replace.weaReplaceParam.impl.WeaAfterReplaceParam;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -32,18 +23,18 @@ public class DemoServiceImpl extends Service implements DemoService {
|
|||
|
||||
|
||||
@Override
|
||||
@Log(operateType = OperateTypeEnum.ADD,operateDesc = "测试自定义日志")
|
||||
//@Log(operateType = OperateTypeEnum.ADD,operateDesc = "测试自定义日志")
|
||||
public List<Demo> list(String name) {
|
||||
|
||||
OrganizationAssert.notNull(name, HrmI18nUtil.getI18nLabel(34721, "参数不能为空"));
|
||||
List<Demo> demos = MapperProxyFactory.getProxy(DemoMapper.class).listAll();
|
||||
|
||||
//操作日志记录
|
||||
Method method = new Object() {
|
||||
}.getClass().getEnclosingMethod();
|
||||
LoggerContext loggerContext = LoggerContext.builder().operatorId(user.getUID()).operatorName(user.getLastname()).build();
|
||||
LogAspect logAspect = new LogAspect(DemoServiceImpl.class, method, loggerContext);
|
||||
logAspect.start();
|
||||
////操作日志记录
|
||||
//Method method = new Object() {
|
||||
//}.getClass().getEnclosingMethod();
|
||||
//LoggerContext loggerContext = LoggerContext.builder().operatorId(user.getUID()).operatorName(user.getLastname()).build();
|
||||
//LogAspect logAspect = new LogAspect(DemoServiceImpl.class, method, loggerContext);
|
||||
//logAspect.start();
|
||||
|
||||
return demos;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,8 +115,8 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
|
|||
public Map<String, Object> listPage(HrmResourceSearchParam params) {
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
OrganizationWeaTable<ScHrmResourceVO> table = new OrganizationWeaTable<>(user, ScHrmResourceVO.class);
|
||||
//String sqlWhere = buildSqlWhere(params);
|
||||
//table.setSqlwhere(sqlWhere);
|
||||
String sqlWhere = buildSqlWhere(params);
|
||||
table.setSqlwhere(sqlWhere);
|
||||
WeaResultMsg result = new WeaResultMsg(false);
|
||||
result.putAll(table.makeDataResult());
|
||||
result.success();
|
||||
|
|
@ -206,7 +206,7 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
|
|||
List<SearchConditionGroup> addGroups = new ArrayList<>();
|
||||
List<SearchConditionItem> conditionItems = new ArrayList<>();
|
||||
SearchConditionItem lastNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "姓名", "lastName");
|
||||
SearchConditionItem managerIdItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "直接上级", "managerId");
|
||||
SearchConditionItem managerIdItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "直接上级", "1", "managerId", "");
|
||||
SearchConditionItem companyIdItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "分部", "161", "companyId", "compBrowser");
|
||||
SearchConditionItem departmentIdItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "部门", "161", "departmentId", "deptBrowser");
|
||||
SearchConditionItem telephoneItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "办公电话", "telephone");
|
||||
|
|
@ -251,22 +251,22 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
|
|||
*/
|
||||
private String buildSqlWhere(HrmResourceSearchParam params) {
|
||||
DBType dbType = DBType.get(new RecordSet().getDBType());
|
||||
String sqlWhere = " where t.delete_type ='0' ";
|
||||
String sqlWhere = " where 1=1 ";
|
||||
String lastName = params.getLastName();
|
||||
if (StringUtils.isNotBlank(lastName)) {
|
||||
sqlWhere += " AND t.last_name " + dbType.like(lastName);
|
||||
sqlWhere += " AND t.lastname " + dbType.like(lastName);
|
||||
}
|
||||
Long managerId = params.getManagerId();
|
||||
if (null != managerId) {
|
||||
sqlWhere += " AND t.manager_id = '" + managerId + "'";
|
||||
sqlWhere += " AND t.managerid = '" + managerId + "'";
|
||||
}
|
||||
Long companyId = params.getCompanyId();
|
||||
if (null != companyId) {
|
||||
sqlWhere += " AND t.company_id = '" + companyId + "'";
|
||||
sqlWhere += " AND t.subcompanyid1 = '" + companyId + "'";
|
||||
}
|
||||
Long departmentId = params.getDepartmentId();
|
||||
if (null != departmentId) {
|
||||
sqlWhere += " AND t.department_id = '" + departmentId + "'";
|
||||
sqlWhere += " AND t.departmentid = '" + departmentId + "'";
|
||||
}
|
||||
String telephone = params.getTelephone();
|
||||
if (StringUtils.isNotBlank(telephone)) {
|
||||
|
|
@ -278,11 +278,11 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
|
|||
}
|
||||
String mobileCall = params.getMobileCall();
|
||||
if (StringUtils.isNotBlank(mobileCall)) {
|
||||
sqlWhere += " AND t.mobile_call " + dbType.like(mobileCall);
|
||||
sqlWhere += " AND t.mobilecall " + dbType.like(mobileCall);
|
||||
}
|
||||
Long jobTitle = params.getJobTitle();
|
||||
if (null != jobTitle) {
|
||||
sqlWhere += " AND t.job_title = '" + jobTitle + "'";
|
||||
sqlWhere += " AND t.jobtitle = '" + jobTitle + "'";
|
||||
}
|
||||
|
||||
return sqlWhere;
|
||||
|
|
|
|||
|
|
@ -49,14 +49,15 @@ public class LogAspect<T> {
|
|||
Parameter[] parameters = method.getParameters();
|
||||
String value = annotation.operateType().getValue();
|
||||
String operateDesc = annotation.operateDesc();
|
||||
String operateModuleName = annotation.operateModule().getValue();
|
||||
loggerContext.setOperateDesc(operateDesc);
|
||||
loggerContext.setCreateTime(new Date());
|
||||
loggerContext.setOperateType(value);
|
||||
loggerContext.setParamsStr(Arrays.toString(parameters));
|
||||
loggerContext.setClientIp("127.0.0.1");
|
||||
loggerContext.setMethodName(method.getName());
|
||||
loggerContext.setClassName(clazz.getName());
|
||||
loggerContext.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue());
|
||||
loggerContext.setOperateModuleName(operateModuleName);
|
||||
MapperProxyFactory.getProxy(SISLogMapper.class).insert(loggerContext);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
package com.engine.organization.util;
|
||||
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.organization.entity.LoggerContext;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/07/04
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class OrganizationWrapper extends Service {
|
||||
|
||||
|
||||
/**
|
||||
* 记录操作日志
|
||||
*
|
||||
* @param clazz
|
||||
* @param message
|
||||
*/
|
||||
public void writeOperateLog(Class clazz,
|
||||
String message) {
|
||||
Method method = clazz.getEnclosingMethod();
|
||||
LoggerContext loggerContext = LoggerContext.builder().operatorId(user.getUID()).clientIp(user.getLoginip()).operatorName(user.getLastname()).message(message).build();
|
||||
LogAspect logAspect = new LogAspect(clazz, method, loggerContext);
|
||||
logAspect.start();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,10 +1,12 @@
|
|||
package com.engine.organization.wrapper;
|
||||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.organization.annotation.Log;
|
||||
import com.engine.organization.entity.po.Demo;
|
||||
import com.engine.organization.enums.OperateTypeEnum;
|
||||
import com.engine.organization.service.DemoService;
|
||||
import com.engine.organization.service.impl.DemoServiceImpl;
|
||||
import com.engine.organization.util.OrganizationWrapper;
|
||||
import com.engine.organization.util.response.ReturnResult;
|
||||
import weaver.hrm.User;
|
||||
|
||||
|
|
@ -16,14 +18,16 @@ import java.util.List;
|
|||
* @Date 2022/4/26
|
||||
* @Version V1.0
|
||||
**/
|
||||
public class DemoWrapper extends Service {
|
||||
public class DemoWrapper extends OrganizationWrapper {
|
||||
|
||||
private DemoService getDemoService(User user) {
|
||||
return ServiceUtil.getService(DemoServiceImpl.class,user);
|
||||
return ServiceUtil.getService(DemoServiceImpl.class, user);
|
||||
}
|
||||
|
||||
@Log(operateType = OperateTypeEnum.DELETE, operateDesc = "operateDesc")
|
||||
public ReturnResult testDemo(String name) {
|
||||
List<Demo> list = getDemoService(user).list(name);
|
||||
return ReturnResult.successed(list);
|
||||
writeOperateLog(new Object(){}.getClass(), "记录testDemo操作日志");
|
||||
return ReturnResult.successed(list);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue