更新模板

This commit is contained in:
xiangheng
2023-12-11 18:20:36 +08:00
parent 2474fe0cf9
commit 0abfbce730
9 changed files with 42 additions and 6 deletions

View File

@@ -20,7 +20,7 @@ module.exports = {
printWidth: 100,
proseWrap: 'preserve',
bracketSameLine: false,
endOfLine: 'lf',
endOfLine: 'auto',
tabWidth: 4,
useTabs: false,
trailingComma: 'none'

View File

@@ -4,7 +4,7 @@
"printWidth": 100,
"proseWrap": "preserve",
"bracketSameLine": false,
"endOfLine": "lf",
"endOfLine": "auto",
"tabWidth": 4,
"useTabs": false,
"trailingComma": "none"

View File

@@ -92,7 +92,7 @@ func loadConfig(envPath string) envConfig {
Secret: "UVTIyzCy",
// Redis键前缀
RedisPrefix: "Like:",
RedisPrefix: "x:",
// 上传图片限制
UploadImageSize: 1024 * 1024 * 10,
// 上传视频限制

View File

@@ -39,6 +39,16 @@ func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) List(c *gin.Context) {
response.CheckAndRespWithData(c, res, err)
}
// @Summary {{{ .FunctionName }}}列表-所有
// @Tags {{{ .ModuleName }}}-{{{ .FunctionName }}}
// @Produce json
// @Success 200 {object} []{{{ title (toCamelCase .EntityName) }}}Resp "成功"
// @Router /api/{{{ .ModuleName }}}/list [get]
func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) ListAll(c *gin.Context) {
res, err := hd.Service.List(page, listReq)
response.CheckAndRespWithData(c, res, err)
}
// @Summary {{{ .FunctionName }}}详情
// @Tags {{{ .ModuleName }}}-{{{ .FunctionName }}}
// @Produce json

View File

@@ -4,7 +4,11 @@ package model
type {{{ title (toCamelCase .EntityName) }}} struct {
{{{- range .Columns }}}
{{{- if not (contains $.SubTableFields .ColumnName) }}}
{{{ title (toCamelCase .GoField) }}} {{{ if eq .GoType "core.TsTime" }}} int64 {{{ else }}} {{{ .GoType }}} {{{ end }}} `gorm:"{{{ if .IsPk }}}primarykey;{{{ end }}}comment:'{{{ .ColumnComment }}}'"` // {{{ .ColumnComment }}}
{{{ if eq .GoType "core.TsTime" }}}
{{{ title (toCamelCase .GoField) }}} int64 `gorm:"{{{ if eq .GoField "create_time" }}}autoCreateTime;{{{ else }}}{{{if eq .GoField "update_time"}}}autoUpdateTime;{{{ end }}}{{{ end }}}comment:'{{{ .ColumnComment }}}'"` // {{{ .ColumnComment }}}
{{{ else }}}
{{{ title (toCamelCase .GoField) }}} {{{ .GoType }}} `gorm:"{{{ if .IsPk }}}primarykey;{{{ end }}}comment:'{{{ .ColumnComment }}}'"` // {{{ .ColumnComment }}}
{{{- end }}}
{{{- end }}}
{{{- end }}}
}

View File

@@ -21,6 +21,7 @@ import (
{{{.ModuleName }}}:edit
{{{.ModuleName }}}:del
{{{.ModuleName }}}:list
{{{.ModuleName }}}:listAll
{{{.ModuleName }}}:detail
*/
@@ -35,6 +36,7 @@ func {{{ title (toCamelCase .ModuleName) }}}Route(rg *gin.RouterGroup) {
rg = rg.Group("/", middleware.TokenAuth())
rg.GET("/{{{ .ModuleName }}}/list", handle.List)
rg.GET("/{{{ .ModuleName }}}/listAll", handle.ListAll)
rg.GET("/{{{ .ModuleName }}}/detail", handle.Detail)
rg.POST("/{{{ .ModuleName }}}/add", handle.Add)
rg.POST("/{{{ .ModuleName }}}/edit", handle.Edit)

View File

@@ -9,6 +9,8 @@ import (
type I{{{ title (toCamelCase .EntityName) }}}Service interface {
List(page request.PageReq, listReq {{{ title (toCamelCase .EntityName) }}}ListReq) (res response.PageResp, e error)
ListAll() (res []{{{ title (toCamelCase .EntityName) }}}Resp, e error)
Detail(id int) (res {{{ title (toCamelCase .EntityName) }}}Resp, e error)
Add(addReq {{{ title (toCamelCase .EntityName) }}}AddReq) (e error)
Edit(editReq {{{ title (toCamelCase .EntityName) }}}EditReq) (e error)
@@ -70,6 +72,17 @@ func (Service {{{ toCamelCase .EntityName }}}Service) List(page request.PageReq,
Lists: resps,
}, nil
}
//ListAll {{{ .FunctionName }}}列表
func (Service {{{ toCamelCase .EntityName }}}Service) ListAll() (res []{{{ title (toCamelCase .EntityName) }}}Resp, e error) {
var objs model.{{{ title (toCamelCase .EntityName) }}}
err := Service.db.Find(&objs).Error
if e = response.CheckErr(err, "ListAll Find err"); e != nil {
return
}
response.Copy(&res, objs)
return res, nil
}
//Detail {{{ .FunctionName }}}详情
func (Service {{{ toCamelCase .EntityName }}}Service) Detail(id int) (res {{{ title (toCamelCase .EntityName) }}}Resp, e error) {

View File

@@ -1,9 +1,13 @@
import request from '@/utils/request'
// {{{.FunctionName}}}列表
export function {{{.ModuleName}}}_lists(params?: Record<string, any>) {
export function {{{.ModuleName}}}_list(params?: Record<string, any>) {
return request.get({ url: '/{{{.ModuleName}}}/list', params })
}
// {{{.FunctionName}}}列表-所有
export function {{{.ModuleName}}}_list_all(params?: Record<string, any>) {
return request.get({ url: '/{{{.ModuleName}}}/listAll', params })
}
// {{{.FunctionName}}}详情
export function {{{.ModuleName}}}_detail(params: Record<string, any>) {

View File

@@ -121,7 +121,7 @@
/>
</div>
</template>
<script lang="ts" setup name="{{{ .ModuleName }}}">
<script lang="ts" setup>
import { {{{ .ModuleName }}}_delete, {{{ .ModuleName }}}_lists } from '@/api/{{{ .ModuleName }}}'
{{{- if ge (len .DictFields) 1 }}}
import { useDictData } from '@/hooks/useDictOptions'
@@ -129,6 +129,9 @@ import { useDictData } from '@/hooks/useDictOptions'
import { usePaging } from '@/hooks/usePaging'
import feedback from '@/utils/feedback'
import EditPopup from './edit.vue'
defineOptions({
name:"{{{ .ModuleName }}}"
})
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
const showEdit = ref(false)
const queryParams = reactive({