Browse Source
* feat: auto record operation log * feat: add list project operation log api * feat: update frontend resourcemaster
vran
3 years ago
committed by
GitHub
81 changed files with 1740 additions and 97 deletions
@ -0,0 +1,30 @@ |
|||
package com.databasir.api; |
|||
|
|||
import com.databasir.common.JsonData; |
|||
import com.databasir.core.domain.log.data.OperationLogPageCondition; |
|||
import com.databasir.core.domain.log.data.OperationLogPageResponse; |
|||
import com.databasir.core.domain.log.service.OperationLogService; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.data.domain.Page; |
|||
import org.springframework.data.domain.Pageable; |
|||
import org.springframework.data.domain.Sort; |
|||
import org.springframework.data.web.PageableDefault; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
@RestController |
|||
@RequiredArgsConstructor |
|||
@Validated |
|||
public class OperationLogController { |
|||
|
|||
private final OperationLogService operationLogService; |
|||
|
|||
@GetMapping(Routes.OperationLog.LIST) |
|||
public JsonData<Page<OperationLogPageResponse>> list(@PageableDefault(sort = "id", direction = Sort.Direction.DESC) |
|||
Pageable page, |
|||
OperationLogPageCondition condition) { |
|||
Page<OperationLogPageResponse> pageData = operationLogService.list(page, condition); |
|||
return JsonData.ok(pageData); |
|||
} |
|||
} |
@ -0,0 +1,117 @@ |
|||
package com.databasir.api.advice; |
|||
|
|||
import com.databasir.api.config.security.DatabasirUserDetails; |
|||
import com.databasir.common.JsonData; |
|||
import com.databasir.core.domain.log.annotation.Operation; |
|||
import com.databasir.core.domain.log.data.OperationLogRequest; |
|||
import com.databasir.core.domain.log.service.OperationLogService; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.aspectj.lang.JoinPoint; |
|||
import org.aspectj.lang.annotation.AfterReturning; |
|||
import org.aspectj.lang.annotation.AfterThrowing; |
|||
import org.aspectj.lang.annotation.Aspect; |
|||
import org.aspectj.lang.reflect.MethodSignature; |
|||
import org.springframework.core.LocalVariableTableParameterNameDiscoverer; |
|||
import org.springframework.core.ParameterNameDiscoverer; |
|||
import org.springframework.expression.EvaluationContext; |
|||
import org.springframework.expression.Expression; |
|||
import org.springframework.expression.spel.standard.SpelExpressionParser; |
|||
import org.springframework.expression.spel.support.StandardEvaluationContext; |
|||
import org.springframework.security.core.context.SecurityContextHolder; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.lang.reflect.Method; |
|||
import java.util.Objects; |
|||
import java.util.Optional; |
|||
|
|||
@Component |
|||
@RequiredArgsConstructor |
|||
@Aspect |
|||
@Slf4j |
|||
public class OperationLogAspect { |
|||
|
|||
private final OperationLogService operationLogService; |
|||
|
|||
private SpelExpressionParser spelExpressionParser = new SpelExpressionParser(); |
|||
|
|||
private ParameterNameDiscoverer parameterNameDiscoverer = new LocalVariableTableParameterNameDiscoverer(); |
|||
|
|||
@AfterReturning(value = "@annotation(operation)", returning = "returnValue") |
|||
public void log(JoinPoint joinPoint, Object returnValue, Operation operation) { |
|||
saveLog(operation, joinPoint, (JsonData<Object>) returnValue); |
|||
} |
|||
|
|||
@AfterThrowing(value = "@annotation(operation)", throwing = "ex") |
|||
public void log(JoinPoint joinPoint, RuntimeException ex, Operation operation) { |
|||
saveLog(operation, joinPoint, JsonData.error("-1", ex.getMessage())); |
|||
throw ex; |
|||
} |
|||
|
|||
private void saveLog(Operation operation, JoinPoint joinPoint, JsonData<Object> result) { |
|||
MethodSignature signature = (MethodSignature) joinPoint.getSignature(); |
|||
Method method = signature.getMethod(); |
|||
Object[] arguments = joinPoint.getArgs(); |
|||
|
|||
DatabasirUserDetails principal = (DatabasirUserDetails) SecurityContextHolder.getContext() |
|||
.getAuthentication() |
|||
.getPrincipal(); |
|||
Integer involvedProjectId = getValueBySPEL(method, arguments, operation.involvedProjectId(), Integer.class) |
|||
.orElse(null); |
|||
Integer involvedGroupId = getValueBySPEL(method, arguments, operation.involvedGroupId(), Integer.class) |
|||
.orElse(null); |
|||
Integer involvedUserId = getValueBySPEL(method, arguments, operation.involvedUserId(), Integer.class) |
|||
.orElse(null); |
|||
int userId = userId(); |
|||
String username = principal.getUserPojo().getUsername(); |
|||
String nickname = principal.getUserPojo().getNickname(); |
|||
if (userId == Operation.Types.SYSTEM_USER_ID) { |
|||
username = "system"; |
|||
nickname = "system"; |
|||
} |
|||
OperationLogRequest request = OperationLogRequest.builder() |
|||
.operatorUserId(userId) |
|||
.operatorUsername(username) |
|||
.operatorNickname(nickname) |
|||
.operationModule(operation.module()) |
|||
.operationCode(method.getName()) |
|||
.operationName(operation.name()) |
|||
.operationResponse(result) |
|||
.isSuccess(result.getErrCode() == null) |
|||
.involvedProjectId(involvedProjectId) |
|||
.involvedGroupId(involvedGroupId) |
|||
.involvedUserId(involvedUserId) |
|||
.build(); |
|||
operationLogService.save(request); |
|||
} |
|||
|
|||
private int userId() { |
|||
DatabasirUserDetails principal = (DatabasirUserDetails) SecurityContextHolder.getContext() |
|||
.getAuthentication() |
|||
.getPrincipal(); |
|||
return principal.getUserPojo().getId(); |
|||
} |
|||
|
|||
private <T> Optional<T> getValueBySPEL(Method method, |
|||
Object[] arguments, |
|||
String expression, |
|||
Class<T> valueType) { |
|||
if (expression == null || "N/A".equals(expression)) { |
|||
return Optional.empty(); |
|||
} |
|||
String[] parameterNames = |
|||
Objects.requireNonNullElse(parameterNameDiscoverer.getParameterNames(method), new String[0]); |
|||
EvaluationContext context = new StandardEvaluationContext(); |
|||
for (int len = 0; len < parameterNames.length; len++) { |
|||
context.setVariable(parameterNames[len], arguments[len]); |
|||
} |
|||
try { |
|||
Expression expr = spelExpressionParser.parseExpression(expression); |
|||
return Optional.ofNullable(expr.getValue(context, valueType)); |
|||
} catch (Exception e) { |
|||
log.warn("parse expression error: " + expression, e); |
|||
return Optional.empty(); |
|||
} |
|||
} |
|||
|
|||
} |
Binary file not shown.
@ -1 +1 @@ |
|||
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>databasir-frontend</title><link href="/css/chunk-04ac1c26.a5cbc9e6.css" rel="prefetch"><link href="/css/chunk-4fd080e4.a5b9f9ad.css" rel="prefetch"><link href="/css/chunk-7e394785.ab54ac4c.css" rel="prefetch"><link href="/css/chunk-7fa689fe.a79c1787.css" rel="prefetch"><link href="/js/chunk-04ac1c26.b03a6105.js" rel="prefetch"><link href="/js/chunk-2d0cc811.feb081c8.js" rel="prefetch"><link href="/js/chunk-48cebeac.b43a95b4.js" rel="prefetch"><link href="/js/chunk-4fd080e4.d40c8d0d.js" rel="prefetch"><link href="/js/chunk-7e394785.b93f6d8c.js" rel="prefetch"><link href="/js/chunk-7fa689fe.e971bfe1.js" rel="prefetch"><link href="/js/chunk-abb10c56.4c323350.js" rel="prefetch"><link href="/js/chunk-fffb1b64.df1e960f.js" rel="prefetch"><link href="/css/app.df19208c.css" rel="preload" as="style"><link href="/css/chunk-vendors.d4aa889d.css" rel="preload" as="style"><link href="/js/app.943c1753.js" rel="preload" as="script"><link href="/js/chunk-vendors.8b5336af.js" rel="preload" as="script"><link href="/css/chunk-vendors.d4aa889d.css" rel="stylesheet"><link href="/css/app.df19208c.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but databasir-frontend doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/js/chunk-vendors.8b5336af.js"></script><script src="/js/app.943c1753.js"></script></body></html> |
|||
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>databasir-frontend</title><link href="/css/chunk-04ac1c26.00ac37b1.css" rel="prefetch"><link href="/css/chunk-7e394785.e51aa148.css" rel="prefetch"><link href="/css/chunk-7fa689fe.80a92238.css" rel="prefetch"><link href="/css/chunk-c2109158.06814884.css" rel="prefetch"><link href="/js/chunk-04ac1c26.b5c879b8.js" rel="prefetch"><link href="/js/chunk-2d0cc811.c5d1ef9e.js" rel="prefetch"><link href="/js/chunk-48cebeac.162363c9.js" rel="prefetch"><link href="/js/chunk-7e394785.e090ef46.js" rel="prefetch"><link href="/js/chunk-7fa689fe.337b34fc.js" rel="prefetch"><link href="/js/chunk-abb10c56.bd8d31bf.js" rel="prefetch"><link href="/js/chunk-c2109158.94b6c554.js" rel="prefetch"><link href="/js/chunk-fffb1b64.1ffb9f27.js" rel="prefetch"><link href="/css/app.36ecf611.css" rel="preload" as="style"><link href="/css/chunk-vendors.d4aa889d.css" rel="preload" as="style"><link href="/js/app.7a0ffda3.js" rel="preload" as="script"><link href="/js/chunk-vendors.8b5336af.js" rel="preload" as="script"><link href="/css/chunk-vendors.d4aa889d.css" rel="stylesheet"><link href="/css/app.36ecf611.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but databasir-frontend doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/js/chunk-vendors.8b5336af.js"></script><script src="/js/app.7a0ffda3.js"></script></body></html> |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,2 +1,2 @@ |
|||
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d0cc811"],{"4de0":function(e,t,r){"use strict";r.r(t);var n=r("7a23"),o=Object(n["createTextVNode"])(" : "),u=Object(n["createTextVNode"])("保存");function l(e,t,r,l,a,c){var s=Object(n["resolveComponent"])("el-input"),i=Object(n["resolveComponent"])("el-form-item"),d=Object(n["resolveComponent"])("el-col"),m=Object(n["resolveComponent"])("el-button"),f=Object(n["resolveComponent"])("el-form"),p=Object(n["resolveComponent"])("el-card"),b=Object(n["resolveComponent"])("el-main"),j=Object(n["resolveComponent"])("el-container");return Object(n["openBlock"])(),Object(n["createBlock"])(j,null,{default:Object(n["withCtx"])((function(){return[Object(n["createVNode"])(b,null,{default:Object(n["withCtx"])((function(){return[Object(n["createVNode"])(p,null,{default:Object(n["withCtx"])((function(){return[Object(n["createVNode"])(f,{model:a.form,"label-position":"top",rules:a.formRule,ref:"formRef",style:{"max-width":"900px"}},{default:Object(n["withCtx"])((function(){return[Object(n["createVNode"])(i,{label:"邮箱账号",prop:"username"},{default:Object(n["withCtx"])((function(){return[Object(n["createVNode"])(s,{modelValue:a.form.username,"onUpdate:modelValue":t[0]||(t[0]=function(e){return a.form.username=e})},null,8,["modelValue"])]})),_:1}),Object(n["createVNode"])(i,{label:"邮箱密码",prop:"password"},{default:Object(n["withCtx"])((function(){return[Object(n["createVNode"])(s,{modelValue:a.form.password,"onUpdate:modelValue":t[1]||(t[1]=function(e){return a.form.password=e}),type:"password",placeholder:"请输入密码","show-password":""},null,8,["modelValue"])]})),_:1}),Object(n["createVNode"])(i,{label:"SMTP",prop:"smtpHost"},{default:Object(n["withCtx"])((function(){return[Object(n["createVNode"])(d,{span:12},{default:Object(n["withCtx"])((function(){return[Object(n["createVNode"])(s,{modelValue:a.form.smtpHost,"onUpdate:modelValue":t[2]||(t[2]=function(e){return a.form.smtpHost=e}),placeholder:"SMTP Host"},null,8,["modelValue"])]})),_:1}),Object(n["createVNode"])(d,{span:1,style:{"text-align":"center"}},{default:Object(n["withCtx"])((function(){return[o]})),_:1}),Object(n["createVNode"])(d,{span:6},{default:Object(n["withCtx"])((function(){return[Object(n["createVNode"])(s,{modelValue:a.form.smtpPort,"onUpdate:modelValue":t[3]||(t[3]=function(e){return a.form.smtpPort=e}),placeholder:"SMTP Port"},null,8,["modelValue"])]})),_:1})]})),_:1}),Object(n["createVNode"])(i,{style:{"margin-top":"38px"}},{default:Object(n["withCtx"])((function(){return[Object(n["createVNode"])(m,{type:"primary",onClick:t[4]||(t[4]=function(e){return c.onSubmit("formRef")})},{default:Object(n["withCtx"])((function(){return[u]})),_:1})]})),_:1})]})),_:1},8,["model","rules"])]})),_:1})]})),_:1})]})),_:1})}var a=r("1da1"),c=(r("96cf"),r("1c1e")),s="/api/v1.0/settings",i=function(){return c["a"].get(s+"/sys_email")},d=function(e){return c["a"].post(s+"/sys_email",e)},m={data:function(){return{form:{smtpHost:null,smtpPort:null,username:null,password:null},formRule:{username:[this.requiredInputValidRule("请输入邮箱账号"),{type:"email",message:"邮箱格式不正确",trigger:"blur"}],password:[this.requiredInputValidRule("请输入邮箱密码")],smtpHost:[this.requiredInputValidRule("请输入 SMTP 地址")],smtpPort:[this.requiredInputValidRule("请输入 SMTP 端口"),{min:1,max:65535,message:"端口有效值为 1~65535",trigger:"blur"}]}}},mounted:function(){this.fetchSysMail()},methods:{requiredInputValidRule:function(e){return{required:!0,message:e,trigger:"blur"}},fetchSysMail:function(){var e=this;return Object(a["a"])(regeneratorRuntime.mark((function t(){var r;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,i().then((function(e){return e.data}));case 2:r=t.sent,r&&(e.form=r);case 4:case"end":return t.stop()}}),t)})))()},onSubmit:function(){var e=this;this.$refs.formRef.validate((function(t){return t?(d(e.form).then((function(t){t.errCode||e.$message.success("更新成功")})),!0):(e.$message.error("请完善表单相关信息!"),!1)}))}}},f=r("6b0d"),p=r.n(f);const b=p()(m,[["render",l]]);t["default"]=b}}]); |
|||
//# sourceMappingURL=chunk-2d0cc811.feb081c8.js.map
|
|||
//# sourceMappingURL=chunk-2d0cc811.c5d1ef9e.js.map
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,2 +1,2 @@ |
|||
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-7e394785"],{a55b:function(e,t,n){"use strict";n.r(t);var o=n("7a23"),r={class:"login-card"},c=Object(o["createElementVNode"])("h1",null,"Databasir",-1),a=Object(o["createTextVNode"])(" 登录 "),u=Object(o["createTextVNode"])(" 忘记密码? ");function l(e,t,n,l,i,d){var s=Object(o["resolveComponent"])("el-header"),b=Object(o["resolveComponent"])("el-link"),f=Object(o["resolveComponent"])("el-divider"),m=Object(o["resolveComponent"])("el-form-item"),j=Object(o["resolveComponent"])("el-button"),p=Object(o["resolveComponent"])("el-tooltip"),O=Object(o["resolveComponent"])("el-space"),h=Object(o["resolveComponent"])("el-form"),w=Object(o["resolveComponent"])("el-main"),C=Object(o["resolveComponent"])("el-footer"),v=Object(o["resolveComponent"])("el-container");return Object(o["openBlock"])(),Object(o["createBlock"])(v,null,{default:Object(o["withCtx"])((function(){return[Object(o["createVNode"])(s),Object(o["createVNode"])(w,{class:"login-main"},{default:Object(o["withCtx"])((function(){return[Object(o["createElementVNode"])("div",r,[Object(o["createVNode"])(h,{ref:"formRef",rules:i.formRule,model:i.form,style:{border:"none"}},{default:Object(o["withCtx"])((function(){return[Object(o["createVNode"])(m,null,{default:Object(o["withCtx"])((function(){return[Object(o["createVNode"])(f,{"content-position":"left"},{default:Object(o["withCtx"])((function(){return[Object(o["createVNode"])(b,{href:"https://github.com/vran-dev/databasir",target:"_blank",underline:!1,type:"info"},{default:Object(o["withCtx"])((function(){return[c]})),_:1})]})),_:1})]})),_:1}),Object(o["createVNode"])(m,{prop:"username"},{default:Object(o["withCtx"])((function(){return[Object(o["withDirectives"])(Object(o["createElementVNode"])("input",{type:"text",class:"login-input",placeholder:"用户名或邮箱","onUpdate:modelValue":t[0]||(t[0]=function(e){return i.form.username=e})},null,512),[[o["vModelText"],i.form.username]])]})),_:1}),Object(o["createVNode"])(m,{prop:"password"},{default:Object(o["withCtx"])((function(){return[Object(o["withDirectives"])(Object(o["createElementVNode"])("input",{type:"password",class:"login-input",placeholder:"密码","onUpdate:modelValue":t[1]||(t[1]=function(e){return i.form.password=e})},null,512),[[o["vModelText"],i.form.password]])]})),_:1}),Object(o["createVNode"])(m,null,{default:Object(o["withCtx"])((function(){return[Object(o["createVNode"])(O,{size:32},{default:Object(o["withCtx"])((function(){return[Object(o["createVNode"])(j,{style:{width:"120px","margin-top":"10px"},color:"#000",onClick:t[2]||(t[2]=function(e){return d.onLogin("formRef")}),plain:"",round:""},{default:Object(o["withCtx"])((function(){return[a]})),_:1}),Object(o["createVNode"])(p,{content:"请联系管理员为您重置密码"},{default:Object(o["withCtx"])((function(){return[Object(o["createVNode"])(b,{target:"_blank",underline:!1,type:"info"},{default:Object(o["withCtx"])((function(){return[u]})),_:1})]})),_:1})]})),_:1})]})),_:1})]})),_:1},8,["rules","model"])])]})),_:1}),Object(o["createVNode"])(C,null,{default:Object(o["withCtx"])((function(){return[Object(o["createVNode"])(O)]})),_:1})]})),_:1})}var i=n("b0af"),d=n("5f87"),s={data:function(){return{form:{username:null,password:null},formRule:{username:[{required:!0,message:"请输入用户名或邮箱",trigger:"blur"}],password:[{required:!0,message:"请输入密码",trigger:"blur"}]}}},methods:{toIndexPage:function(){this.$router.push({path:"/groups"})},onLogin:function(){var e=this;this.$refs.formRef.validate((function(t){t&&Object(i["a"])(e.form).then((function(t){t.errCode||(d["b"].saveUserLoginData(t.data),e.$store.commit("userUpdate",{nickname:t.data.nickname,username:t.data.username,email:t.data.email}),e.toIndexPage())}))}))}}},b=(n("d30d"),n("6b0d")),f=n.n(b);const m=f()(s,[["render",l]]);t["default"]=m},d30d:function(e,t,n){"use strict";n("edba")},edba:function(e,t,n){}}]); |
|||
//# sourceMappingURL=chunk-7e394785.b93f6d8c.js.map
|
|||
//# sourceMappingURL=chunk-7e394785.e090ef46.js.map
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,42 @@ |
|||
package com.databasir.core.domain.log.annotation; |
|||
|
|||
import java.lang.annotation.ElementType; |
|||
import java.lang.annotation.Retention; |
|||
import java.lang.annotation.RetentionPolicy; |
|||
import java.lang.annotation.Target; |
|||
|
|||
@Target(ElementType.METHOD) |
|||
@Retention(RetentionPolicy.RUNTIME) |
|||
public @interface Operation { |
|||
|
|||
String module(); |
|||
|
|||
String name() default "UNKNOWN"; |
|||
|
|||
/** |
|||
* @return the Spring-EL expression |
|||
*/ |
|||
String involvedProjectId() default "N/A"; |
|||
|
|||
/** |
|||
* @return the Spring-EL expression |
|||
*/ |
|||
String involvedGroupId() default "N/A"; |
|||
|
|||
/** |
|||
* @return the Spring-EL expression |
|||
*/ |
|||
String involvedUserId() default "N/A"; |
|||
|
|||
interface Modules { |
|||
String UNKNOWN = "UNKNOWN"; |
|||
String PROJECT = "project"; |
|||
String USER = "user"; |
|||
String GROUP = "group"; |
|||
String SETTING = "setting"; |
|||
} |
|||
|
|||
interface Types { |
|||
int SYSTEM_USER_ID = -1; |
|||
} |
|||
} |
@ -0,0 +1,13 @@ |
|||
package com.databasir.core.domain.log.converter; |
|||
|
|||
import com.databasir.core.domain.log.data.OperationLogPageResponse; |
|||
import com.databasir.core.infrastructure.converter.JsonConverter; |
|||
import com.databasir.dao.tables.pojos.OperationLogPojo; |
|||
import org.mapstruct.Mapper; |
|||
|
|||
@Mapper(componentModel = "spring", uses = JsonConverter.class) |
|||
public interface OperationLogPojoConverter { |
|||
|
|||
OperationLogPageResponse to(OperationLogPojo pojo); |
|||
|
|||
} |
@ -0,0 +1,13 @@ |
|||
package com.databasir.core.domain.log.converter; |
|||
|
|||
import com.databasir.core.domain.log.data.OperationLogRequest; |
|||
import com.databasir.core.infrastructure.converter.JsonConverter; |
|||
import com.databasir.dao.tables.pojos.OperationLogPojo; |
|||
import org.mapstruct.Mapper; |
|||
|
|||
@Mapper(componentModel = "spring", uses = JsonConverter.class) |
|||
public interface OperationLogRequestConverter { |
|||
|
|||
OperationLogPojo toPojo(OperationLogRequest request); |
|||
|
|||
} |
@ -0,0 +1,55 @@ |
|||
package com.databasir.core.domain.log.data; |
|||
|
|||
import com.databasir.dao.Tables; |
|||
import lombok.Data; |
|||
import org.jooq.Condition; |
|||
import org.jooq.impl.DSL; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
@Data |
|||
public class OperationLogPageCondition { |
|||
|
|||
private String module; |
|||
|
|||
private String code; |
|||
|
|||
private Integer operatorUserId; |
|||
|
|||
private Integer involveProjectId; |
|||
|
|||
private Integer involveGroupId; |
|||
|
|||
private Integer involveUserId; |
|||
|
|||
private Boolean isSuccess; |
|||
|
|||
public Condition toCondition() { |
|||
List<Condition> conditions = new ArrayList<>(); |
|||
if (module != null) { |
|||
conditions.add(Tables.OPERATION_LOG.OPERATION_MODULE.eq(module)); |
|||
} |
|||
if (code != null) { |
|||
conditions.add(Tables.OPERATION_LOG.OPERATION_CODE.eq(module)); |
|||
} |
|||
if (operatorUserId != null) { |
|||
conditions.add(Tables.OPERATION_LOG.OPERATOR_USER_ID.eq(operatorUserId)); |
|||
} |
|||
if (involveProjectId != null) { |
|||
conditions.add(Tables.OPERATION_LOG.INVOLVED_PROJECT_ID.eq(involveProjectId)); |
|||
} |
|||
if (involveGroupId != null) { |
|||
conditions.add(Tables.OPERATION_LOG.INVOLVED_GROUP_ID.eq(involveGroupId)); |
|||
} |
|||
if (involveUserId != null) { |
|||
conditions.add(Tables.OPERATION_LOG.INVOLVED_USER_ID.eq(involveUserId)); |
|||
} |
|||
if (isSuccess != null) { |
|||
conditions.add(Tables.OPERATION_LOG.IS_SUCCESS.eq(isSuccess)); |
|||
} |
|||
return conditions.stream() |
|||
.reduce(Condition::and) |
|||
.orElse(DSL.trueCondition()); |
|||
} |
|||
} |
@ -0,0 +1,39 @@ |
|||
package com.databasir.core.domain.log.data; |
|||
|
|||
import com.databasir.common.JsonData; |
|||
import lombok.Builder; |
|||
import lombok.Data; |
|||
|
|||
import java.time.LocalDateTime; |
|||
|
|||
@Data |
|||
@Builder |
|||
public class OperationLogPageResponse { |
|||
|
|||
private Integer id; |
|||
|
|||
private Integer operatorUserId; |
|||
|
|||
private String operatorUsername; |
|||
|
|||
private String operatorNickname; |
|||
|
|||
private String operationModule; |
|||
|
|||
private String operationCode; |
|||
|
|||
private String operationName; |
|||
|
|||
private JsonData<Object> operationResponse; |
|||
|
|||
private Boolean isSuccess; |
|||
|
|||
private Integer involvedProjectId; |
|||
|
|||
private Integer involvedGroupId; |
|||
|
|||
private Integer involvedUserId; |
|||
|
|||
private LocalDateTime createAt; |
|||
|
|||
} |
@ -0,0 +1,32 @@ |
|||
package com.databasir.core.domain.log.data; |
|||
|
|||
import lombok.Builder; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
@Builder |
|||
public class OperationLogRequest { |
|||
|
|||
private Integer operatorUserId; |
|||
|
|||
private String operatorUsername; |
|||
|
|||
private String operatorNickname; |
|||
|
|||
private String operationModule; |
|||
|
|||
private String operationCode; |
|||
|
|||
private String operationName; |
|||
|
|||
private Object operationResponse; |
|||
|
|||
private Boolean isSuccess; |
|||
|
|||
private Integer involvedProjectId; |
|||
|
|||
private Integer involvedGroupId; |
|||
|
|||
private Integer involvedUserId; |
|||
|
|||
} |
@ -0,0 +1,35 @@ |
|||
package com.databasir.core.domain.log.service; |
|||
|
|||
import com.databasir.core.domain.log.converter.OperationLogPojoConverter; |
|||
import com.databasir.core.domain.log.converter.OperationLogRequestConverter; |
|||
import com.databasir.core.domain.log.data.OperationLogPageCondition; |
|||
import com.databasir.core.domain.log.data.OperationLogPageResponse; |
|||
import com.databasir.core.domain.log.data.OperationLogRequest; |
|||
import com.databasir.dao.impl.OperationLogDao; |
|||
import com.databasir.dao.tables.pojos.OperationLogPojo; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.data.domain.Page; |
|||
import org.springframework.data.domain.Pageable; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class OperationLogService { |
|||
|
|||
private final OperationLogDao operationLogDao; |
|||
|
|||
private final OperationLogRequestConverter operationLogRequestConverter; |
|||
|
|||
private final OperationLogPojoConverter operationLogPojoConverter; |
|||
|
|||
public void save(OperationLogRequest request) { |
|||
OperationLogPojo pojo = operationLogRequestConverter.toPojo(request); |
|||
operationLogDao.insertAndReturnId(pojo); |
|||
} |
|||
|
|||
public Page<OperationLogPageResponse> list(Pageable page, |
|||
OperationLogPageCondition condition) { |
|||
Page<OperationLogPojo> pojoData = operationLogDao.selectByPage(page, condition.toCondition()); |
|||
return pojoData.map(operationLogPojoConverter::to); |
|||
} |
|||
} |
@ -0,0 +1,204 @@ |
|||
/* |
|||
* This file is generated by jOOQ. |
|||
*/ |
|||
package com.databasir.dao.tables; |
|||
|
|||
|
|||
import com.databasir.dao.Databasir; |
|||
import com.databasir.dao.Keys; |
|||
import com.databasir.dao.tables.records.OperationLogRecord; |
|||
|
|||
import java.time.LocalDateTime; |
|||
|
|||
import org.jooq.Field; |
|||
import org.jooq.ForeignKey; |
|||
import org.jooq.Identity; |
|||
import org.jooq.JSON; |
|||
import org.jooq.Name; |
|||
import org.jooq.Record; |
|||
import org.jooq.Row13; |
|||
import org.jooq.Schema; |
|||
import org.jooq.Table; |
|||
import org.jooq.TableField; |
|||
import org.jooq.TableOptions; |
|||
import org.jooq.UniqueKey; |
|||
import org.jooq.impl.DSL; |
|||
import org.jooq.impl.SQLDataType; |
|||
import org.jooq.impl.TableImpl; |
|||
|
|||
|
|||
/** |
|||
* This class is generated by jOOQ. |
|||
*/ |
|||
@SuppressWarnings({ "all", "unchecked", "rawtypes" }) |
|||
public class OperationLog extends TableImpl<OperationLogRecord> { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* The reference instance of <code>databasir.operation_log</code> |
|||
*/ |
|||
public static final OperationLog OPERATION_LOG = new OperationLog(); |
|||
|
|||
/** |
|||
* The class holding records for this type |
|||
*/ |
|||
@Override |
|||
public Class<OperationLogRecord> getRecordType() { |
|||
return OperationLogRecord.class; |
|||
} |
|||
|
|||
/** |
|||
* The column <code>databasir.operation_log.id</code>. |
|||
*/ |
|||
public final TableField<OperationLogRecord, Long> ID = createField(DSL.name("id"), SQLDataType.BIGINT.nullable(false).identity(true), this, ""); |
|||
|
|||
/** |
|||
* The column <code>databasir.operation_log.operator_user_id</code>. ref to |
|||
* user.id |
|||
*/ |
|||
public final TableField<OperationLogRecord, Integer> OPERATOR_USER_ID = createField(DSL.name("operator_user_id"), SQLDataType.INTEGER.nullable(false), this, "ref to user.id"); |
|||
|
|||
/** |
|||
* The column <code>databasir.operation_log.operator_username</code>. |
|||
* user.username |
|||
*/ |
|||
public final TableField<OperationLogRecord, String> OPERATOR_USERNAME = createField(DSL.name("operator_username"), SQLDataType.VARCHAR(128).nullable(false), this, "user.username"); |
|||
|
|||
/** |
|||
* The column <code>databasir.operation_log.operator_nickname</code>. |
|||
* user.nickname |
|||
*/ |
|||
public final TableField<OperationLogRecord, String> OPERATOR_NICKNAME = createField(DSL.name("operator_nickname"), SQLDataType.VARCHAR(255).nullable(false), this, "user.nickname"); |
|||
|
|||
/** |
|||
* The column <code>databasir.operation_log.operation_module</code>. |
|||
*/ |
|||
public final TableField<OperationLogRecord, String> OPERATION_MODULE = createField(DSL.name("operation_module"), SQLDataType.VARCHAR(128).nullable(false), this, ""); |
|||
|
|||
/** |
|||
* The column <code>databasir.operation_log.operation_code</code>. |
|||
*/ |
|||
public final TableField<OperationLogRecord, String> OPERATION_CODE = createField(DSL.name("operation_code"), SQLDataType.VARCHAR(255).nullable(false), this, ""); |
|||
|
|||
/** |
|||
* The column <code>databasir.operation_log.operation_name</code>. |
|||
*/ |
|||
public final TableField<OperationLogRecord, String> OPERATION_NAME = createField(DSL.name("operation_name"), SQLDataType.VARCHAR(255).nullable(false), this, ""); |
|||
|
|||
/** |
|||
* The column <code>databasir.operation_log.operation_response</code>. |
|||
*/ |
|||
public final TableField<OperationLogRecord, JSON> OPERATION_RESPONSE = createField(DSL.name("operation_response"), SQLDataType.JSON.nullable(false), this, ""); |
|||
|
|||
/** |
|||
* The column <code>databasir.operation_log.is_success</code>. |
|||
*/ |
|||
public final TableField<OperationLogRecord, Boolean> IS_SUCCESS = createField(DSL.name("is_success"), SQLDataType.BOOLEAN.nullable(false).defaultValue(DSL.inline("0", SQLDataType.BOOLEAN)), this, ""); |
|||
|
|||
/** |
|||
* The column <code>databasir.operation_log.involved_project_id</code>. ref |
|||
* to project.id |
|||
*/ |
|||
public final TableField<OperationLogRecord, Integer> INVOLVED_PROJECT_ID = createField(DSL.name("involved_project_id"), SQLDataType.INTEGER, this, "ref to project.id"); |
|||
|
|||
/** |
|||
* The column <code>databasir.operation_log.involved_group_id</code>. ref to |
|||
* group.id |
|||
*/ |
|||
public final TableField<OperationLogRecord, Integer> INVOLVED_GROUP_ID = createField(DSL.name("involved_group_id"), SQLDataType.INTEGER, this, "ref to group.id"); |
|||
|
|||
/** |
|||
* The column <code>databasir.operation_log.involved_user_id</code>. ref to |
|||
* user.id |
|||
*/ |
|||
public final TableField<OperationLogRecord, Integer> INVOLVED_USER_ID = createField(DSL.name("involved_user_id"), SQLDataType.INTEGER, this, "ref to user.id"); |
|||
|
|||
/** |
|||
* The column <code>databasir.operation_log.create_at</code>. |
|||
*/ |
|||
public final TableField<OperationLogRecord, LocalDateTime> CREATE_AT = createField(DSL.name("create_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); |
|||
|
|||
private OperationLog(Name alias, Table<OperationLogRecord> aliased) { |
|||
this(alias, aliased, null); |
|||
} |
|||
|
|||
private OperationLog(Name alias, Table<OperationLogRecord> aliased, Field<?>[] parameters) { |
|||
super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table()); |
|||
} |
|||
|
|||
/** |
|||
* Create an aliased <code>databasir.operation_log</code> table reference |
|||
*/ |
|||
public OperationLog(String alias) { |
|||
this(DSL.name(alias), OPERATION_LOG); |
|||
} |
|||
|
|||
/** |
|||
* Create an aliased <code>databasir.operation_log</code> table reference |
|||
*/ |
|||
public OperationLog(Name alias) { |
|||
this(alias, OPERATION_LOG); |
|||
} |
|||
|
|||
/** |
|||
* Create a <code>databasir.operation_log</code> table reference |
|||
*/ |
|||
public OperationLog() { |
|||
this(DSL.name("operation_log"), null); |
|||
} |
|||
|
|||
public <O extends Record> OperationLog(Table<O> child, ForeignKey<O, OperationLogRecord> key) { |
|||
super(child, key, OPERATION_LOG); |
|||
} |
|||
|
|||
@Override |
|||
public Schema getSchema() { |
|||
return aliased() ? null : Databasir.DATABASIR; |
|||
} |
|||
|
|||
@Override |
|||
public Identity<OperationLogRecord, Long> getIdentity() { |
|||
return (Identity<OperationLogRecord, Long>) super.getIdentity(); |
|||
} |
|||
|
|||
@Override |
|||
public UniqueKey<OperationLogRecord> getPrimaryKey() { |
|||
return Keys.KEY_OPERATION_LOG_PRIMARY; |
|||
} |
|||
|
|||
@Override |
|||
public OperationLog as(String alias) { |
|||
return new OperationLog(DSL.name(alias), this); |
|||
} |
|||
|
|||
@Override |
|||
public OperationLog as(Name alias) { |
|||
return new OperationLog(alias, this); |
|||
} |
|||
|
|||
/** |
|||
* Rename this table |
|||
*/ |
|||
@Override |
|||
public OperationLog rename(String name) { |
|||
return new OperationLog(DSL.name(name), null); |
|||
} |
|||
|
|||
/** |
|||
* Rename this table |
|||
*/ |
|||
@Override |
|||
public OperationLog rename(Name name) { |
|||
return new OperationLog(name, null); |
|||
} |
|||
|
|||
// -------------------------------------------------------------------------
|
|||
// Row13 type methods
|
|||
// -------------------------------------------------------------------------
|
|||
|
|||
@Override |
|||
public Row13<Long, Integer, String, String, String, String, String, JSON, Boolean, Integer, Integer, Integer, LocalDateTime> fieldsRow() { |
|||
return (Row13) super.fieldsRow(); |
|||
} |
|||
} |
@ -0,0 +1,298 @@ |
|||
/* |
|||
* This file is generated by jOOQ. |
|||
*/ |
|||
package com.databasir.dao.tables.pojos; |
|||
|
|||
|
|||
import java.io.Serializable; |
|||
import java.time.LocalDateTime; |
|||
|
|||
import org.jooq.JSON; |
|||
|
|||
|
|||
/** |
|||
* This class is generated by jOOQ. |
|||
*/ |
|||
@SuppressWarnings({ "all", "unchecked", "rawtypes" }) |
|||
public class OperationLogPojo implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
private Long id; |
|||
private Integer operatorUserId; |
|||
private String operatorUsername; |
|||
private String operatorNickname; |
|||
private String operationModule; |
|||
private String operationCode; |
|||
private String operationName; |
|||
private JSON operationResponse; |
|||
private Boolean isSuccess; |
|||
private Integer involvedProjectId; |
|||
private Integer involvedGroupId; |
|||
private Integer involvedUserId; |
|||
private LocalDateTime createAt; |
|||
|
|||
public OperationLogPojo() {} |
|||
|
|||
public OperationLogPojo(OperationLogPojo value) { |
|||
this.id = value.id; |
|||
this.operatorUserId = value.operatorUserId; |
|||
this.operatorUsername = value.operatorUsername; |
|||
this.operatorNickname = value.operatorNickname; |
|||
this.operationModule = value.operationModule; |
|||
this.operationCode = value.operationCode; |
|||
this.operationName = value.operationName; |
|||
this.operationResponse = value.operationResponse; |
|||
this.isSuccess = value.isSuccess; |
|||
this.involvedProjectId = value.involvedProjectId; |
|||
this.involvedGroupId = value.involvedGroupId; |
|||
this.involvedUserId = value.involvedUserId; |
|||
this.createAt = value.createAt; |
|||
} |
|||
|
|||
public OperationLogPojo( |
|||
Long id, |
|||
Integer operatorUserId, |
|||
String operatorUsername, |
|||
String operatorNickname, |
|||
String operationModule, |
|||
String operationCode, |
|||
String operationName, |
|||
JSON operationResponse, |
|||
Boolean isSuccess, |
|||
Integer involvedProjectId, |
|||
Integer involvedGroupId, |
|||
Integer involvedUserId, |
|||
LocalDateTime createAt |
|||
) { |
|||
this.id = id; |
|||
this.operatorUserId = operatorUserId; |
|||
this.operatorUsername = operatorUsername; |
|||
this.operatorNickname = operatorNickname; |
|||
this.operationModule = operationModule; |
|||
this.operationCode = operationCode; |
|||
this.operationName = operationName; |
|||
this.operationResponse = operationResponse; |
|||
this.isSuccess = isSuccess; |
|||
this.involvedProjectId = involvedProjectId; |
|||
this.involvedGroupId = involvedGroupId; |
|||
this.involvedUserId = involvedUserId; |
|||
this.createAt = createAt; |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.id</code>. |
|||
*/ |
|||
public Long getId() { |
|||
return this.id; |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.id</code>. |
|||
*/ |
|||
public void setId(Long id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.operator_user_id</code>. ref to |
|||
* user.id |
|||
*/ |
|||
public Integer getOperatorUserId() { |
|||
return this.operatorUserId; |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.operator_user_id</code>. ref to |
|||
* user.id |
|||
*/ |
|||
public void setOperatorUserId(Integer operatorUserId) { |
|||
this.operatorUserId = operatorUserId; |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.operator_username</code>. |
|||
* user.username |
|||
*/ |
|||
public String getOperatorUsername() { |
|||
return this.operatorUsername; |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.operator_username</code>. |
|||
* user.username |
|||
*/ |
|||
public void setOperatorUsername(String operatorUsername) { |
|||
this.operatorUsername = operatorUsername; |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.operator_nickname</code>. |
|||
* user.nickname |
|||
*/ |
|||
public String getOperatorNickname() { |
|||
return this.operatorNickname; |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.operator_nickname</code>. |
|||
* user.nickname |
|||
*/ |
|||
public void setOperatorNickname(String operatorNickname) { |
|||
this.operatorNickname = operatorNickname; |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.operation_module</code>. |
|||
*/ |
|||
public String getOperationModule() { |
|||
return this.operationModule; |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.operation_module</code>. |
|||
*/ |
|||
public void setOperationModule(String operationModule) { |
|||
this.operationModule = operationModule; |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.operation_code</code>. |
|||
*/ |
|||
public String getOperationCode() { |
|||
return this.operationCode; |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.operation_code</code>. |
|||
*/ |
|||
public void setOperationCode(String operationCode) { |
|||
this.operationCode = operationCode; |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.operation_name</code>. |
|||
*/ |
|||
public String getOperationName() { |
|||
return this.operationName; |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.operation_name</code>. |
|||
*/ |
|||
public void setOperationName(String operationName) { |
|||
this.operationName = operationName; |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.operation_response</code>. |
|||
*/ |
|||
public JSON getOperationResponse() { |
|||
return this.operationResponse; |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.operation_response</code>. |
|||
*/ |
|||
public void setOperationResponse(JSON operationResponse) { |
|||
this.operationResponse = operationResponse; |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.is_success</code>. |
|||
*/ |
|||
public Boolean getIsSuccess() { |
|||
return this.isSuccess; |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.is_success</code>. |
|||
*/ |
|||
public void setIsSuccess(Boolean isSuccess) { |
|||
this.isSuccess = isSuccess; |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.involved_project_id</code>. ref |
|||
* to project.id |
|||
*/ |
|||
public Integer getInvolvedProjectId() { |
|||
return this.involvedProjectId; |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.involved_project_id</code>. ref |
|||
* to project.id |
|||
*/ |
|||
public void setInvolvedProjectId(Integer involvedProjectId) { |
|||
this.involvedProjectId = involvedProjectId; |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.involved_group_id</code>. ref to |
|||
* group.id |
|||
*/ |
|||
public Integer getInvolvedGroupId() { |
|||
return this.involvedGroupId; |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.involved_group_id</code>. ref to |
|||
* group.id |
|||
*/ |
|||
public void setInvolvedGroupId(Integer involvedGroupId) { |
|||
this.involvedGroupId = involvedGroupId; |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.involved_user_id</code>. ref to |
|||
* user.id |
|||
*/ |
|||
public Integer getInvolvedUserId() { |
|||
return this.involvedUserId; |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.involved_user_id</code>. ref to |
|||
* user.id |
|||
*/ |
|||
public void setInvolvedUserId(Integer involvedUserId) { |
|||
this.involvedUserId = involvedUserId; |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.create_at</code>. |
|||
*/ |
|||
public LocalDateTime getCreateAt() { |
|||
return this.createAt; |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.create_at</code>. |
|||
*/ |
|||
public void setCreateAt(LocalDateTime createAt) { |
|||
this.createAt = createAt; |
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
StringBuilder sb = new StringBuilder("OperationLogPojo ("); |
|||
|
|||
sb.append(id); |
|||
sb.append(", ").append(operatorUserId); |
|||
sb.append(", ").append(operatorUsername); |
|||
sb.append(", ").append(operatorNickname); |
|||
sb.append(", ").append(operationModule); |
|||
sb.append(", ").append(operationCode); |
|||
sb.append(", ").append(operationName); |
|||
sb.append(", ").append(operationResponse); |
|||
sb.append(", ").append(isSuccess); |
|||
sb.append(", ").append(involvedProjectId); |
|||
sb.append(", ").append(involvedGroupId); |
|||
sb.append(", ").append(involvedUserId); |
|||
sb.append(", ").append(createAt); |
|||
|
|||
sb.append(")"); |
|||
return sb.toString(); |
|||
} |
|||
} |
@ -0,0 +1,590 @@ |
|||
/* |
|||
* This file is generated by jOOQ. |
|||
*/ |
|||
package com.databasir.dao.tables.records; |
|||
|
|||
|
|||
import com.databasir.dao.tables.OperationLog; |
|||
import com.databasir.dao.tables.pojos.OperationLogPojo; |
|||
|
|||
import java.time.LocalDateTime; |
|||
|
|||
import org.jooq.Field; |
|||
import org.jooq.JSON; |
|||
import org.jooq.Record1; |
|||
import org.jooq.Record13; |
|||
import org.jooq.Row13; |
|||
import org.jooq.impl.UpdatableRecordImpl; |
|||
|
|||
|
|||
/** |
|||
* This class is generated by jOOQ. |
|||
*/ |
|||
@SuppressWarnings({ "all", "unchecked", "rawtypes" }) |
|||
public class OperationLogRecord extends UpdatableRecordImpl<OperationLogRecord> implements Record13<Long, Integer, String, String, String, String, String, JSON, Boolean, Integer, Integer, Integer, LocalDateTime> { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.id</code>. |
|||
*/ |
|||
public void setId(Long value) { |
|||
set(0, value); |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.id</code>. |
|||
*/ |
|||
public Long getId() { |
|||
return (Long) get(0); |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.operator_user_id</code>. ref to |
|||
* user.id |
|||
*/ |
|||
public void setOperatorUserId(Integer value) { |
|||
set(1, value); |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.operator_user_id</code>. ref to |
|||
* user.id |
|||
*/ |
|||
public Integer getOperatorUserId() { |
|||
return (Integer) get(1); |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.operator_username</code>. |
|||
* user.username |
|||
*/ |
|||
public void setOperatorUsername(String value) { |
|||
set(2, value); |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.operator_username</code>. |
|||
* user.username |
|||
*/ |
|||
public String getOperatorUsername() { |
|||
return (String) get(2); |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.operator_nickname</code>. |
|||
* user.nickname |
|||
*/ |
|||
public void setOperatorNickname(String value) { |
|||
set(3, value); |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.operator_nickname</code>. |
|||
* user.nickname |
|||
*/ |
|||
public String getOperatorNickname() { |
|||
return (String) get(3); |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.operation_module</code>. |
|||
*/ |
|||
public void setOperationModule(String value) { |
|||
set(4, value); |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.operation_module</code>. |
|||
*/ |
|||
public String getOperationModule() { |
|||
return (String) get(4); |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.operation_code</code>. |
|||
*/ |
|||
public void setOperationCode(String value) { |
|||
set(5, value); |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.operation_code</code>. |
|||
*/ |
|||
public String getOperationCode() { |
|||
return (String) get(5); |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.operation_name</code>. |
|||
*/ |
|||
public void setOperationName(String value) { |
|||
set(6, value); |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.operation_name</code>. |
|||
*/ |
|||
public String getOperationName() { |
|||
return (String) get(6); |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.operation_response</code>. |
|||
*/ |
|||
public void setOperationResponse(JSON value) { |
|||
set(7, value); |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.operation_response</code>. |
|||
*/ |
|||
public JSON getOperationResponse() { |
|||
return (JSON) get(7); |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.is_success</code>. |
|||
*/ |
|||
public void setIsSuccess(Boolean value) { |
|||
set(8, value); |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.is_success</code>. |
|||
*/ |
|||
public Boolean getIsSuccess() { |
|||
return (Boolean) get(8); |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.involved_project_id</code>. ref |
|||
* to project.id |
|||
*/ |
|||
public void setInvolvedProjectId(Integer value) { |
|||
set(9, value); |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.involved_project_id</code>. ref |
|||
* to project.id |
|||
*/ |
|||
public Integer getInvolvedProjectId() { |
|||
return (Integer) get(9); |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.involved_group_id</code>. ref to |
|||
* group.id |
|||
*/ |
|||
public void setInvolvedGroupId(Integer value) { |
|||
set(10, value); |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.involved_group_id</code>. ref to |
|||
* group.id |
|||
*/ |
|||
public Integer getInvolvedGroupId() { |
|||
return (Integer) get(10); |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.involved_user_id</code>. ref to |
|||
* user.id |
|||
*/ |
|||
public void setInvolvedUserId(Integer value) { |
|||
set(11, value); |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.involved_user_id</code>. ref to |
|||
* user.id |
|||
*/ |
|||
public Integer getInvolvedUserId() { |
|||
return (Integer) get(11); |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.operation_log.create_at</code>. |
|||
*/ |
|||
public void setCreateAt(LocalDateTime value) { |
|||
set(12, value); |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.operation_log.create_at</code>. |
|||
*/ |
|||
public LocalDateTime getCreateAt() { |
|||
return (LocalDateTime) get(12); |
|||
} |
|||
|
|||
// -------------------------------------------------------------------------
|
|||
// Primary key information
|
|||
// -------------------------------------------------------------------------
|
|||
|
|||
@Override |
|||
public Record1<Long> key() { |
|||
return (Record1) super.key(); |
|||
} |
|||
|
|||
// -------------------------------------------------------------------------
|
|||
// Record13 type implementation
|
|||
// -------------------------------------------------------------------------
|
|||
|
|||
@Override |
|||
public Row13<Long, Integer, String, String, String, String, String, JSON, Boolean, Integer, Integer, Integer, LocalDateTime> fieldsRow() { |
|||
return (Row13) super.fieldsRow(); |
|||
} |
|||
|
|||
@Override |
|||
public Row13<Long, Integer, String, String, String, String, String, JSON, Boolean, Integer, Integer, Integer, LocalDateTime> valuesRow() { |
|||
return (Row13) super.valuesRow(); |
|||
} |
|||
|
|||
@Override |
|||
public Field<Long> field1() { |
|||
return OperationLog.OPERATION_LOG.ID; |
|||
} |
|||
|
|||
@Override |
|||
public Field<Integer> field2() { |
|||
return OperationLog.OPERATION_LOG.OPERATOR_USER_ID; |
|||
} |
|||
|
|||
@Override |
|||
public Field<String> field3() { |
|||
return OperationLog.OPERATION_LOG.OPERATOR_USERNAME; |
|||
} |
|||
|
|||
@Override |
|||
public Field<String> field4() { |
|||
return OperationLog.OPERATION_LOG.OPERATOR_NICKNAME; |
|||
} |
|||
|
|||
@Override |
|||
public Field<String> field5() { |
|||
return OperationLog.OPERATION_LOG.OPERATION_MODULE; |
|||
} |
|||
|
|||
@Override |
|||
public Field<String> field6() { |
|||
return OperationLog.OPERATION_LOG.OPERATION_CODE; |
|||
} |
|||
|
|||
@Override |
|||
public Field<String> field7() { |
|||
return OperationLog.OPERATION_LOG.OPERATION_NAME; |
|||
} |
|||
|
|||
@Override |
|||
public Field<JSON> field8() { |
|||
return OperationLog.OPERATION_LOG.OPERATION_RESPONSE; |
|||
} |
|||
|
|||
@Override |
|||
public Field<Boolean> field9() { |
|||
return OperationLog.OPERATION_LOG.IS_SUCCESS; |
|||
} |
|||
|
|||
@Override |
|||
public Field<Integer> field10() { |
|||
return OperationLog.OPERATION_LOG.INVOLVED_PROJECT_ID; |
|||
} |
|||
|
|||
@Override |
|||
public Field<Integer> field11() { |
|||
return OperationLog.OPERATION_LOG.INVOLVED_GROUP_ID; |
|||
} |
|||
|
|||
@Override |
|||
public Field<Integer> field12() { |
|||
return OperationLog.OPERATION_LOG.INVOLVED_USER_ID; |
|||
} |
|||
|
|||
@Override |
|||
public Field<LocalDateTime> field13() { |
|||
return OperationLog.OPERATION_LOG.CREATE_AT; |
|||
} |
|||
|
|||
@Override |
|||
public Long component1() { |
|||
return getId(); |
|||
} |
|||
|
|||
@Override |
|||
public Integer component2() { |
|||
return getOperatorUserId(); |
|||
} |
|||
|
|||
@Override |
|||
public String component3() { |
|||
return getOperatorUsername(); |
|||
} |
|||
|
|||
@Override |
|||
public String component4() { |
|||
return getOperatorNickname(); |
|||
} |
|||
|
|||
@Override |
|||
public String component5() { |
|||
return getOperationModule(); |
|||
} |
|||
|
|||
@Override |
|||
public String component6() { |
|||
return getOperationCode(); |
|||
} |
|||
|
|||
@Override |
|||
public String component7() { |
|||
return getOperationName(); |
|||
} |
|||
|
|||
@Override |
|||
public JSON component8() { |
|||
return getOperationResponse(); |
|||
} |
|||
|
|||
@Override |
|||
public Boolean component9() { |
|||
return getIsSuccess(); |
|||
} |
|||
|
|||
@Override |
|||
public Integer component10() { |
|||
return getInvolvedProjectId(); |
|||
} |
|||
|
|||
@Override |
|||
public Integer component11() { |
|||
return getInvolvedGroupId(); |
|||
} |
|||
|
|||
@Override |
|||
public Integer component12() { |
|||
return getInvolvedUserId(); |
|||
} |
|||
|
|||
@Override |
|||
public LocalDateTime component13() { |
|||
return getCreateAt(); |
|||
} |
|||
|
|||
@Override |
|||
public Long value1() { |
|||
return getId(); |
|||
} |
|||
|
|||
@Override |
|||
public Integer value2() { |
|||
return getOperatorUserId(); |
|||
} |
|||
|
|||
@Override |
|||
public String value3() { |
|||
return getOperatorUsername(); |
|||
} |
|||
|
|||
@Override |
|||
public String value4() { |
|||
return getOperatorNickname(); |
|||
} |
|||
|
|||
@Override |
|||
public String value5() { |
|||
return getOperationModule(); |
|||
} |
|||
|
|||
@Override |
|||
public String value6() { |
|||
return getOperationCode(); |
|||
} |
|||
|
|||
@Override |
|||
public String value7() { |
|||
return getOperationName(); |
|||
} |
|||
|
|||
@Override |
|||
public JSON value8() { |
|||
return getOperationResponse(); |
|||
} |
|||
|
|||
@Override |
|||
public Boolean value9() { |
|||
return getIsSuccess(); |
|||
} |
|||
|
|||
@Override |
|||
public Integer value10() { |
|||
return getInvolvedProjectId(); |
|||
} |
|||
|
|||
@Override |
|||
public Integer value11() { |
|||
return getInvolvedGroupId(); |
|||
} |
|||
|
|||
@Override |
|||
public Integer value12() { |
|||
return getInvolvedUserId(); |
|||
} |
|||
|
|||
@Override |
|||
public LocalDateTime value13() { |
|||
return getCreateAt(); |
|||
} |
|||
|
|||
@Override |
|||
public OperationLogRecord value1(Long value) { |
|||
setId(value); |
|||
return this; |
|||
} |
|||
|
|||
@Override |
|||
public OperationLogRecord value2(Integer value) { |
|||
setOperatorUserId(value); |
|||
return this; |
|||
} |
|||
|
|||
@Override |
|||
public OperationLogRecord value3(String value) { |
|||
setOperatorUsername(value); |
|||
return this; |
|||
} |
|||
|
|||
@Override |
|||
public OperationLogRecord value4(String value) { |
|||
setOperatorNickname(value); |
|||
return this; |
|||
} |
|||
|
|||
@Override |
|||
public OperationLogRecord value5(String value) { |
|||
setOperationModule(value); |
|||
return this; |
|||
} |
|||
|
|||
@Override |
|||
public OperationLogRecord value6(String value) { |
|||
setOperationCode(value); |
|||
return this; |
|||
} |
|||
|
|||
@Override |
|||
public OperationLogRecord value7(String value) { |
|||
setOperationName(value); |
|||
return this; |
|||
} |
|||
|
|||
@Override |
|||
public OperationLogRecord value8(JSON value) { |
|||
setOperationResponse(value); |
|||
return this; |
|||
} |
|||
|
|||
@Override |
|||
public OperationLogRecord value9(Boolean value) { |
|||
setIsSuccess(value); |
|||
return this; |
|||
} |
|||
|
|||
@Override |
|||
public OperationLogRecord value10(Integer value) { |
|||
setInvolvedProjectId(value); |
|||
return this; |
|||
} |
|||
|
|||
@Override |
|||
public OperationLogRecord value11(Integer value) { |
|||
setInvolvedGroupId(value); |
|||
return this; |
|||
} |
|||
|
|||
@Override |
|||
public OperationLogRecord value12(Integer value) { |
|||
setInvolvedUserId(value); |
|||
return this; |
|||
} |
|||
|
|||
@Override |
|||
public OperationLogRecord value13(LocalDateTime value) { |
|||
setCreateAt(value); |
|||
return this; |
|||
} |
|||
|
|||
@Override |
|||
public OperationLogRecord values(Long value1, Integer value2, String value3, String value4, String value5, String value6, String value7, JSON value8, Boolean value9, Integer value10, Integer value11, Integer value12, LocalDateTime value13) { |
|||
value1(value1); |
|||
value2(value2); |
|||
value3(value3); |
|||
value4(value4); |
|||
value5(value5); |
|||
value6(value6); |
|||
value7(value7); |
|||
value8(value8); |
|||
value9(value9); |
|||
value10(value10); |
|||
value11(value11); |
|||
value12(value12); |
|||
value13(value13); |
|||
return this; |
|||
} |
|||
|
|||
// -------------------------------------------------------------------------
|
|||
// Constructors
|
|||
// -------------------------------------------------------------------------
|
|||
|
|||
/** |
|||
* Create a detached OperationLogRecord |
|||
*/ |
|||
public OperationLogRecord() { |
|||
super(OperationLog.OPERATION_LOG); |
|||
} |
|||
|
|||
/** |
|||
* Create a detached, initialised OperationLogRecord |
|||
*/ |
|||
public OperationLogRecord(Long id, Integer operatorUserId, String operatorUsername, String operatorNickname, String operationModule, String operationCode, String operationName, JSON operationResponse, Boolean isSuccess, Integer involvedProjectId, Integer involvedGroupId, Integer involvedUserId, LocalDateTime createAt) { |
|||
super(OperationLog.OPERATION_LOG); |
|||
|
|||
setId(id); |
|||
setOperatorUserId(operatorUserId); |
|||
setOperatorUsername(operatorUsername); |
|||
setOperatorNickname(operatorNickname); |
|||
setOperationModule(operationModule); |
|||
setOperationCode(operationCode); |
|||
setOperationName(operationName); |
|||
setOperationResponse(operationResponse); |
|||
setIsSuccess(isSuccess); |
|||
setInvolvedProjectId(involvedProjectId); |
|||
setInvolvedGroupId(involvedGroupId); |
|||
setInvolvedUserId(involvedUserId); |
|||
setCreateAt(createAt); |
|||
} |
|||
|
|||
/** |
|||
* Create a detached, initialised OperationLogRecord |
|||
*/ |
|||
public OperationLogRecord(OperationLogPojo value) { |
|||
super(OperationLog.OPERATION_LOG); |
|||
|
|||
if (value != null) { |
|||
setId(value.getId()); |
|||
setOperatorUserId(value.getOperatorUserId()); |
|||
setOperatorUsername(value.getOperatorUsername()); |
|||
setOperatorNickname(value.getOperatorNickname()); |
|||
setOperationModule(value.getOperationModule()); |
|||
setOperationCode(value.getOperationCode()); |
|||
setOperationName(value.getOperationName()); |
|||
setOperationResponse(value.getOperationResponse()); |
|||
setIsSuccess(value.getIsSuccess()); |
|||
setInvolvedProjectId(value.getInvolvedProjectId()); |
|||
setInvolvedGroupId(value.getInvolvedGroupId()); |
|||
setInvolvedUserId(value.getInvolvedUserId()); |
|||
setCreateAt(value.getCreateAt()); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,28 @@ |
|||
package com.databasir.dao.impl; |
|||
|
|||
import com.databasir.dao.tables.pojos.OperationLogPojo; |
|||
import lombok.Getter; |
|||
import org.jooq.DSLContext; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
import static com.databasir.dao.Tables.OPERATION_LOG; |
|||
|
|||
@Repository |
|||
public class OperationLogDao extends BaseDao<OperationLogPojo> { |
|||
|
|||
@Autowired |
|||
@Getter |
|||
private DSLContext dslContext; |
|||
|
|||
public OperationLogDao() { |
|||
super(OPERATION_LOG, OperationLogPojo.class); |
|||
} |
|||
|
|||
@Override |
|||
protected <T extends Serializable> Class<T> identityType() { |
|||
return (Class<T>) Long.class; |
|||
} |
|||
} |
@ -0,0 +1,18 @@ |
|||
CREATE TABLE operation_log |
|||
( |
|||
id BIGINT PRIMARY KEY AUTO_INCREMENT NOT NULL, |
|||
|
|||
operator_user_id INT NOT NULL COMMENT 'ref to user.id', |
|||
operator_username VARCHAR(128) NOT NULL COMMENT 'user.username', |
|||
operator_nickname VARCHAR(255) NOT NULL COMMENT 'user.nickname', |
|||
operation_module VARCHAR(128) NOT NULL, |
|||
operation_code VARCHAR(255) NOT NULL, |
|||
operation_name VARCHAR(255) NOT NULL, |
|||
operation_response JSON NOT NULL, |
|||
is_success BOOLEAN NOT NULL DEFAULT FALSE, |
|||
involved_project_id INT DEFAULT NULL COMMENT 'ref to project.id', |
|||
involved_group_id INT DEFAULT NULL COMMENT 'ref to group.id', |
|||
involved_user_id INT DEFAULT NULL COMMENT 'ref to user.id', |
|||
create_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP |
|||
) CHARSET utf8mb4 |
|||
COLLATE utf8mb4_unicode_ci; |
Loading…
Reference in new issue