Browse Source
* feat: template property jooq generate * feat: add template property api * feat: update export logic * feat: update frontend resourcesmaster
committed by
GitHub
60 changed files with 1282 additions and 176 deletions
@ -0,0 +1,38 @@ |
|||
package com.databasir.api; |
|||
|
|||
import com.databasir.common.JsonData; |
|||
import com.databasir.core.domain.document.data.DocumentTemplatePropertiesResponse; |
|||
import com.databasir.core.domain.document.data.DocumentTemplatePropertiesUpdateRequest; |
|||
import com.databasir.core.domain.document.service.DocumentTemplateService; |
|||
import com.databasir.core.domain.log.annotation.Operation; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.security.access.prepost.PreAuthorize; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PatchMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import javax.validation.Valid; |
|||
|
|||
@RequiredArgsConstructor |
|||
@Validated |
|||
@RestController |
|||
public class DocumentTemplateController { |
|||
|
|||
private final DocumentTemplateService documentTemplateService; |
|||
|
|||
@GetMapping(Routes.DocumentTemplateProperty.API) |
|||
public JsonData<DocumentTemplatePropertiesResponse> getAllProperties() { |
|||
return JsonData.ok(documentTemplateService.getAllProperties()); |
|||
} |
|||
|
|||
@PatchMapping(Routes.DocumentTemplateProperty.API) |
|||
@PreAuthorize("hasAnyAuthority('SYS_OWNER')") |
|||
@Operation(module = Operation.Modules.SETTING, name = "更新模板") |
|||
public JsonData<Void> updateByType(@RequestBody @Valid DocumentTemplatePropertiesUpdateRequest request) { |
|||
documentTemplateService.updateByType(request); |
|||
return JsonData.ok(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1 @@ |
|||
.el-row{margin-bottom:12px} |
@ -1 +1 @@ |
|||
@-webkit-keyframes running-line{to{stroke-dashoffset:-1000}}@keyframes running-line{to{stroke-dashoffset:-1000}}.text{font-size:14px;line-height:1.3rem}.item{margin-top:10px;margin-right:40px}.remark-card{margin-bottom:30px}.remark-header{display:flex;justify-content:space-between;align-items:center}.remark-header .remark-user{color:#6d6d6d}.remark-header .remark-time{color:#6d6d6d;font-size:.8rem;margin-left:10px}.remark-content{white-space:pre-wrap;text-align:left}.badge-item{margin-top:18px;margin-bottom:6px}.h2{font-size:24px;color:#606266;margin-top:13px;margin-bottom:13px}.h2,.h3{font-family:Helvetica Neue,Helvetica,PingFang SC,Hiragino Sans GB,Microsoft YaHei,微软雅黑,Arial,sans-serif}.h3{font-size:20px;color:#909399;margin-top:18px;margin-bottom:18px}.removed-item{background-color:#fef0f0!important;color:#f56c6c}.added-item{background-color:#f0f9eb!important;color:#67c23a}.modified-item{background-color:#fdf6ec!important;color:#e6a23c}.modified-original-item{background-color:#fdf6ec!important;color:#a8abb2}.span-ellipsis{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;flex:1;display:flex;align-items:left;justify-content:space-between;font-size:14px}.doc-toc-aside{overflow-wrap:break-word;text-overflow:ellipsis;bottom:0;top:100px;position:fixed;overflow-y:hidden;overflow-x:hidden;max-width:var(--el-aside-width);width:var(--el-aside-width);border-width:0 1px 0 0;border-color:#ddd;border-style:solid}.doc-toc-aside:hover{overflow-y:auto;scrollbar-width:thin} |
|||
@-webkit-keyframes running-line{to{stroke-dashoffset:-1000}}@keyframes running-line{to{stroke-dashoffset:-1000}}.text{font-size:14px;line-height:1.3rem}.item{margin-top:10px;margin-right:40px}.remark-card{margin-bottom:30px}.remark-header{display:flex;justify-content:space-between;align-items:center}.remark-header .remark-user{color:#6d6d6d}.remark-header .remark-time{color:#6d6d6d;font-size:.8rem;margin-left:10px}.remark-content{white-space:pre-wrap;text-align:left}.badge-item{margin-top:18px;margin-bottom:6px}.removed-item{background-color:#fef0f0!important;color:#f56c6c}.added-item{background-color:#f0f9eb!important;color:#67c23a}.modified-item{background-color:#fdf6ec!important;color:#e6a23c}.modified-original-item{background-color:#fdf6ec!important;color:#a8abb2}.span-ellipsis{width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;flex:1;display:flex;align-items:left;justify-content:space-between;font-size:14px}.doc-toc-aside{overflow-wrap:break-word;text-overflow:ellipsis;bottom:0;top:100px;position:fixed;overflow-y:hidden;overflow-x:hidden;max-width:var(--el-aside-width);width:var(--el-aside-width);border-width:0 1px 0 0;border-color:#ddd;border-style:solid}.doc-toc-aside:hover{overflow-y:auto;scrollbar-width:thin} |
@ -1 +1 @@ |
|||
.left-menu:not(.el-menu--collapse){height:100vh}.databasir-nav{left:0;bottom:0}.databasir-main-header,.databasir-nav{position:fixed;transform:scale(1);top:0}.databasir-main-header{display:flex;justify-content:space-between;align-items:center;right:0;left:50px;padding:30px;margin-left:33px;background:#fff;z-index:100;border-color:#eee;border-width:0 0 1px 0;border-style:solid}.databasir{display:block}.databasir-main{position:relative;margin-left:60px;margin-top:80px;--el-main-padding:0px 20px 20px 20px}.databasir-main-expand{margin-left:50px}.databasir-main-content{max-width:95%;--el-main-padding:0px 20px 20px 20px} |
|||
.left-menu:not(.el-menu--collapse){height:100vh}.databasir-nav{left:0;bottom:0}.databasir-main-header,.databasir-nav{position:fixed;transform:scale(1);top:0}.databasir-main-header{display:flex;justify-content:space-between;align-items:center;right:0;left:50px;padding:30px;margin-left:33px;background:#fff;z-index:100;border-color:#eee;border-width:0 0 1px 0;border-style:solid}.databasir{display:block}.databasir-main{position:relative;margin-left:60px;margin-top:80px;--el-main-padding:0px 20px 20px 20px}.databasir-main-expand{margin-left:50px}.databasir-main-content{max-width:95%;--el-main-padding:0px 20px 20px 20px}.h2{font-size:24px;color:#606266;margin-top:13px;margin-bottom:13px}.h2,.h3{font-family:Helvetica Neue,Helvetica,PingFang SC,Hiragino Sans GB,Microsoft YaHei,微软雅黑,Arial,sans-serif}.h3{font-size:20px;color:#909399;margin-top:18px;margin-bottom:18px} |
@ -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</title><script defer="defer" type="module" src="/js/chunk-vendors.98e14a99.js"></script><script defer="defer" type="module" src="/js/app.ccfb747d.js"></script><link href="/css/chunk-vendors.8e1003a6.css" rel="stylesheet"><link href="/css/app.757c1ef3.css" rel="stylesheet"><script defer="defer" src="/js/chunk-vendors-legacy.2897f987.js" nomodule></script><script defer="defer" src="/js/app-legacy.89421156.js" nomodule></script></head><body><noscript><strong>We're sorry but databasir doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></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</title><script defer="defer" type="module" src="/js/chunk-vendors.c33500d9.js"></script><script defer="defer" type="module" src="/js/app.dcbe0648.js"></script><link href="/css/chunk-vendors.8e1003a6.css" rel="stylesheet"><link href="/css/app.15b40a89.css" rel="stylesheet"><script defer="defer" src="/js/chunk-vendors-legacy.2897f987.js" nomodule></script><script defer="defer" src="/js/app-legacy.359fd70e.js" nomodule></script></head><body><noscript><strong>We're sorry but databasir doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></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
@ -1,2 +1,2 @@ |
|||
"use strict";(self["webpackChunkdatabasir"]=self["webpackChunkdatabasir"]||[]).push([[243],{1243:function(e,t,n){n.r(t),n.d(t,{default:function(){return W}});var r=n(6252),u=(0,r.Uk)(" 系统邮箱设置 "),o=(0,r.Uk)(" : "),l=(0,r.Uk)("保存"),a=(0,r.Uk)("重置");function s(e,t,n,s,i,m){var f=(0,r.up)("box"),d=(0,r.up)("el-icon"),p=(0,r.up)("el-divider"),c=(0,r.up)("el-input"),w=(0,r.up)("el-form-item"),h=(0,r.up)("el-col"),g=(0,r.up)("el-switch"),W=(0,r.up)("el-button"),V=(0,r.up)("el-form"),S=(0,r.up)("el-card"),_=(0,r.up)("el-main"),b=(0,r.up)("el-container");return(0,r.wg)(),(0,r.j4)(b,null,{default:(0,r.w5)((function(){return[(0,r.Wm)(_,null,{default:(0,r.w5)((function(){return[(0,r.Wm)(S,{shadow:"hover",style:{"max-width":"600px"}},{default:(0,r.w5)((function(){return[(0,r.Wm)(p,null,{default:(0,r.w5)((function(){return[(0,r.Wm)(d,null,{default:(0,r.w5)((function(){return[(0,r.Wm)(f)]})),_:1}),u]})),_:1}),(0,r.Wm)(V,{model:i.form,"label-position":"top",rules:i.formRule,ref:"formRef",style:{"max-width":"900px"}},{default:(0,r.w5)((function(){return[(0,r.Wm)(w,{label:"邮箱账号",prop:"username"},{default:(0,r.w5)((function(){return[(0,r.Wm)(c,{modelValue:i.form.username,"onUpdate:modelValue":t[0]||(t[0]=function(e){return i.form.username=e}),placeholder:"请输入邮箱账号"},null,8,["modelValue"])]})),_:1}),(0,r.Wm)(w,{label:"邮箱密码",prop:"password"},{default:(0,r.w5)((function(){return[(0,r.Wm)(c,{modelValue:i.form.password,"onUpdate:modelValue":t[1]||(t[1]=function(e){return i.form.password=e}),type:"password",placeholder:"请输入密码","show-password":""},null,8,["modelValue"])]})),_:1}),(0,r.Wm)(w,{label:"SMTP",prop:"smtpHost"},{default:(0,r.w5)((function(){return[(0,r.Wm)(h,{span:12},{default:(0,r.w5)((function(){return[(0,r.Wm)(c,{modelValue:i.form.smtpHost,"onUpdate:modelValue":t[2]||(t[2]=function(e){return i.form.smtpHost=e}),placeholder:"SMTP Host"},null,8,["modelValue"])]})),_:1}),(0,r.Wm)(h,{span:1,style:{"text-align":"center"}},{default:(0,r.w5)((function(){return[o]})),_:1}),(0,r.Wm)(h,{span:6},{default:(0,r.w5)((function(){return[(0,r.Wm)(c,{modelValue:i.form.smtpPort,"onUpdate:modelValue":t[3]||(t[3]=function(e){return i.form.smtpPort=e}),placeholder:"SMTP Port"},null,8,["modelValue"])]})),_:1})]})),_:1}),(0,r.Wm)(w,{label:"启用 SSL",prop:"useSSL"},{default:(0,r.w5)((function(){return[(0,r.Wm)(g,{modelValue:i.form.useSSL,"onUpdate:modelValue":t[4]||(t[4]=function(e){return i.form.useSSL=e})},null,8,["modelValue"])]})),_:1}),(0,r.Wm)(w,{style:{"margin-top":"38px"}},{default:(0,r.w5)((function(){return[(0,r.Wm)(W,{type:"primary",onClick:t[5]||(t[5]=function(e){return m.onSubmit("formRef")})},{default:(0,r.w5)((function(){return[l]})),_:1}),(0,r.Wm)(W,{type:"danger",onClick:t[6]||(t[6]=function(e){return m.onReset()})},{default:(0,r.w5)((function(){return[a]})),_:1})]})),_:1})]})),_:1},8,["model","rules"])]})),_:1})]})),_:1})]})),_:1})}var i=n(8534),m=(n(5666),n(3872)),f="/api/v1.0/settings",d=function(){return m.Z.get(f+"/sys_email")},p=function(e){return m.Z.post(f+"/sys_email",e)},c=function(){return m.Z["delete"](f+"/sys_email")},w={data:function(){return{form:{smtpHost:null,smtpPort:null,username:null,password:null,useSSL:!1},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(0,i.Z)(regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,d().then((function(e){return e.data}));case 2:n=t.sent,n&&(e.form=n);case 4:case"end":return t.stop()}}),t)})))()},onSubmit:function(){var e=this;this.$refs.formRef.validate((function(t){return t?(p(e.form).then((function(t){t.errCode||e.$message.success("更新成功")})),!0):(e.$message.error("请完善表单相关信息!"),!1)}))},onReset:function(){var e=this;this.$confirm("确认重置系统邮件吗?删除后数据将无法恢复","警告",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then((function(){c().then((function(t){t.errCode||(e.form={},e.$message.success("重置成功"))}))}))}}},h=n(3744);const g=(0,h.Z)(w,[["render",s]]);var W=g}}]); |
|||
//# sourceMappingURL=243-legacy.92016c20.js.map
|
|||
//# sourceMappingURL=243-legacy.8e2218d7.js.map
|
File diff suppressed because one or more lines are too long
@ -1,2 +1,2 @@ |
|||
"use strict";(self["webpackChunkdatabasir"]=self["webpackChunkdatabasir"]||[]).push([[243],{1243:function(e,l,t){t.r(l),t.d(l,{default:function(){return W}});var a=t(6252);const s=(0,a.Uk)(" 系统邮箱设置 "),r=(0,a.Uk)(" : "),u=(0,a.Uk)("保存"),o=(0,a.Uk)("重置");function m(e,l,t,m,n,d){const p=(0,a.up)("box"),i=(0,a.up)("el-icon"),f=(0,a.up)("el-divider"),c=(0,a.up)("el-input"),h=(0,a.up)("el-form-item"),w=(0,a.up)("el-col"),W=(0,a.up)("el-switch"),V=(0,a.up)("el-button"),g=(0,a.up)("el-form"),S=(0,a.up)("el-card"),_=(0,a.up)("el-main"),b=(0,a.up)("el-container");return(0,a.wg)(),(0,a.j4)(b,null,{default:(0,a.w5)((()=>[(0,a.Wm)(_,null,{default:(0,a.w5)((()=>[(0,a.Wm)(S,{shadow:"hover",style:{"max-width":"600px"}},{default:(0,a.w5)((()=>[(0,a.Wm)(f,null,{default:(0,a.w5)((()=>[(0,a.Wm)(i,null,{default:(0,a.w5)((()=>[(0,a.Wm)(p)])),_:1}),s])),_:1}),(0,a.Wm)(g,{model:n.form,"label-position":"top",rules:n.formRule,ref:"formRef",style:{"max-width":"900px"}},{default:(0,a.w5)((()=>[(0,a.Wm)(h,{label:"邮箱账号",prop:"username"},{default:(0,a.w5)((()=>[(0,a.Wm)(c,{modelValue:n.form.username,"onUpdate:modelValue":l[0]||(l[0]=e=>n.form.username=e),placeholder:"请输入邮箱账号"},null,8,["modelValue"])])),_:1}),(0,a.Wm)(h,{label:"邮箱密码",prop:"password"},{default:(0,a.w5)((()=>[(0,a.Wm)(c,{modelValue:n.form.password,"onUpdate:modelValue":l[1]||(l[1]=e=>n.form.password=e),type:"password",placeholder:"请输入密码","show-password":""},null,8,["modelValue"])])),_:1}),(0,a.Wm)(h,{label:"SMTP",prop:"smtpHost"},{default:(0,a.w5)((()=>[(0,a.Wm)(w,{span:12},{default:(0,a.w5)((()=>[(0,a.Wm)(c,{modelValue:n.form.smtpHost,"onUpdate:modelValue":l[2]||(l[2]=e=>n.form.smtpHost=e),placeholder:"SMTP Host"},null,8,["modelValue"])])),_:1}),(0,a.Wm)(w,{span:1,style:{"text-align":"center"}},{default:(0,a.w5)((()=>[r])),_:1}),(0,a.Wm)(w,{span:6},{default:(0,a.w5)((()=>[(0,a.Wm)(c,{modelValue:n.form.smtpPort,"onUpdate:modelValue":l[3]||(l[3]=e=>n.form.smtpPort=e),placeholder:"SMTP Port"},null,8,["modelValue"])])),_:1})])),_:1}),(0,a.Wm)(h,{label:"启用 SSL",prop:"useSSL"},{default:(0,a.w5)((()=>[(0,a.Wm)(W,{modelValue:n.form.useSSL,"onUpdate:modelValue":l[4]||(l[4]=e=>n.form.useSSL=e)},null,8,["modelValue"])])),_:1}),(0,a.Wm)(h,{style:{"margin-top":"38px"}},{default:(0,a.w5)((()=>[(0,a.Wm)(V,{type:"primary",onClick:l[5]||(l[5]=e=>d.onSubmit("formRef"))},{default:(0,a.w5)((()=>[u])),_:1}),(0,a.Wm)(V,{type:"danger",onClick:l[6]||(l[6]=e=>d.onReset())},{default:(0,a.w5)((()=>[o])),_:1})])),_:1})])),_:1},8,["model","rules"])])),_:1})])),_:1})])),_:1})}var n=t(3872);const d="/api/v1.0/settings",p=()=>n.Z.get(d+"/sys_email"),i=e=>n.Z.post(d+"/sys_email",e),f=()=>n.Z["delete"](d+"/sys_email");var c={data(){return{form:{smtpHost:null,smtpPort:null,username:null,password:null,useSSL:!1},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(){this.fetchSysMail()},methods:{requiredInputValidRule(e){return{required:!0,message:e,trigger:"blur"}},async fetchSysMail(){const e=await p().then((e=>e.data));e&&(this.form=e)},onSubmit(){this.$refs.formRef.validate((e=>e?(i(this.form).then((e=>{e.errCode||this.$message.success("更新成功")})),!0):(this.$message.error("请完善表单相关信息!"),!1)))},onReset(){this.$confirm("确认重置系统邮件吗?删除后数据将无法恢复","警告",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then((()=>{f().then((e=>{e.errCode||(this.form={},this.$message.success("重置成功"))}))}))}}},h=t(3744);const w=(0,h.Z)(c,[["render",m]]);var W=w}}]); |
|||
//# sourceMappingURL=243.e2c9f564.js.map
|
|||
//# sourceMappingURL=243.d82073b3.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
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,25 @@ |
|||
package com.databasir.core.domain.document.converter; |
|||
|
|||
import com.databasir.core.domain.document.data.DocumentTemplatePropertiesUpdateRequest; |
|||
import com.databasir.dao.enums.DocumentTemplatePropertyType; |
|||
import com.databasir.dao.tables.pojos.DocumentTemplatePropertyPojo; |
|||
import org.mapstruct.Mapper; |
|||
import org.mapstruct.Mapping; |
|||
|
|||
import java.util.List; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Mapper(componentModel = "spring") |
|||
public interface DocumentTemplatePropertiesUpdateRequestConverter { |
|||
|
|||
@Mapping(target = "defaultValue", constant = "") |
|||
DocumentTemplatePropertyPojo toPojo(DocumentTemplatePropertiesUpdateRequest.PropertyRequest property, |
|||
DocumentTemplatePropertyType type); |
|||
|
|||
default List<DocumentTemplatePropertyPojo> toPojo(DocumentTemplatePropertiesUpdateRequest request) { |
|||
return request.getProperties().stream() |
|||
.map(prop -> toPojo(prop, request.getType())) |
|||
.collect(Collectors.toList()); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,15 @@ |
|||
package com.databasir.core.domain.document.converter; |
|||
|
|||
import com.databasir.core.domain.document.data.DocumentTemplatePropertiesResponse; |
|||
import com.databasir.dao.tables.pojos.DocumentTemplatePropertyPojo; |
|||
import org.mapstruct.Mapper; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Mapper(componentModel = "spring") |
|||
public interface DocumentTemplatePropertyResponseConverter { |
|||
|
|||
List<DocumentTemplatePropertiesResponse.DocumentTemplatePropertyResponse> of( |
|||
List<DocumentTemplatePropertyPojo> pojoList); |
|||
|
|||
} |
@ -0,0 +1,41 @@ |
|||
package com.databasir.core.domain.document.data; |
|||
|
|||
import com.databasir.dao.enums.DocumentTemplatePropertyType; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Builder; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
import java.time.LocalDateTime; |
|||
import java.util.Collections; |
|||
import java.util.List; |
|||
|
|||
@Data |
|||
@Builder |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
public class DocumentTemplatePropertiesResponse { |
|||
|
|||
private List<DocumentTemplatePropertyResponse> columnFieldNameProperties = Collections.emptyList(); |
|||
|
|||
private List<DocumentTemplatePropertyResponse> indexFieldNameProperties = Collections.emptyList(); |
|||
|
|||
private List<DocumentTemplatePropertyResponse> triggerFieldNameProperties = Collections.emptyList(); |
|||
|
|||
private List<DocumentTemplatePropertyResponse> foreignKeyFieldNameProperties = Collections.emptyList(); |
|||
|
|||
@Data |
|||
public static class DocumentTemplatePropertyResponse { |
|||
|
|||
private String key; |
|||
|
|||
private String value; |
|||
|
|||
private String defaultValue; |
|||
|
|||
private DocumentTemplatePropertyType type; |
|||
|
|||
private LocalDateTime createAt; |
|||
|
|||
} |
|||
} |
@ -0,0 +1,28 @@ |
|||
package com.databasir.core.domain.document.data; |
|||
|
|||
import com.databasir.dao.enums.DocumentTemplatePropertyType; |
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotEmpty; |
|||
import javax.validation.constraints.NotNull; |
|||
import java.util.Collections; |
|||
import java.util.List; |
|||
|
|||
@Data |
|||
public class DocumentTemplatePropertiesUpdateRequest { |
|||
|
|||
@NotNull |
|||
private DocumentTemplatePropertyType type; |
|||
|
|||
@NotEmpty |
|||
private List<PropertyRequest> properties = Collections.emptyList(); |
|||
|
|||
@Data |
|||
public static class PropertyRequest { |
|||
|
|||
private String key; |
|||
|
|||
private String value; |
|||
|
|||
} |
|||
} |
@ -0,0 +1,46 @@ |
|||
package com.databasir.core.domain.document.service; |
|||
|
|||
import com.databasir.core.domain.document.converter.DocumentTemplatePropertiesUpdateRequestConverter; |
|||
import com.databasir.core.domain.document.converter.DocumentTemplatePropertyResponseConverter; |
|||
import com.databasir.core.domain.document.data.DocumentTemplatePropertiesResponse; |
|||
import com.databasir.core.domain.document.data.DocumentTemplatePropertiesUpdateRequest; |
|||
import com.databasir.dao.impl.DocumentTemplatePropertyDao; |
|||
import com.databasir.dao.tables.pojos.DocumentTemplatePropertyPojo; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.stream.Collectors; |
|||
|
|||
import static com.databasir.dao.enums.DocumentTemplatePropertyType.*; |
|||
|
|||
@Service |
|||
@RequiredArgsConstructor |
|||
@Slf4j |
|||
public class DocumentTemplateService { |
|||
|
|||
private final DocumentTemplatePropertyDao documentTemplatePropertyDao; |
|||
|
|||
private final DocumentTemplatePropertyResponseConverter documentTemplatePropertyResponseConverter; |
|||
|
|||
private final DocumentTemplatePropertiesUpdateRequestConverter documentTemplatePropertiesUpdateRequestConverter; |
|||
|
|||
public DocumentTemplatePropertiesResponse getAllProperties() { |
|||
List<DocumentTemplatePropertyPojo> properties = documentTemplatePropertyDao.selectAll(); |
|||
var propertiesGroupByType = documentTemplatePropertyResponseConverter.of(properties) |
|||
.stream() |
|||
.collect(Collectors.groupingBy(d -> d.getType())); |
|||
return DocumentTemplatePropertiesResponse.builder() |
|||
.columnFieldNameProperties(propertiesGroupByType.get(COLUMN_FIELD_NAME)) |
|||
.foreignKeyFieldNameProperties(propertiesGroupByType.get(FOREIGN_KEY_FIELD_NAME)) |
|||
.indexFieldNameProperties(propertiesGroupByType.get(INDEX_FIELD_NAME)) |
|||
.triggerFieldNameProperties(propertiesGroupByType.get(TRIGGER_FIELD_NAME)) |
|||
.build(); |
|||
} |
|||
|
|||
public void updateByType(DocumentTemplatePropertiesUpdateRequest request) { |
|||
List<DocumentTemplatePropertyPojo> pojoList = documentTemplatePropertiesUpdateRequestConverter.toPojo(request); |
|||
documentTemplatePropertyDao.batchInsertOnDuplicateKeyUpdate(pojoList); |
|||
} |
|||
} |
@ -0,0 +1,137 @@ |
|||
package com.databasir.core.infrastructure.event.subscriber; |
|||
|
|||
import com.databasir.common.codec.Aes; |
|||
import com.databasir.common.codec.Rsa; |
|||
import com.databasir.core.domain.document.data.TableDocumentResponse; |
|||
import com.databasir.dao.enums.DocumentTemplatePropertyType; |
|||
import com.databasir.dao.impl.DocumentTemplatePropertyDao; |
|||
import com.databasir.dao.impl.SysKeyDao; |
|||
import com.databasir.dao.impl.UserDao; |
|||
import com.databasir.dao.impl.UserRoleDao; |
|||
import com.databasir.dao.tables.pojos.DocumentTemplatePropertyPojo; |
|||
import com.databasir.dao.tables.pojos.SysKeyPojo; |
|||
import com.databasir.dao.tables.pojos.UserPojo; |
|||
import com.databasir.dao.tables.pojos.UserRolePojo; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.context.event.ContextRefreshedEvent; |
|||
import org.springframework.context.event.EventListener; |
|||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.lang.reflect.Field; |
|||
import java.util.ArrayList; |
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Optional; |
|||
import java.util.function.BiFunction; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Component |
|||
@Slf4j |
|||
@RequiredArgsConstructor |
|||
public class SystemStartedEventSubscriber { |
|||
|
|||
private final SysKeyDao sysKeyDao; |
|||
|
|||
private final UserDao userDao; |
|||
|
|||
private final UserRoleDao userRoleDao; |
|||
|
|||
private final DocumentTemplatePropertyDao documentTemplatePropertyDao; |
|||
|
|||
@SuppressWarnings("checkstyle:all") |
|||
private BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder(); |
|||
|
|||
@EventListener(classes = ContextRefreshedEvent.class) |
|||
public void onStarted(ContextRefreshedEvent event) { |
|||
log.info("begin to init system data"); |
|||
initSysOwnerIfNecessary(); |
|||
initDatabaseTypesIfNecessary(); |
|||
initTemplatePropertiesIfNecessary(); |
|||
log.info("system data init finished"); |
|||
} |
|||
|
|||
private void initTemplatePropertiesIfNecessary() { |
|||
List<String> ignoreFields = List.of("createAt", "discussionCount", "id"); |
|||
BiFunction<Field, DocumentTemplatePropertyType, DocumentTemplatePropertyPojo> mapping = (field, type) -> { |
|||
String key = field.getName(); |
|||
String def = field.getName(); |
|||
DocumentTemplatePropertyPojo pojo = new DocumentTemplatePropertyPojo(); |
|||
pojo.setType(type); |
|||
pojo.setKey(key); |
|||
pojo.setDefaultValue(def); |
|||
return pojo; |
|||
}; |
|||
// column field name;
|
|||
Field[] columnFields = TableDocumentResponse.ColumnDocumentResponse.class.getDeclaredFields(); |
|||
List<DocumentTemplatePropertyPojo> columnProperties = Arrays.stream(columnFields) |
|||
.filter(f -> !ignoreFields.contains(f.getName())) |
|||
.map(field -> mapping.apply(field, DocumentTemplatePropertyType.COLUMN_FIELD_NAME)) |
|||
.collect(Collectors.toList()); |
|||
|
|||
// index field name;
|
|||
Field[] indexFields = TableDocumentResponse.IndexDocumentResponse.class.getDeclaredFields(); |
|||
List<DocumentTemplatePropertyPojo> indexProperties = Arrays.stream(indexFields) |
|||
.filter(f -> !ignoreFields.contains(f.getName())) |
|||
.map(field -> mapping.apply(field, DocumentTemplatePropertyType.INDEX_FIELD_NAME)) |
|||
.collect(Collectors.toList()); |
|||
|
|||
// foreign key field name;
|
|||
Field[] fkFields = TableDocumentResponse.ForeignKeyDocumentResponse.class.getDeclaredFields(); |
|||
List<DocumentTemplatePropertyPojo> fkProperties = Arrays.stream(fkFields) |
|||
.filter(f -> !ignoreFields.contains(f.getName())) |
|||
.map(field -> mapping.apply(field, DocumentTemplatePropertyType.FOREIGN_KEY_FIELD_NAME)) |
|||
.collect(Collectors.toList()); |
|||
|
|||
// trigger field name;
|
|||
Field[] triggerFields = TableDocumentResponse.TriggerDocumentResponse.class.getDeclaredFields(); |
|||
List<DocumentTemplatePropertyPojo> triggerProperties = Arrays.stream(triggerFields) |
|||
.filter(f -> !ignoreFields.contains(f.getName())) |
|||
.map(field -> mapping.apply(field, DocumentTemplatePropertyType.TRIGGER_FIELD_NAME)) |
|||
.collect(Collectors.toList()); |
|||
|
|||
List<DocumentTemplatePropertyPojo> properties = new ArrayList<>(); |
|||
properties.addAll(columnProperties); |
|||
properties.addAll(indexProperties); |
|||
properties.addAll(fkProperties); |
|||
properties.addAll(triggerProperties); |
|||
documentTemplatePropertyDao.batchInsertOnDuplicateIgnore(properties); |
|||
|
|||
} |
|||
|
|||
private void initDatabaseTypesIfNecessary() { |
|||
// TODO
|
|||
} |
|||
|
|||
private void initSysOwnerIfNecessary() { |
|||
sysKeyDao.selectOptionTopOne() |
|||
.orElseGet(() -> { |
|||
SysKeyPojo pojo = new SysKeyPojo(); |
|||
pojo.setAesKey(Aes.randomBase64Key()); |
|||
Rsa.RsaBase64Key key = Rsa.generateBase64Key(); |
|||
pojo.setRsaPublicKey(key.getPublicBase64Key()); |
|||
pojo.setRsaPrivateKey(key.getPrivateBase64Key()); |
|||
sysKeyDao.insertAndReturnId(pojo); |
|||
return pojo; |
|||
}); |
|||
|
|||
String email = "N/A"; |
|||
String username = "databasir"; |
|||
Optional<UserPojo> userOpt = userDao.selectByEmailOrUsername(username); |
|||
if (!userOpt.isPresent()) { |
|||
UserPojo admin = new UserPojo(); |
|||
admin.setEmail(email); |
|||
admin.setUsername(username); |
|||
admin.setPassword(bCryptPasswordEncoder.encode(username)); |
|||
admin.setEnabled(true); |
|||
admin.setNickname("Databasir Admin"); |
|||
Integer userId = userDao.insertAndReturnId(admin); |
|||
UserRolePojo role = new UserRolePojo(); |
|||
role.setUserId(userId); |
|||
role.setRole("SYS_OWNER"); |
|||
userRoleDao.insertAndReturnId(role); |
|||
} |
|||
} |
|||
|
|||
} |
@ -0,0 +1,176 @@ |
|||
/* |
|||
* 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.converter.DocumentTemplatePropertyTypeConverter; |
|||
import com.databasir.dao.enums.DocumentTemplatePropertyType; |
|||
import com.databasir.dao.tables.records.DocumentTemplatePropertyRecord; |
|||
|
|||
import java.time.LocalDateTime; |
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
|
|||
import org.jooq.Field; |
|||
import org.jooq.ForeignKey; |
|||
import org.jooq.Identity; |
|||
import org.jooq.Name; |
|||
import org.jooq.Record; |
|||
import org.jooq.Row6; |
|||
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; |
|||
|
|||
|
|||
/** |
|||
* template property |
|||
*/ |
|||
@SuppressWarnings({ "all", "unchecked", "rawtypes" }) |
|||
public class DocumentTemplateProperty extends TableImpl<DocumentTemplatePropertyRecord> { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* The reference instance of |
|||
* <code>databasir.document_template_property</code> |
|||
*/ |
|||
public static final DocumentTemplateProperty DOCUMENT_TEMPLATE_PROPERTY = new DocumentTemplateProperty(); |
|||
|
|||
/** |
|||
* The class holding records for this type |
|||
*/ |
|||
@Override |
|||
public Class<DocumentTemplatePropertyRecord> getRecordType() { |
|||
return DocumentTemplatePropertyRecord.class; |
|||
} |
|||
|
|||
/** |
|||
* The column <code>databasir.document_template_property.id</code>. |
|||
*/ |
|||
public final TableField<DocumentTemplatePropertyRecord, Integer> ID = createField(DSL.name("id"), SQLDataType.INTEGER.nullable(false).identity(true), this, ""); |
|||
|
|||
/** |
|||
* The column <code>databasir.document_template_property.key</code>. |
|||
*/ |
|||
public final TableField<DocumentTemplatePropertyRecord, String> KEY = createField(DSL.name("key"), SQLDataType.VARCHAR(255).nullable(false), this, ""); |
|||
|
|||
/** |
|||
* The column <code>databasir.document_template_property.value</code>. |
|||
*/ |
|||
public final TableField<DocumentTemplatePropertyRecord, String> VALUE = createField(DSL.name("value"), SQLDataType.VARCHAR(255), this, ""); |
|||
|
|||
/** |
|||
* The column |
|||
* <code>databasir.document_template_property.default_value</code>. |
|||
*/ |
|||
public final TableField<DocumentTemplatePropertyRecord, String> DEFAULT_VALUE = createField(DSL.name("default_value"), SQLDataType.VARCHAR(255).nullable(false), this, ""); |
|||
|
|||
/** |
|||
* The column <code>databasir.document_template_property.type</code>. |
|||
*/ |
|||
public final TableField<DocumentTemplatePropertyRecord, DocumentTemplatePropertyType> TYPE = createField(DSL.name("type"), SQLDataType.VARCHAR(64).nullable(false), this, "", new DocumentTemplatePropertyTypeConverter()); |
|||
|
|||
/** |
|||
* The column <code>databasir.document_template_property.create_at</code>. |
|||
*/ |
|||
public final TableField<DocumentTemplatePropertyRecord, LocalDateTime> CREATE_AT = createField(DSL.name("create_at"), SQLDataType.LOCALDATETIME(0).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this, ""); |
|||
|
|||
private DocumentTemplateProperty(Name alias, Table<DocumentTemplatePropertyRecord> aliased) { |
|||
this(alias, aliased, null); |
|||
} |
|||
|
|||
private DocumentTemplateProperty(Name alias, Table<DocumentTemplatePropertyRecord> aliased, Field<?>[] parameters) { |
|||
super(alias, null, aliased, parameters, DSL.comment("template property"), TableOptions.table()); |
|||
} |
|||
|
|||
/** |
|||
* Create an aliased <code>databasir.document_template_property</code> table |
|||
* reference |
|||
*/ |
|||
public DocumentTemplateProperty(String alias) { |
|||
this(DSL.name(alias), DOCUMENT_TEMPLATE_PROPERTY); |
|||
} |
|||
|
|||
/** |
|||
* Create an aliased <code>databasir.document_template_property</code> table |
|||
* reference |
|||
*/ |
|||
public DocumentTemplateProperty(Name alias) { |
|||
this(alias, DOCUMENT_TEMPLATE_PROPERTY); |
|||
} |
|||
|
|||
/** |
|||
* Create a <code>databasir.document_template_property</code> table |
|||
* reference |
|||
*/ |
|||
public DocumentTemplateProperty() { |
|||
this(DSL.name("document_template_property"), null); |
|||
} |
|||
|
|||
public <O extends Record> DocumentTemplateProperty(Table<O> child, ForeignKey<O, DocumentTemplatePropertyRecord> key) { |
|||
super(child, key, DOCUMENT_TEMPLATE_PROPERTY); |
|||
} |
|||
|
|||
@Override |
|||
public Schema getSchema() { |
|||
return aliased() ? null : Databasir.DATABASIR; |
|||
} |
|||
|
|||
@Override |
|||
public Identity<DocumentTemplatePropertyRecord, Integer> getIdentity() { |
|||
return (Identity<DocumentTemplatePropertyRecord, Integer>) super.getIdentity(); |
|||
} |
|||
|
|||
@Override |
|||
public UniqueKey<DocumentTemplatePropertyRecord> getPrimaryKey() { |
|||
return Keys.KEY_DOCUMENT_TEMPLATE_PROPERTY_PRIMARY; |
|||
} |
|||
|
|||
@Override |
|||
public List<UniqueKey<DocumentTemplatePropertyRecord>> getUniqueKeys() { |
|||
return Arrays.asList(Keys.KEY_DOCUMENT_TEMPLATE_PROPERTY_UK_TYPE_KEY); |
|||
} |
|||
|
|||
@Override |
|||
public DocumentTemplateProperty as(String alias) { |
|||
return new DocumentTemplateProperty(DSL.name(alias), this); |
|||
} |
|||
|
|||
@Override |
|||
public DocumentTemplateProperty as(Name alias) { |
|||
return new DocumentTemplateProperty(alias, this); |
|||
} |
|||
|
|||
/** |
|||
* Rename this table |
|||
*/ |
|||
@Override |
|||
public DocumentTemplateProperty rename(String name) { |
|||
return new DocumentTemplateProperty(DSL.name(name), null); |
|||
} |
|||
|
|||
/** |
|||
* Rename this table |
|||
*/ |
|||
@Override |
|||
public DocumentTemplateProperty rename(Name name) { |
|||
return new DocumentTemplateProperty(name, null); |
|||
} |
|||
|
|||
// -------------------------------------------------------------------------
|
|||
// Row6 type methods
|
|||
// -------------------------------------------------------------------------
|
|||
|
|||
@Override |
|||
public Row6<Integer, String, String, String, DocumentTemplatePropertyType, LocalDateTime> fieldsRow() { |
|||
return (Row6) super.fieldsRow(); |
|||
} |
|||
} |
@ -0,0 +1,155 @@ |
|||
/* |
|||
* This file is generated by jOOQ. |
|||
*/ |
|||
package com.databasir.dao.tables.pojos; |
|||
|
|||
|
|||
import com.databasir.dao.enums.DocumentTemplatePropertyType; |
|||
|
|||
import java.io.Serializable; |
|||
import java.time.LocalDateTime; |
|||
|
|||
|
|||
/** |
|||
* template property |
|||
*/ |
|||
@SuppressWarnings({ "all", "unchecked", "rawtypes" }) |
|||
public class DocumentTemplatePropertyPojo implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
private Integer id; |
|||
private String key; |
|||
private String value; |
|||
private String defaultValue; |
|||
private DocumentTemplatePropertyType type; |
|||
private LocalDateTime createAt; |
|||
|
|||
public DocumentTemplatePropertyPojo() {} |
|||
|
|||
public DocumentTemplatePropertyPojo(DocumentTemplatePropertyPojo value) { |
|||
this.id = value.id; |
|||
this.key = value.key; |
|||
this.value = value.value; |
|||
this.defaultValue = value.defaultValue; |
|||
this.type = value.type; |
|||
this.createAt = value.createAt; |
|||
} |
|||
|
|||
public DocumentTemplatePropertyPojo( |
|||
Integer id, |
|||
String key, |
|||
String value, |
|||
String defaultValue, |
|||
DocumentTemplatePropertyType type, |
|||
LocalDateTime createAt |
|||
) { |
|||
this.id = id; |
|||
this.key = key; |
|||
this.value = value; |
|||
this.defaultValue = defaultValue; |
|||
this.type = type; |
|||
this.createAt = createAt; |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.document_template_property.id</code>. |
|||
*/ |
|||
public Integer getId() { |
|||
return this.id; |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.document_template_property.id</code>. |
|||
*/ |
|||
public void setId(Integer id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.document_template_property.key</code>. |
|||
*/ |
|||
public String getKey() { |
|||
return this.key; |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.document_template_property.key</code>. |
|||
*/ |
|||
public void setKey(String key) { |
|||
this.key = key; |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.document_template_property.value</code>. |
|||
*/ |
|||
public String getValue() { |
|||
return this.value; |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.document_template_property.value</code>. |
|||
*/ |
|||
public void setValue(String value) { |
|||
this.value = value; |
|||
} |
|||
|
|||
/** |
|||
* Getter for |
|||
* <code>databasir.document_template_property.default_value</code>. |
|||
*/ |
|||
public String getDefaultValue() { |
|||
return this.defaultValue; |
|||
} |
|||
|
|||
/** |
|||
* Setter for |
|||
* <code>databasir.document_template_property.default_value</code>. |
|||
*/ |
|||
public void setDefaultValue(String defaultValue) { |
|||
this.defaultValue = defaultValue; |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.document_template_property.type</code>. |
|||
*/ |
|||
public DocumentTemplatePropertyType getType() { |
|||
return this.type; |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.document_template_property.type</code>. |
|||
*/ |
|||
public void setType(DocumentTemplatePropertyType type) { |
|||
this.type = type; |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.document_template_property.create_at</code>. |
|||
*/ |
|||
public LocalDateTime getCreateAt() { |
|||
return this.createAt; |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.document_template_property.create_at</code>. |
|||
*/ |
|||
public void setCreateAt(LocalDateTime createAt) { |
|||
this.createAt = createAt; |
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
StringBuilder sb = new StringBuilder("DocumentTemplatePropertyPojo ("); |
|||
|
|||
sb.append(id); |
|||
sb.append(", ").append(key); |
|||
sb.append(", ").append(value); |
|||
sb.append(", ").append(defaultValue); |
|||
sb.append(", ").append(type); |
|||
sb.append(", ").append(createAt); |
|||
|
|||
sb.append(")"); |
|||
return sb.toString(); |
|||
} |
|||
} |
@ -0,0 +1,314 @@ |
|||
/* |
|||
* This file is generated by jOOQ. |
|||
*/ |
|||
package com.databasir.dao.tables.records; |
|||
|
|||
|
|||
import com.databasir.dao.enums.DocumentTemplatePropertyType; |
|||
import com.databasir.dao.tables.DocumentTemplateProperty; |
|||
import com.databasir.dao.tables.pojos.DocumentTemplatePropertyPojo; |
|||
|
|||
import java.time.LocalDateTime; |
|||
|
|||
import org.jooq.Field; |
|||
import org.jooq.Record1; |
|||
import org.jooq.Record6; |
|||
import org.jooq.Row6; |
|||
import org.jooq.impl.UpdatableRecordImpl; |
|||
|
|||
|
|||
/** |
|||
* template property |
|||
*/ |
|||
@SuppressWarnings({ "all", "unchecked", "rawtypes" }) |
|||
public class DocumentTemplatePropertyRecord extends UpdatableRecordImpl<DocumentTemplatePropertyRecord> implements Record6<Integer, String, String, String, DocumentTemplatePropertyType, LocalDateTime> { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* Setter for <code>databasir.document_template_property.id</code>. |
|||
*/ |
|||
public void setId(Integer value) { |
|||
set(0, value); |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.document_template_property.id</code>. |
|||
*/ |
|||
public Integer getId() { |
|||
return (Integer) get(0); |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.document_template_property.key</code>. |
|||
*/ |
|||
public void setKey(String value) { |
|||
set(1, value); |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.document_template_property.key</code>. |
|||
*/ |
|||
public String getKey() { |
|||
return (String) get(1); |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.document_template_property.value</code>. |
|||
*/ |
|||
public void setValue(String value) { |
|||
set(2, value); |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.document_template_property.value</code>. |
|||
*/ |
|||
public String getValue() { |
|||
return (String) get(2); |
|||
} |
|||
|
|||
/** |
|||
* Setter for |
|||
* <code>databasir.document_template_property.default_value</code>. |
|||
*/ |
|||
public void setDefaultValue(String value) { |
|||
set(3, value); |
|||
} |
|||
|
|||
/** |
|||
* Getter for |
|||
* <code>databasir.document_template_property.default_value</code>. |
|||
*/ |
|||
public String getDefaultValue() { |
|||
return (String) get(3); |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.document_template_property.type</code>. |
|||
*/ |
|||
public void setType(DocumentTemplatePropertyType value) { |
|||
set(4, value); |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.document_template_property.type</code>. |
|||
*/ |
|||
public DocumentTemplatePropertyType getType() { |
|||
return (DocumentTemplatePropertyType) get(4); |
|||
} |
|||
|
|||
/** |
|||
* Setter for <code>databasir.document_template_property.create_at</code>. |
|||
*/ |
|||
public void setCreateAt(LocalDateTime value) { |
|||
set(5, value); |
|||
} |
|||
|
|||
/** |
|||
* Getter for <code>databasir.document_template_property.create_at</code>. |
|||
*/ |
|||
public LocalDateTime getCreateAt() { |
|||
return (LocalDateTime) get(5); |
|||
} |
|||
|
|||
// -------------------------------------------------------------------------
|
|||
// Primary key information
|
|||
// -------------------------------------------------------------------------
|
|||
|
|||
@Override |
|||
public Record1<Integer> key() { |
|||
return (Record1) super.key(); |
|||
} |
|||
|
|||
// -------------------------------------------------------------------------
|
|||
// Record6 type implementation
|
|||
// -------------------------------------------------------------------------
|
|||
|
|||
@Override |
|||
public Row6<Integer, String, String, String, DocumentTemplatePropertyType, LocalDateTime> fieldsRow() { |
|||
return (Row6) super.fieldsRow(); |
|||
} |
|||
|
|||
@Override |
|||
public Row6<Integer, String, String, String, DocumentTemplatePropertyType, LocalDateTime> valuesRow() { |
|||
return (Row6) super.valuesRow(); |
|||
} |
|||
|
|||
@Override |
|||
public Field<Integer> field1() { |
|||
return DocumentTemplateProperty.DOCUMENT_TEMPLATE_PROPERTY.ID; |
|||
} |
|||
|
|||
@Override |
|||
public Field<String> field2() { |
|||
return DocumentTemplateProperty.DOCUMENT_TEMPLATE_PROPERTY.KEY; |
|||
} |
|||
|
|||
@Override |
|||
public Field<String> field3() { |
|||
return DocumentTemplateProperty.DOCUMENT_TEMPLATE_PROPERTY.VALUE; |
|||
} |
|||
|
|||
@Override |
|||
public Field<String> field4() { |
|||
return DocumentTemplateProperty.DOCUMENT_TEMPLATE_PROPERTY.DEFAULT_VALUE; |
|||
} |
|||
|
|||
@Override |
|||
public Field<DocumentTemplatePropertyType> field5() { |
|||
return DocumentTemplateProperty.DOCUMENT_TEMPLATE_PROPERTY.TYPE; |
|||
} |
|||
|
|||
@Override |
|||
public Field<LocalDateTime> field6() { |
|||
return DocumentTemplateProperty.DOCUMENT_TEMPLATE_PROPERTY.CREATE_AT; |
|||
} |
|||
|
|||
@Override |
|||
public Integer component1() { |
|||
return getId(); |
|||
} |
|||
|
|||
@Override |
|||
public String component2() { |
|||
return getKey(); |
|||
} |
|||
|
|||
@Override |
|||
public String component3() { |
|||
return getValue(); |
|||
} |
|||
|
|||
@Override |
|||
public String component4() { |
|||
return getDefaultValue(); |
|||
} |
|||
|
|||
@Override |
|||
public DocumentTemplatePropertyType component5() { |
|||
return getType(); |
|||
} |
|||
|
|||
@Override |
|||
public LocalDateTime component6() { |
|||
return getCreateAt(); |
|||
} |
|||
|
|||
@Override |
|||
public Integer value1() { |
|||
return getId(); |
|||
} |
|||
|
|||
@Override |
|||
public String value2() { |
|||
return getKey(); |
|||
} |
|||
|
|||
@Override |
|||
public String value3() { |
|||
return getValue(); |
|||
} |
|||
|
|||
@Override |
|||
public String value4() { |
|||
return getDefaultValue(); |
|||
} |
|||
|
|||
@Override |
|||
public DocumentTemplatePropertyType value5() { |
|||
return getType(); |
|||
} |
|||
|
|||
@Override |
|||
public LocalDateTime value6() { |
|||
return getCreateAt(); |
|||
} |
|||
|
|||
@Override |
|||
public DocumentTemplatePropertyRecord value1(Integer value) { |
|||
setId(value); |
|||
return this; |
|||
} |
|||
|
|||
@Override |
|||
public DocumentTemplatePropertyRecord value2(String value) { |
|||
setKey(value); |
|||
return this; |
|||
} |
|||
|
|||
@Override |
|||
public DocumentTemplatePropertyRecord value3(String value) { |
|||
setValue(value); |
|||
return this; |
|||
} |
|||
|
|||
@Override |
|||
public DocumentTemplatePropertyRecord value4(String value) { |
|||
setDefaultValue(value); |
|||
return this; |
|||
} |
|||
|
|||
@Override |
|||
public DocumentTemplatePropertyRecord value5(DocumentTemplatePropertyType value) { |
|||
setType(value); |
|||
return this; |
|||
} |
|||
|
|||
@Override |
|||
public DocumentTemplatePropertyRecord value6(LocalDateTime value) { |
|||
setCreateAt(value); |
|||
return this; |
|||
} |
|||
|
|||
@Override |
|||
public DocumentTemplatePropertyRecord values(Integer value1, String value2, String value3, String value4, DocumentTemplatePropertyType value5, LocalDateTime value6) { |
|||
value1(value1); |
|||
value2(value2); |
|||
value3(value3); |
|||
value4(value4); |
|||
value5(value5); |
|||
value6(value6); |
|||
return this; |
|||
} |
|||
|
|||
// -------------------------------------------------------------------------
|
|||
// Constructors
|
|||
// -------------------------------------------------------------------------
|
|||
|
|||
/** |
|||
* Create a detached DocumentTemplatePropertyRecord |
|||
*/ |
|||
public DocumentTemplatePropertyRecord() { |
|||
super(DocumentTemplateProperty.DOCUMENT_TEMPLATE_PROPERTY); |
|||
} |
|||
|
|||
/** |
|||
* Create a detached, initialised DocumentTemplatePropertyRecord |
|||
*/ |
|||
public DocumentTemplatePropertyRecord(Integer id, String key, String value, String defaultValue, DocumentTemplatePropertyType type, LocalDateTime createAt) { |
|||
super(DocumentTemplateProperty.DOCUMENT_TEMPLATE_PROPERTY); |
|||
|
|||
setId(id); |
|||
setKey(key); |
|||
setValue(value); |
|||
setDefaultValue(defaultValue); |
|||
setType(type); |
|||
setCreateAt(createAt); |
|||
} |
|||
|
|||
/** |
|||
* Create a detached, initialised DocumentTemplatePropertyRecord |
|||
*/ |
|||
public DocumentTemplatePropertyRecord(DocumentTemplatePropertyPojo value) { |
|||
super(DocumentTemplateProperty.DOCUMENT_TEMPLATE_PROPERTY); |
|||
|
|||
if (value != null) { |
|||
setId(value.getId()); |
|||
setKey(value.getKey()); |
|||
setValue(value.getValue()); |
|||
setDefaultValue(value.getDefaultValue()); |
|||
setType(value.getType()); |
|||
setCreateAt(value.getCreateAt()); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,12 @@ |
|||
package com.databasir.dao.converter; |
|||
|
|||
import com.databasir.dao.enums.DocumentTemplatePropertyType; |
|||
import org.jooq.impl.EnumConverter; |
|||
|
|||
public class DocumentTemplatePropertyTypeConverter extends EnumConverter<String, DocumentTemplatePropertyType> { |
|||
|
|||
public DocumentTemplatePropertyTypeConverter() { |
|||
super(String.class, DocumentTemplatePropertyType.class); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,7 @@ |
|||
package com.databasir.dao.enums; |
|||
|
|||
public enum DocumentTemplatePropertyType { |
|||
|
|||
INDEX_FIELD_NAME, COLUMN_FIELD_NAME, TRIGGER_FIELD_NAME, FOREIGN_KEY_FIELD_NAME; |
|||
|
|||
} |
@ -0,0 +1,56 @@ |
|||
package com.databasir.dao.impl; |
|||
|
|||
import com.databasir.dao.tables.pojos.DocumentTemplatePropertyPojo; |
|||
import com.databasir.dao.tables.records.DocumentTemplatePropertyRecord; |
|||
import lombok.Getter; |
|||
import org.jooq.DSLContext; |
|||
import org.jooq.InsertReturningStep; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
import java.util.Collection; |
|||
import java.util.List; |
|||
import java.util.stream.Collectors; |
|||
|
|||
import static com.databasir.dao.Tables.DOCUMENT_TEMPLATE_PROPERTY; |
|||
|
|||
@Repository |
|||
public class DocumentTemplatePropertyDao extends BaseDao<DocumentTemplatePropertyPojo> { |
|||
|
|||
@Autowired |
|||
@Getter |
|||
private DSLContext dslContext; |
|||
|
|||
public DocumentTemplatePropertyDao() { |
|||
super(DOCUMENT_TEMPLATE_PROPERTY, DocumentTemplatePropertyPojo.class); |
|||
} |
|||
|
|||
public void batchInsertOnDuplicateIgnore(Collection<DocumentTemplatePropertyPojo> data) { |
|||
if (data == null || data.isEmpty()) { |
|||
return; |
|||
} |
|||
List<InsertReturningStep<DocumentTemplatePropertyRecord>> query = data.stream() |
|||
.map(pojo -> |
|||
|
|||
getDslContext() |
|||
.insertInto(DOCUMENT_TEMPLATE_PROPERTY) |
|||
.set(getDslContext().newRecord(DOCUMENT_TEMPLATE_PROPERTY, pojo)) |
|||
.onDuplicateKeyIgnore()) |
|||
.collect(Collectors.toList()); |
|||
getDslContext().batch(query).execute(); |
|||
} |
|||
|
|||
public void batchInsertOnDuplicateKeyUpdate(Collection<DocumentTemplatePropertyPojo> data) { |
|||
if (data == null || data.isEmpty()) { |
|||
return; |
|||
} |
|||
List<InsertReturningStep<DocumentTemplatePropertyRecord>> query = data.stream() |
|||
.map(pojo -> getDslContext() |
|||
.insertInto(DOCUMENT_TEMPLATE_PROPERTY) |
|||
.set(getDslContext().newRecord(DOCUMENT_TEMPLATE_PROPERTY, pojo)) |
|||
.onDuplicateKeyUpdate() |
|||
.set(DOCUMENT_TEMPLATE_PROPERTY.VALUE, pojo.getValue())) |
|||
.collect(Collectors.toList()); |
|||
getDslContext().batch(query).execute(); |
|||
} |
|||
} |
Loading…
Reference in new issue