mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-12-24 08:12:55 +08:00
更新模板
This commit is contained in:
@@ -20,7 +20,7 @@ module.exports = {
|
||||
printWidth: 100,
|
||||
proseWrap: 'preserve',
|
||||
bracketSameLine: false,
|
||||
endOfLine: 'lf',
|
||||
endOfLine: 'auto',
|
||||
tabWidth: 4,
|
||||
useTabs: false,
|
||||
trailingComma: 'none'
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"printWidth": 100,
|
||||
"proseWrap": "preserve",
|
||||
"bracketSameLine": false,
|
||||
"endOfLine": "lf",
|
||||
"endOfLine": "auto",
|
||||
"tabWidth": 4,
|
||||
"useTabs": false,
|
||||
"trailingComma": "none"
|
||||
|
||||
@@ -92,7 +92,7 @@ func loadConfig(envPath string) envConfig {
|
||||
Secret: "UVTIyzCy",
|
||||
|
||||
// Redis键前缀
|
||||
RedisPrefix: "Like:",
|
||||
RedisPrefix: "x:",
|
||||
// 上传图片限制
|
||||
UploadImageSize: 1024 * 1024 * 10,
|
||||
// 上传视频限制
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 }}}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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>) {
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user