统一时间

This commit is contained in:
xiangheng
2024-05-13 20:31:24 +08:00
parent c1444ce554
commit f52d5d662b
40 changed files with 1998 additions and 944 deletions

View File

@@ -113,7 +113,7 @@ import {
monitor_web_export_file monitor_web_export_file
} from '@/api/monitor_web' } from '@/api/monitor_web'
import { monitor_project_list_all } from '@/api/monitor_project' import { monitor_project_list_all } from '@/api/monitor_project'
import { useDictData, useDictOptions } from '@/hooks/useDictOptions' import { useDictOptions } from '@/hooks/useDictOptions'
import { usePaging } from '@/hooks/usePaging' import { usePaging } from '@/hooks/usePaging'
import feedback from '@/utils/feedback' import feedback from '@/utils/feedback'
import EditPopup from './edit.vue' import EditPopup from './edit.vue'

View File

@@ -30,3 +30,4 @@
### Go应该注意的问题 ### Go应该注意的问题
1. 循环依赖 1. 循环依赖
2. 零值更新避免数据库默认值为0 2. 零值更新避免数据库默认值为0
3. 软删除本系统需要IsDelete和DeleteTime字段https://gorm.io/zh_CN/docs/delete.html#%E6%B7%B7%E5%90%88%E6%A8%A1%E5%BC%8F

View File

@@ -2,7 +2,6 @@ package album
import ( import (
"path" "path"
"time"
"x_admin/config" "x_admin/config"
"x_admin/core" "x_admin/core"
"x_admin/core/request" "x_admin/core/request"
@@ -154,7 +153,7 @@ func (albSrv albumService) AlbumDel(ids []uint) (e error) {
return response.AssertArgumentError.Make("文件丢失!") return response.AssertArgumentError.Make("文件丢失!")
} }
err = albSrv.db.Model(&common_model.Album{}).Where("id in ?", ids).Updates( err = albSrv.db.Model(&common_model.Album{}).Where("id in ?", ids).Updates(
common_model.Album{IsDelete: 1, DeleteTime: time.Now().Unix()}).Error common_model.Album{IsDelete: 1, DeleteTime: core.NowTime()}).Error
e = response.CheckErr(err, "AlbumDel UpdateColumn err") e = response.CheckErr(err, "AlbumDel UpdateColumn err")
return return
} }
@@ -222,7 +221,7 @@ func (albSrv albumService) CateDel(id uint) (e error) {
return response.AssertArgumentError.Make("当前分类正被使用中,不能删除!") return response.AssertArgumentError.Make("当前分类正被使用中,不能删除!")
} }
cate.IsDelete = 1 cate.IsDelete = 1
cate.DeleteTime = time.Now().Unix() cate.DeleteTime = core.NowTime()
err = albSrv.db.Save(&cate).Error err = albSrv.db.Save(&cate).Error
e = response.CheckErr(err, "CateDel Save err") e = response.CheckErr(err, "CateDel Save err")
return return

View File

@@ -159,6 +159,7 @@ func (Service flowApplyService) Del(id int) (e error) {
} }
// 删除 // 删除
obj.IsDelete = 1 obj.IsDelete = 1
obj.DeleteTime = core.NowTime()
err = Service.db.Save(&obj).Error err = Service.db.Save(&obj).Error
e = response.CheckErr(err, "Del Save err") e = response.CheckErr(err, "Del Save err")
return return

View File

@@ -102,10 +102,10 @@ type DownloadReq struct {
// DbTableResp 数据表返回信息 // DbTableResp 数据表返回信息
type DbTableResp struct { type DbTableResp struct {
TableName string `json:"tableName" structs:"tableName"` // 表的名称 TableName string `json:"tableName" structs:"tableName"` // 表的名称
TableComment string `json:"tableComment" structs:"tableComment"` // 表的描述 TableComment string `json:"tableComment" structs:"tableComment"` // 表的描述
CreateTime core.OnlyRespTsTime `json:"createTime" structs:"createTime"` // 创建时间 CreateTime core.TsTime `json:"createTime" structs:"createTime"` // 创建时间
UpdateTime core.OnlyRespTsTime `json:"updateTime" structs:"updateTime"` // 更新时间 UpdateTime core.TsTime `json:"updateTime" structs:"updateTime"` // 更新时间
} }
// GenTableResp 生成表返回信息 // GenTableResp 生成表返回信息

View File

@@ -82,10 +82,10 @@ func (genSrv generateService) List(page request.PageReq, listReq ListTableReq) (
genModel = genModel.Where("table_comment like ?", "%"+listReq.TableComment+"%") genModel = genModel.Where("table_comment like ?", "%"+listReq.TableComment+"%")
} }
if !listReq.StartTime.IsZero() { if !listReq.StartTime.IsZero() {
genModel = genModel.Where("create_time >= ?", listReq.StartTime.Unix()) genModel = genModel.Where("create_time >= ?", listReq.StartTime)
} }
if !listReq.EndTime.IsZero() { if !listReq.EndTime.IsZero() {
genModel = genModel.Where("create_time <= ?", listReq.EndTime.Unix()) genModel = genModel.Where("create_time <= ?", listReq.EndTime)
} }
// 总数 // 总数
var count int64 var count int64

View File

@@ -1,14 +1,23 @@
package model package model
import (
"x_admin/core"
"gorm.io/plugin/soft_delete"
)
//{{{ title (toCamelCase .EntityName) }}} {{{ .FunctionName }}}实体 //{{{ title (toCamelCase .EntityName) }}} {{{ .FunctionName }}}实体
type {{{ title (toCamelCase .EntityName) }}} struct { type {{{ title (toCamelCase .EntityName) }}} struct {
{{{- range .Columns }}} {{{- range .Columns }}}
{{{- if not (contains $.SubTableFields .ColumnName) }}} {{{- if not (contains $.SubTableFields .ColumnName) }}}
{{{ if eq .GoType "core.TsTime" }}} {{{ if eq .GoField "is_delete" }}}
{{{ title (toCamelCase .GoField) }}} int64 `gorm:"{{{ if eq .GoField "create_time" }}}autoCreateTime;{{{ else }}}{{{if eq .GoField "update_time"}}}autoUpdateTime;{{{ end }}}{{{ end }}}comment:'{{{ .ColumnComment }}}'" excel:"name:{{{ .ColumnComment }}};"` // {{{ .ColumnComment }}} IsDelete soft_delete.DeletedAt `gorm:"not null;default:0;softDelete:flag,DeletedAtField:DeleteTime;comment:'是否删除: 0=否, 1=是'"`
{{{ else }}} {{{ else }}}
{{{ title (toCamelCase .GoField) }}} {{{ .GoType }}} `gorm:"{{{ if .IsPk }}}primarykey;{{{ end }}}comment:'{{{ .ColumnComment }}}'" excel:"name:{{{ .ColumnComment }}};"` // {{{ .ColumnComment }}} {{{ if eq .GoType "core.TsTime" }}}
{{{- end }}} {{{ title (toCamelCase .GoField) }}} core.TsTime `gorm:"{{{ if eq .GoField "create_time" }}}autoCreateTime;{{{ else }}}{{{if eq .GoField "update_time"}}}autoUpdateTime;{{{ end }}}{{{ end }}}comment:'{{{ .ColumnComment }}}'" excel:"name:{{{ .ColumnComment }}};"` // {{{ .ColumnComment }}}
{{{ else }}}
{{{ title (toCamelCase .GoField) }}} {{{ .GoType }}} `gorm:"{{{ if .IsPk }}}primarykey;{{{ end }}}comment:'{{{ .ColumnComment }}}'" excel:"name:{{{ .ColumnComment }}};"` // {{{ .ColumnComment }}}
{{{- end }}}
{{{- end }}}
{{{- end }}} {{{- end }}}
{{{- end }}} {{{- end }}}
} }

View File

@@ -26,16 +26,16 @@ admin:{{{.ModuleName }}}:ExportFile
admin:{{{.ModuleName }}}:ImportFile admin:{{{.ModuleName }}}:ImportFile
// 列表 // 列表
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, paths, component, is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'C', '{{{ .FunctionName }}}', '/{{{ .ModuleName }}}/index', '{{{ .ModuleName }}}/index', 0, 1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()); INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, paths, component, is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'C', '{{{ .FunctionName }}}', '/{{{ .ModuleName }}}/index', '{{{ .ModuleName }}}/index', 0, 1, 0, now(), now());
按钮 按钮
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '{{{ .FunctionName }}}添加','admin:{{{ .ModuleName }}}:add', 0, 1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()); INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '{{{ .FunctionName }}}添加','admin:{{{ .ModuleName }}}:add', 0, 1, 0, now(), now());
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '{{{ .FunctionName }}}编辑','admin:{{{ .ModuleName }}}:edit', 0, 1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()); INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '{{{ .FunctionName }}}编辑','admin:{{{ .ModuleName }}}:edit', 0, 1, 0, now(), now());
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '{{{ .FunctionName }}}删除','admin:{{{ .ModuleName }}}:del', 0, 1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()); INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '{{{ .FunctionName }}}删除','admin:{{{ .ModuleName }}}:del', 0, 1, 0, now(), now());
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '{{{ .FunctionName }}}列表','admin:{{{ .ModuleName }}}:list', 0, 1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()); INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '{{{ .FunctionName }}}列表','admin:{{{ .ModuleName }}}:list', 0, 1, 0, now(), now());
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '{{{ .FunctionName }}}全部列表','admin:{{{ .ModuleName }}}:listAll', 0, 1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()); INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '{{{ .FunctionName }}}全部列表','admin:{{{ .ModuleName }}}:listAll', 0, 1, 0, now(), now());
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '{{{ .FunctionName }}}详情','admin:{{{ .ModuleName }}}:detail', 0, 1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()); INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '{{{ .FunctionName }}}详情','admin:{{{ .ModuleName }}}:detail', 0, 1, 0, now(), now());
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '{{{ .FunctionName }}}导出excel','admin:{{{ .ModuleName }}}:ExportFile', 0, 1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()); INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '{{{ .FunctionName }}}导出excel','admin:{{{ .ModuleName }}}:ExportFile', 0, 1, 0, now(), now());
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '{{{ .FunctionName }}}导入excel','admin:{{{ .ModuleName }}}:ImportFile', 0, 1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()); INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '{{{ .FunctionName }}}导入excel','admin:{{{ .ModuleName }}}:ImportFile', 0, 1, 0, now(), now());
*/ */

View File

@@ -29,10 +29,10 @@ func (service {{{ toCamelCase .EntityName }}}Service) GetModel(listReq {{{ title
{{{- $queryOpr := index $.ModelOprMap .QueryType }}} {{{- $queryOpr := index $.ModelOprMap .QueryType }}}
{{{- if eq .HtmlType "datetime" }}} {{{- if eq .HtmlType "datetime" }}}
if listReq.{{{ title (toCamelCase .ColumnName) }}}Start != "" { if listReq.{{{ title (toCamelCase .ColumnName) }}}Start != "" {
dbModel = dbModel.Where("{{{ .ColumnName }}} >= UNIX_TIMESTAMP(?)", listReq.{{{ title (toCamelCase .ColumnName) }}}Start) dbModel = dbModel.Where("{{{ .ColumnName }}} >= ?", listReq.{{{ title (toCamelCase .ColumnName) }}}Start)
} }
if listReq.{{{ title (toCamelCase .ColumnName) }}}End != "" { if listReq.{{{ title (toCamelCase .ColumnName) }}}End != "" {
dbModel = dbModel.Where("{{{ .ColumnName }}} <= UNIX_TIMESTAMP(?)", listReq.{{{ title (toCamelCase .ColumnName) }}}End) dbModel = dbModel.Where("{{{ .ColumnName }}} <= ?", listReq.{{{ title (toCamelCase .ColumnName) }}}End)
} }
{{{- else }}} {{{- else }}}
{{{- if and (eq .GoType "string") (eq $queryOpr "like") }}} {{{- if and (eq .GoType "string") (eq $queryOpr "like") }}}
@@ -154,6 +154,9 @@ func (service {{{ toCamelCase .EntityName }}}Service) Del(id int) (e error) {
// //
{{{- if contains .AllFields "is_delete" }}} {{{- if contains .AllFields "is_delete" }}}
obj.IsDelete = 1 obj.IsDelete = 1
{{{- if contains .AllFields "delete_time" }}}
obj.DeleteTime = core.NowTime()
{{{- end }}}
err = service.db.Save(&obj).Error err = service.db.Save(&obj).Error
e = response.CheckErr(err, "删除失败") e = response.CheckErr(err, "删除失败")
{{{- else }}} {{{- else }}}

View File

@@ -1,7 +1,8 @@
<template> <template>
<div class="index-lists"> <div class="index-lists">
<el-card class="!border-none" shadow="never"> <el-card class="!border-none" shadow="never">
<el-form ref="formRef" class="mb-[-16px]" :model="queryParams" :inline="true"> <el-form ref="formRef" class="mb-[-16px]" :model="queryParams" :inline="true" label-width="70px"
label-position="left">
{{{- range .Columns }}} {{{- range .Columns }}}
{{{- if eq .IsQuery 1 }}} {{{- if eq .IsQuery 1 }}}
{{{- if eq .HtmlType "datetime" }}} {{{- if eq .HtmlType "datetime" }}}

View File

@@ -3,8 +3,8 @@ package tpl_utils
import ( import (
"strconv" "strconv"
"strings" "strings"
"time"
"x_admin/config" "x_admin/config"
"x_admin/core"
"x_admin/model/gen_model" "x_admin/model/gen_model"
"x_admin/util" "x_admin/util"
@@ -67,8 +67,8 @@ func (gu genUtil) InitTable(table gen_model.GenTable) gen_model.GenTable {
EntityName: gu.ToClassName(table.TableName), EntityName: gu.ToClassName(table.TableName),
ModuleName: gu.ToModuleName(table.TableName), ModuleName: gu.ToModuleName(table.TableName),
FunctionName: strings.Replace(table.TableComment, "表", "", -1), FunctionName: strings.Replace(table.TableComment, "表", "", -1),
CreateTime: time.Now().Unix(), CreateTime: core.NowTime(),
UpdateTime: time.Now().Unix(), UpdateTime: core.NowTime(),
} }
} }
@@ -89,8 +89,8 @@ func (gu genUtil) InitColumn(tableId uint, column gen_model.GenTableColumn) gen_
IsPk: column.IsPk, IsPk: column.IsPk,
IsIncrement: column.IsIncrement, IsIncrement: column.IsIncrement,
IsRequired: column.IsRequired, IsRequired: column.IsRequired,
CreateTime: time.Now().Unix(), CreateTime: core.NowTime(),
UpdateTime: time.Now().Unix(), UpdateTime: core.NowTime(),
} }
if util.ToolsUtil.Contains(append(SqlConstants.ColumnTypeStr, SqlConstants.ColumnTypeText...), columnType) { if util.ToolsUtil.Contains(append(SqlConstants.ColumnTypeStr, SqlConstants.ColumnTypeText...), columnType) {
//文本域组 //文本域组

View File

@@ -126,7 +126,7 @@ func (service monitorClientService) Detail(id int) (res MonitorClientResp, e err
func (service monitorClientService) Add(addReq MonitorClientAddReq) (e error) { func (service monitorClientService) Add(addReq MonitorClientAddReq) (e error) {
var obj model.MonitorClient var obj model.MonitorClient
response.Copy(&obj, addReq) response.Copy(&obj, addReq)
obj.ClientTime = core.ToUnix(addReq.ClientTime) // obj.ClientTime = core.ToUnix(addReq.ClientTime)
err := service.db.Create(&obj).Error err := service.db.Create(&obj).Error
e = response.CheckMysqlErr(err) e = response.CheckMysqlErr(err)

View File

@@ -57,16 +57,16 @@ func (service monitorWebService) List(page request.PageReq, listReq MonitorWebLi
dbModel = dbModel.Where("stack = ?", listReq.Stack) dbModel = dbModel.Where("stack = ?", listReq.Stack)
} }
if listReq.ClientTimeStart != "" { if listReq.ClientTimeStart != "" {
dbModel = dbModel.Where("client_time >= UNIX_TIMESTAMP(?)", listReq.ClientTimeStart) dbModel = dbModel.Where("client_time >= ?", listReq.ClientTimeStart)
} }
if listReq.ClientTimeEnd != "" { if listReq.ClientTimeEnd != "" {
dbModel = dbModel.Where("client_time <= UNIX_TIMESTAMP(?)", listReq.ClientTimeEnd) dbModel = dbModel.Where("client_time <= ?", listReq.ClientTimeEnd)
} }
if listReq.CreateTimeStart != "" { if listReq.CreateTimeStart != "" {
dbModel = dbModel.Where("create_time >= UNIX_TIMESTAMP(?)", listReq.CreateTimeStart) dbModel = dbModel.Where("create_time >= ?", listReq.CreateTimeStart)
} }
if listReq.CreateTimeEnd != "" { if listReq.CreateTimeEnd != "" {
dbModel = dbModel.Where("create_time <= UNIX_TIMESTAMP(?)", listReq.CreateTimeEnd) dbModel = dbModel.Where("create_time <= ?", listReq.CreateTimeEnd)
} }
// 总数 // 总数

View File

@@ -1,9 +1,10 @@
package admin package admin
import ( import (
"github.com/gin-gonic/gin"
"x_admin/middleware"
"x_admin/admin/monitor_web" "x_admin/admin/monitor_web"
"x_admin/middleware"
"github.com/gin-gonic/gin"
) )
/** /**
@@ -25,20 +26,8 @@ admin:monitor_web:detail
admin:monitor_web:ExportFile admin:monitor_web:ExportFile
admin:monitor_web:ImportFile admin:monitor_web:ImportFile
// 列表
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, paths, component, is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'C', '错误收集error', '/monitor_web/index', 'monitor_web/index', 0, 1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
按钮
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '错误收集error添加','admin:monitor_web:add', 0, 1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '错误收集error编辑','admin:monitor_web:edit', 0, 1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '错误收集error删除','admin:monitor_web:del', 0, 1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '错误收集error列表','admin:monitor_web:list', 0, 1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '错误收集error全部列表','admin:monitor_web:listAll', 0, 1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '错误收集error详情','admin:monitor_web:detail', 0, 1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '错误收集error导出excel','admin:monitor_web:ExportFile', 0, 1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '错误收集error导入excel','admin:monitor_web:ImportFile', 0, 1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
*/ */
// MonitorWebRoute(rg) // MonitorWebRoute(rg)
func MonitorWebRoute(rg *gin.RouterGroup) { func MonitorWebRoute(rg *gin.RouterGroup) {
handle := monitor_web.MonitorWebHandler{} handle := monitor_web.MonitorWebHandler{}
@@ -47,8 +36,8 @@ func MonitorWebRoute(rg *gin.RouterGroup) {
rg.GET("/monitor_web/list", handle.List) rg.GET("/monitor_web/list", handle.List)
rg.GET("/monitor_web/listAll", handle.ListAll) rg.GET("/monitor_web/listAll", handle.ListAll)
rg.GET("/monitor_web/detail", handle.Detail) rg.GET("/monitor_web/detail", handle.Detail)
rg.POST("/monitor_web/add",middleware.RecordLog("错误收集error新增"), handle.Add) rg.POST("/monitor_web/add", middleware.RecordLog("错误收集error新增"), handle.Add)
rg.POST("/monitor_web/edit",middleware.RecordLog("错误收集error编辑"), handle.Edit) rg.POST("/monitor_web/edit", middleware.RecordLog("错误收集error编辑"), handle.Edit)
rg.POST("/monitor_web/del", middleware.RecordLog("错误收集error删除"), handle.Del) rg.POST("/monitor_web/del", middleware.RecordLog("错误收集error删除"), handle.Del)
rg.GET("/monitor_web/ExportFile", middleware.RecordLog("错误收集error导出"), handle.ExportFile) rg.GET("/monitor_web/ExportFile", middleware.RecordLog("错误收集error导出"), handle.ExportFile)
rg.POST("/monitor_web/ImportFile", handle.ImportFile) rg.POST("/monitor_web/ImportFile", handle.ImportFile)

View File

@@ -1,7 +1,6 @@
package dict_data package dict_data
import ( import (
"time"
"x_admin/core" "x_admin/core"
"x_admin/core/request" "x_admin/core/request"
"x_admin/core/response" "x_admin/core/response"
@@ -152,6 +151,6 @@ func (ddSrv settingDictDataService) Edit(editReq SettingDictDataEditReq) (e erro
// Del 字典数据删除 // Del 字典数据删除
func (ddSrv settingDictDataService) Del(delReq SettingDictDataDelReq) (e error) { func (ddSrv settingDictDataService) Del(delReq SettingDictDataDelReq) (e error) {
err := ddSrv.db.Model(&setting_model.DictData{}).Where("id IN ?", delReq.Ids).Updates( err := ddSrv.db.Model(&setting_model.DictData{}).Where("id IN ?", delReq.Ids).Updates(
setting_model.DictData{IsDelete: 1, DeleteTime: time.Now().Unix()}).Error setting_model.DictData{IsDelete: 1, DeleteTime: core.NowTime()}).Error
return response.CheckErr(err, "Del Update err") return response.CheckErr(err, "Del Update err")
} }

View File

@@ -1,7 +1,6 @@
package dict_type package dict_type
import ( import (
"time"
"x_admin/core" "x_admin/core"
"x_admin/core/request" "x_admin/core/request"
"x_admin/core/response" "x_admin/core/response"
@@ -132,6 +131,6 @@ func (dtSrv settingDictTypeService) Edit(editReq SettingDictTypeEditReq) (e erro
// Del 字典类型删除 // Del 字典类型删除
func (dtSrv settingDictTypeService) Del(delReq SettingDictTypeDelReq) (e error) { func (dtSrv settingDictTypeService) Del(delReq SettingDictTypeDelReq) (e error) {
err := dtSrv.db.Model(&setting_model.DictType{}).Where("id IN ?", delReq.Ids).Updates( err := dtSrv.db.Model(&setting_model.DictType{}).Where("id IN ?", delReq.Ids).Updates(
setting_model.DictType{IsDelete: 1, DeleteTime: time.Now().Unix()}).Error setting_model.DictType{IsDelete: 1, DeleteTime: core.NowTime()}).Error
return response.CheckErr(err, "Del Update err") return response.CheckErr(err, "Del Update err")
} }

View File

@@ -425,7 +425,7 @@ func (adminSrv systemAuthAdminService) Del(c *gin.Context, id uint) (e error) {
if id == config.AdminConfig.GetAdminId(c) { if id == config.AdminConfig.GetAdminId(c) {
return response.AssertArgumentError.Make("不能删除自己!") return response.AssertArgumentError.Make("不能删除自己!")
} }
err = adminSrv.db.Model(&admin).Updates(system_model.SystemAuthAdmin{IsDelete: 1, DeleteTime: time.Now().Unix()}).Error err = adminSrv.db.Model(&admin).Updates(system_model.SystemAuthAdmin{IsDelete: 1, DeleteTime: core.TsTime(time.Now())}).Error
e = response.CheckErr(err, "Del Updates err") e = response.CheckErr(err, "Del Updates err")
return return
} }
@@ -449,7 +449,7 @@ func (adminSrv systemAuthAdminService) Disable(c *gin.Context, id uint) (e error
} else { } else {
isDisable = 0 isDisable = 0
} }
err = adminSrv.db.Model(&admin).Updates(map[string]interface{}{"is_disable": isDisable, "update_time": time.Now().Unix()}).Error err = adminSrv.db.Model(&admin).Updates(map[string]interface{}{"is_disable": isDisable, "update_time": time.Now()}).Error
e = response.CheckErr(err, "Disable Updates err") e = response.CheckErr(err, "Disable Updates err")
return return
} }

View File

@@ -31,9 +31,9 @@ type systemAuthDeptService struct {
} }
// All 部门所有 // All 部门所有
func (deptSrv systemAuthDeptService) All() (res []SystemAuthDeptResp, e error) { func (service systemAuthDeptService) All() (res []SystemAuthDeptResp, e error) {
var depts []system_model.SystemAuthDept var depts []system_model.SystemAuthDept
err := deptSrv.db.Where("is_delete = ?", 0).Order("sort desc, id desc").Find(&depts).Error err := service.db.Where("is_delete = ?", 0).Order("sort desc, id desc").Find(&depts).Error
if e = response.CheckErr(err, "All Find err"); e != nil { if e = response.CheckErr(err, "All Find err"); e != nil {
return return
} }
@@ -43,8 +43,8 @@ func (deptSrv systemAuthDeptService) All() (res []SystemAuthDeptResp, e error) {
} }
// List 部门列表 // List 部门列表
func (deptSrv systemAuthDeptService) List(listReq SystemAuthDeptListReq) (deptResps []SystemAuthDeptResp, e error) { func (service systemAuthDeptService) List(listReq SystemAuthDeptListReq) (deptResps []SystemAuthDeptResp, e error) {
deptModel := deptSrv.db.Where("is_delete = ?", 0) deptModel := service.db.Where("is_delete = ?", 0)
if listReq.Name != "" { if listReq.Name != "" {
deptModel = deptModel.Where("name like ?", "%"+listReq.Name+"%") deptModel = deptModel.Where("name like ?", "%"+listReq.Name+"%")
} }
@@ -64,9 +64,9 @@ func (deptSrv systemAuthDeptService) List(listReq SystemAuthDeptListReq) (deptRe
} }
// Detail 部门详情 // Detail 部门详情
func (deptSrv systemAuthDeptService) Detail(id uint) (res SystemAuthDeptResp, e error) { func (service systemAuthDeptService) Detail(id uint) (res SystemAuthDeptResp, e error) {
var dept system_model.SystemAuthDept var dept system_model.SystemAuthDept
err := deptSrv.db.Where("id = ? AND is_delete = ?", id, 0).Limit(1).First(&dept).Error err := service.db.Where("id = ? AND is_delete = ?", id, 0).Limit(1).First(&dept).Error
if e = response.CheckErrDBNotRecord(err, "部门已不存在!"); e != nil { if e = response.CheckErrDBNotRecord(err, "部门已不存在!"); e != nil {
return return
} }
@@ -78,9 +78,9 @@ func (deptSrv systemAuthDeptService) Detail(id uint) (res SystemAuthDeptResp, e
} }
// Add 部门新增 // Add 部门新增
func (deptSrv systemAuthDeptService) Add(addReq SystemAuthDeptAddReq) (e error) { func (service systemAuthDeptService) Add(addReq SystemAuthDeptAddReq) (e error) {
if addReq.Pid == 0 { if addReq.Pid == 0 {
r := deptSrv.db.Where("pid = ? AND is_delete = ?", 0, 0).Limit(1).Find(&system_model.SystemAuthDept{}) r := service.db.Where("pid = ? AND is_delete = ?", 0, 0).Limit(1).Find(&system_model.SystemAuthDept{})
if e = response.CheckErr(r.Error, "Add Find err"); e != nil { if e = response.CheckErr(r.Error, "Add Find err"); e != nil {
return return
} }
@@ -90,15 +90,15 @@ func (deptSrv systemAuthDeptService) Add(addReq SystemAuthDeptAddReq) (e error)
} }
var dept system_model.SystemAuthDept var dept system_model.SystemAuthDept
response.Copy(&dept, addReq) response.Copy(&dept, addReq)
err := deptSrv.db.Create(&dept).Error err := service.db.Create(&dept).Error
e = response.CheckErr(err, "Add Create err") e = response.CheckErr(err, "Add Create err")
return return
} }
// Edit 部门编辑 // Edit 部门编辑
func (deptSrv systemAuthDeptService) Edit(editReq SystemAuthDeptEditReq) (e error) { func (service systemAuthDeptService) Edit(editReq SystemAuthDeptEditReq) (e error) {
var dept system_model.SystemAuthDept var dept system_model.SystemAuthDept
err := deptSrv.db.Where("id = ? AND is_delete = ?", editReq.ID, 0).Limit(1).First(&dept).Error err := service.db.Where("id = ? AND is_delete = ?", editReq.ID, 0).Limit(1).First(&dept).Error
// 校验 // 校验
if e = response.CheckErrDBNotRecord(err, "部门不存在!"); e != nil { if e = response.CheckErrDBNotRecord(err, "部门不存在!"); e != nil {
return return
@@ -114,15 +114,15 @@ func (deptSrv systemAuthDeptService) Edit(editReq SystemAuthDeptEditReq) (e erro
} }
// 更新 // 更新
response.Copy(&dept, editReq) response.Copy(&dept, editReq)
err = deptSrv.db.Model(&dept).Select("*").Updates(dept).Error err = service.db.Model(&dept).Select("*").Updates(dept).Error
e = response.CheckErr(err, "Edit Updates err") e = response.CheckErr(err, "Edit Updates err")
return return
} }
// Del 部门删除 // Del 部门删除
func (deptSrv systemAuthDeptService) Del(id uint) (e error) { func (service systemAuthDeptService) Del(id uint) (e error) {
var dept system_model.SystemAuthDept var dept system_model.SystemAuthDept
err := deptSrv.db.Where("id = ? AND is_delete = ?", id, 0).Limit(1).First(&dept).Error err := service.db.Where("id = ? AND is_delete = ?", id, 0).Limit(1).First(&dept).Error
// 校验 // 校验
if e = response.CheckErrDBNotRecord(err, "部门不存在!"); e != nil { if e = response.CheckErrDBNotRecord(err, "部门不存在!"); e != nil {
return return
@@ -133,22 +133,23 @@ func (deptSrv systemAuthDeptService) Del(id uint) (e error) {
if dept.Pid == 0 { if dept.Pid == 0 {
return response.AssertArgumentError.Make("顶级部门不能删除!") return response.AssertArgumentError.Make("顶级部门不能删除!")
} }
r := deptSrv.db.Where("pid = ? AND is_delete = ?", id, 0).Limit(1).Find(&system_model.SystemAuthDept{}) r := service.db.Where("pid = ? AND is_delete = ?", id, 0).Limit(1).Find(&system_model.SystemAuthDept{})
if e = response.CheckErr(r.Error, "Del Find dept err"); e != nil { if e = response.CheckErr(r.Error, "Del Find dept err"); e != nil {
return return
} }
if r.RowsAffected > 0 { if r.RowsAffected > 0 {
return response.AssertArgumentError.Make("请先删除子级部门!") return response.AssertArgumentError.Make("请先删除子级部门!")
} }
r = deptSrv.db.Where("dept_id = ? AND is_delete = ?", id, 0).Limit(1).Find(&system_model.SystemAuthAdmin{}) r = service.db.Where("dept_id = ? AND is_delete = ?", id, 0).Limit(1).Find(&system_model.SystemAuthAdmin{})
if e = response.CheckErr(r.Error, "Del Find admin err"); e != nil { if e = response.CheckErr(r.Error, "Del Find admin err"); e != nil {
return return
} }
if r.RowsAffected > 0 { if r.RowsAffected > 0 {
return response.AssertArgumentError.Make("该部门已被管理员使用,请先移除!") return response.AssertArgumentError.Make("该部门已被管理员使用,请先移除!")
} }
dept.IsDelete = 1 // dept.IsDelete = 1
err = deptSrv.db.Save(&dept).Error // err = service.db.Save(&dept).Error
err = service.db.Delete(&dept).Error
e = response.CheckErr(err, "Del Save err") e = response.CheckErr(err, "Del Save err")
return return
} }

View File

@@ -59,10 +59,10 @@ func (logSrv systemLogsServer) Operate(page request.PageReq, logReq SystemLogOpe
logModel = logModel.Where("url = ?", logReq.Url) logModel = logModel.Where("url = ?", logReq.Url)
} }
if logReq.StartTime != "" { if logReq.StartTime != "" {
logModel = logModel.Where("log.create_time >= UNIX_TIMESTAMP(?)", logReq.StartTime) logModel = logModel.Where("log.create_time >= ?", logReq.StartTime)
} }
if logReq.EndTime != "" { if logReq.EndTime != "" {
logModel = logModel.Where("log.create_time <= UNIX_TIMESTAMP(?)", logReq.EndTime) logModel = logModel.Where("log.create_time <= ?", logReq.EndTime)
} }
// 总数 // 总数
var count int64 var count int64
@@ -99,10 +99,10 @@ func (logSrv systemLogsServer) Login(page request.PageReq, logReq SystemLogLogin
logModel = logModel.Where("status = ?", logReq.Status) logModel = logModel.Where("status = ?", logReq.Status)
} }
if logReq.StartTime != "" { if logReq.StartTime != "" {
logModel = logModel.Where("create_time >= UNIX_TIMESTAMP(?)", logReq.StartTime) logModel = logModel.Where("create_time >= now(?)", logReq.StartTime)
} }
if logReq.EndTime != "" { if logReq.EndTime != "" {
logModel = logModel.Where("create_time <= UNIX_TIMESTAMP(?)", logReq.EndTime) logModel = logModel.Where("create_time <= now(?)", logReq.EndTime)
} }
// 总数 // 总数
var count int64 var count int64

View File

@@ -4,7 +4,6 @@ import (
"errors" "errors"
"runtime/debug" "runtime/debug"
"strconv" "strconv"
"time"
"x_admin/admin/system/admin" "x_admin/admin/system/admin"
"x_admin/config" "x_admin/config"
"x_admin/core" "x_admin/core"
@@ -97,7 +96,7 @@ func (loginSrv systemLoginService) Login(c *gin.Context, req *SystemLoginReq) (r
// 更新登录信息 // 更新登录信息
err = loginSrv.db.Model(&sysAdmin).Updates( err = loginSrv.db.Model(&sysAdmin).Updates(
system_model.SystemAuthAdmin{LastLoginIp: c.ClientIP(), LastLoginTime: time.Now().Unix()}).Error system_model.SystemAuthAdmin{LastLoginIp: c.ClientIP(), LastLoginTime: core.NowTime()}).Error
if err != nil { if err != nil {
if e = loginSrv.RecordLoginLog(c, sysAdmin.ID, req.Username, response.SystemError.Msg()); e != nil { if e = loginSrv.RecordLoginLog(c, sysAdmin.ID, req.Username, response.SystemError.Msg()); e != nil {
return return

View File

@@ -32,9 +32,9 @@ type systemAuthPostService struct {
} }
// All 岗位所有 // All 岗位所有
func (postSrv systemAuthPostService) All() (res []SystemAuthPostResp, e error) { func (service systemAuthPostService) All() (res []SystemAuthPostResp, e error) {
var posts []system_model.SystemAuthPost var posts []system_model.SystemAuthPost
err := postSrv.db.Where("is_delete = ?", 0).Order("sort desc, id desc").Find(&posts).Error err := service.db.Order("sort desc, id desc").Find(&posts).Error
if e = response.CheckErr(err, "All Find err"); e != nil { if e = response.CheckErr(err, "All Find err"); e != nil {
return return
} }
@@ -44,12 +44,12 @@ func (postSrv systemAuthPostService) All() (res []SystemAuthPostResp, e error) {
} }
// List 岗位列表 // List 岗位列表
func (postSrv systemAuthPostService) List(page request.PageReq, listReq SystemAuthPostListReq) (res response.PageResp, e error) { func (service systemAuthPostService) List(page request.PageReq, listReq SystemAuthPostListReq) (res response.PageResp, e error) {
// 分页信息 // 分页信息
limit := page.PageSize limit := page.PageSize
offset := page.PageSize * (page.PageNo - 1) offset := page.PageSize * (page.PageNo - 1)
// 查询 // 查询
postModel := postSrv.db.Model(&system_model.SystemAuthPost{}).Where("is_delete = ?", 0) postModel := service.db.Model(&system_model.SystemAuthPost{})
if listReq.Code != "" { if listReq.Code != "" {
postModel = postModel.Where("code like ?", "%"+listReq.Code+"%") postModel = postModel.Where("code like ?", "%"+listReq.Code+"%")
} }
@@ -82,9 +82,9 @@ func (postSrv systemAuthPostService) List(page request.PageReq, listReq SystemAu
} }
// Detail 部门详情 // Detail 部门详情
func (postSrv systemAuthPostService) Detail(id uint) (res SystemAuthPostResp, e error) { func (service systemAuthPostService) Detail(id uint) (res SystemAuthPostResp, e error) {
var post system_model.SystemAuthPost var post system_model.SystemAuthPost
err := postSrv.db.Where("id = ? AND is_delete = ?", id, 0).Limit(1).First(&post).Error err := service.db.Where("id = ? AND is_delete = ?", id, 0).Limit(1).First(&post).Error
if e = response.CheckErrDBNotRecord(err, "岗位不存在!"); e != nil { if e = response.CheckErrDBNotRecord(err, "岗位不存在!"); e != nil {
return return
} }
@@ -96,8 +96,8 @@ func (postSrv systemAuthPostService) Detail(id uint) (res SystemAuthPostResp, e
} }
// Add 部门新增 // Add 部门新增
func (postSrv systemAuthPostService) Add(addReq SystemAuthPostAddReq) (e error) { func (service systemAuthPostService) Add(addReq SystemAuthPostAddReq) (e error) {
r := postSrv.db.Where("(code = ? OR name = ?) AND is_delete = ?", addReq.Code, addReq.Name, 0).Limit(1).Find(&system_model.SystemAuthPost{}) r := service.db.Where("(code = ? OR name = ?) AND is_delete = ?", addReq.Code, addReq.Name, 0).Limit(1).Find(&system_model.SystemAuthPost{})
if e = response.CheckErr(r.Error, "Add Find err"); e != nil { if e = response.CheckErr(r.Error, "Add Find err"); e != nil {
return return
} }
@@ -106,15 +106,15 @@ func (postSrv systemAuthPostService) Add(addReq SystemAuthPostAddReq) (e error)
} }
var post system_model.SystemAuthPost var post system_model.SystemAuthPost
response.Copy(&post, addReq) response.Copy(&post, addReq)
err := postSrv.db.Create(&post).Error err := service.db.Create(&post).Error
e = response.CheckErr(err, "Add Create err") e = response.CheckErr(err, "Add Create err")
return return
} }
// Edit 部门编辑 // Edit 部门编辑
func (postSrv systemAuthPostService) Edit(editReq SystemAuthPostEditReq) (e error) { func (service systemAuthPostService) Edit(editReq SystemAuthPostEditReq) (e error) {
var post system_model.SystemAuthPost var post system_model.SystemAuthPost
err := postSrv.db.Where("id = ? AND is_delete = ?", editReq.ID, 0).Limit(1).First(&post).Error err := service.db.Where("id = ? AND is_delete = ?", editReq.ID, 0).Limit(1).First(&post).Error
// 校验 // 校验
if e = response.CheckErrDBNotRecord(err, "部门不存在!"); e != nil { if e = response.CheckErrDBNotRecord(err, "部门不存在!"); e != nil {
return return
@@ -122,7 +122,7 @@ func (postSrv systemAuthPostService) Edit(editReq SystemAuthPostEditReq) (e erro
if e = response.CheckErr(err, "Edit First err"); e != nil { if e = response.CheckErr(err, "Edit First err"); e != nil {
return return
} }
r := postSrv.db.Where("(code = ? OR name = ?) AND id != ? AND is_delete = ?", editReq.Code, editReq.Name, editReq.ID, 0).Limit(1).Find(&system_model.SystemAuthPost{}) r := service.db.Where("(code = ? OR name = ?) AND id != ? AND is_delete = ?", editReq.Code, editReq.Name, editReq.ID, 0).Limit(1).Find(&system_model.SystemAuthPost{})
if e = response.CheckErr(r.Error, "Add Find err"); e != nil { if e = response.CheckErr(r.Error, "Add Find err"); e != nil {
return return
} }
@@ -131,31 +131,31 @@ func (postSrv systemAuthPostService) Edit(editReq SystemAuthPostEditReq) (e erro
} }
// 更新 // 更新
response.Copy(&post, editReq) response.Copy(&post, editReq)
err = postSrv.db.Model(&post).Select("*").Updates(post).Error err = service.db.Model(&post).Select("*").Updates(post).Error
e = response.CheckErr(err, "Edit Updates err") e = response.CheckErr(err, "Edit Updates err")
return return
} }
// Del 部门删除 // Del 部门删除
func (postSrv systemAuthPostService) Del(id uint) (e error) { func (service systemAuthPostService) Del(id uint) (e error) {
var post system_model.SystemAuthPost var post system_model.SystemAuthPost
err := postSrv.db.Where("id = ? AND is_delete = ?", id, 0).Limit(1).First(&post).Error err := service.db.Where("id = ? AND is_delete = ?", id, 0).Limit(1).First(&post).Error
// 校验 // 校验
if e = response.CheckErrDBNotRecord(err, "部门不存在!"); e != nil { if e = response.CheckErrDBNotRecord(err, "岗位不存在!"); e != nil {
return return
} }
if e = response.CheckErr(err, "Del First err"); e != nil { if e = response.CheckErr(err, "Del First err"); e != nil {
return return
} }
r := postSrv.db.Where("post_id = ? AND is_delete = ?", id, 0).Limit(1).Find(&system_model.SystemAuthAdmin{}) r := service.db.Where("post_id = ? AND is_delete = ?", id, 0).Limit(1).Find(&system_model.SystemAuthAdmin{})
if e = response.CheckErr(r.Error, "Del Find err"); e != nil { if e = response.CheckErr(r.Error, "Del Find err"); e != nil {
return return
} }
if r.RowsAffected > 0 { if r.RowsAffected > 0 {
return response.AssertArgumentError.Make("该岗位已被管理员使用,请先移除!") return response.AssertArgumentError.Make("该岗位存在管理员,请先移除!")
} }
post.IsDelete = 1
err = postSrv.db.Save(&post).Error err = service.db.Delete(&post).Error
e = response.CheckErr(err, "Del Save err") e = response.CheckErr(err, "Del Save err")
return return
} }

View File

@@ -1,54 +1,39 @@
package core package core
import ( import (
"database/sql/driver"
"encoding/json" "encoding/json"
"fmt"
"time" "time"
"gorm.io/gorm"
"gorm.io/gorm/schema"
) )
const DateFormat = "2006-01-02" const DateFormat = "2006-01-02"
const TimeFormat = "2006-01-02 15:04:05" const TimeFormat = "2006-01-02 15:04:05"
// TsTime 自定义时间格式 // TsTime 自定义时间格式
type TsTime int64 type TsTime time.Time
type OnlyRespTsTime time.Time type OnlyRespTsTime time.Time
// //TsDate 自定义日期格式 // func (tst *TsTime) UnmarshalJSON(bs []byte) error {
// type TsDate int64 // var date string
// // err := json.Unmarshal(bs, &date)
// func (tsd *TsDate) UnmarshalJSON(bs []byte) error { // if err != nil {
// var date string // return err
// err := json.Unmarshal(bs, &date) // }
// if err != nil { // tt, _ := time.ParseInLocation(TimeFormat, date, time.Local)
// return err // *tst = TsTime(tt.Unix())
// } // return nil
// tt, _ := time.ParseInLocation(DateFormat, date, time.Local) // }
// *tsd = TsDate(tt.Unix())
// return nil
// }
//
// func (tsd TsDate) MarshalJSON() ([]byte, error) {
// tt := time.Unix(int64(tsd), 0).Format(DateFormat)
// return json.Marshal(tt)
// }
//
func (tst *TsTime) UnmarshalJSON(bs []byte) error { // // MarshalJSON 将TsTime类型的时间转化为JSON字符串格式
var date string // // 返回转化后的JSON字符串和错误信息
err := json.Unmarshal(bs, &date) // func (tst TsTime) MarshalJSON() ([]byte, error) {
if err != nil { // tt := time.Unix(int64(tst), 0).Format(TimeFormat)
return err // return json.Marshal(tt)
} // }
tt, _ := time.ParseInLocation(TimeFormat, date, time.Local)
*tst = TsTime(tt.Unix())
return nil
}
// MarshalJSON 将TsTime类型的时间转化为JSON字符串格式
// 返回转化后的JSON字符串和错误信息
func (tst TsTime) MarshalJSON() ([]byte, error) {
tt := time.Unix(int64(tst), 0).Format(TimeFormat)
return json.Marshal(tt)
}
// 通过时间字符串生成时间戳 // 通过时间字符串生成时间戳
func ToUnix(date string) int64 { func ToUnix(date string) int64 {
@@ -58,8 +43,69 @@ func ToUnix(date string) int64 {
tt, _ := time.ParseInLocation(TimeFormat, date, time.Local) tt, _ := time.ParseInLocation(TimeFormat, date, time.Local)
return tt.Unix() return tt.Unix()
} }
func NowTime() TsTime {
return TsTime(time.Now())
}
func (otst OnlyRespTsTime) MarshalJSON() ([]byte, error) { func (otst OnlyRespTsTime) MarshalJSON() ([]byte, error) {
tt := time.Time(otst).Format(TimeFormat) tt := time.Time(otst).Format(TimeFormat)
return json.Marshal(tt) return json.Marshal(tt)
} }
// type TsTime time.Time
func (tst *TsTime) UnmarshalJSON(bs []byte) error {
var date string
err := json.Unmarshal(bs, &date)
if err != nil {
return err
}
tt, _ := time.ParseInLocation(TimeFormat, date, time.Local)
*tst = TsTime(tt)
return nil
}
// MarshalJSON 将TsTime类型的时间转化为JSON字符串格式
// 返回转化后的JSON字符串和错误信息
func (tst TsTime) MarshalJSON() ([]byte, error) {
tt := time.Time(tst).Format(TimeFormat)
return json.Marshal(tt)
}
// 写入数据库gorm调用
func (t TsTime) Value() (driver.Value, error) {
timeStr := t.String()
if timeStr == "0001-01-01 00:00:00" {
return nil, nil
}
return timeStr, nil
}
// 读取数据gorm调用
func (t *TsTime) Scan(v any) error {
// pt, err := time.ParseInLocation("2006-01-02 15:04:05", v.(time.Time).String(), time.Local)
if pt, ok := v.(time.Time); ok {
*t = TsTime(pt)
return nil
}
return fmt.Errorf("cant convert %s to time", v)
}
func (t TsTime) String() string {
return time.Time(t).Format(TimeFormat)
}
func (TsTime) GormDBDataType(db *gorm.DB, field *schema.Field) string {
// 使用 field.Tag、field.TagSettings 获取字段的 tag
// 查看 https://github.com/go-gorm/gorm/blob/master/schema/field.go 获取全部的选项
// 根据不同的数据库驱动返回不同的数据类型
// switch db.Dialector.Name() {
// case "mysql", "sqlite":
// return "JSON"
// case "postgres":
// return "JSONB"
// }
// return ""
return "DATETIME"
}

View File

@@ -26,6 +26,7 @@ require (
golang.org/x/image v0.15.0 golang.org/x/image v0.15.0
gorm.io/driver/mysql v1.5.4 gorm.io/driver/mysql v1.5.4
gorm.io/gorm v1.25.7 gorm.io/gorm v1.25.7
gorm.io/plugin/soft_delete v1.2.1
) )
require ( require (

View File

@@ -211,6 +211,8 @@ github.com/jinzhu/copier v0.4.0 h1:w3ciUoD19shMCRargcpm0cm91ytaBhDvuRpz1ODO/U8=
github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
@@ -247,6 +249,8 @@ github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-sqlite3 v1.14.3 h1:j7a/xn1U6TKA/PHHxqZuzh64CdtRc7rU9M+AvkOl5bA=
github.com/mattn/go-sqlite3 v1.14.3/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGwNd0Lj+XmI=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@@ -712,9 +716,15 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/driver/mysql v1.5.4 h1:igQmHfKcbaTVyAIHNhhB888vvxh8EdQ2uSUT0LPcBso= gorm.io/driver/mysql v1.5.4 h1:igQmHfKcbaTVyAIHNhhB888vvxh8EdQ2uSUT0LPcBso=
gorm.io/driver/mysql v1.5.4/go.mod h1:9rYxJph/u9SWkWc9yY4XJ1F/+xO0S/ChOmbk3+Z5Tvs= gorm.io/driver/mysql v1.5.4/go.mod h1:9rYxJph/u9SWkWc9yY4XJ1F/+xO0S/ChOmbk3+Z5Tvs=
gorm.io/driver/sqlite v1.1.3 h1:BYfdVuZB5He/u9dt4qDpZqiqDJ6KhPqs5QUqsr/Eeuc=
gorm.io/driver/sqlite v1.1.3/go.mod h1:AKDgRWk8lcSQSw+9kxCJnX/yySj8G3rdwYlU57cB45c=
gorm.io/gorm v1.20.1/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
gorm.io/gorm v1.23.0/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
gorm.io/gorm v1.25.7-0.20240204074919-46816ad31dde/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= gorm.io/gorm v1.25.7-0.20240204074919-46816ad31dde/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
gorm.io/gorm v1.25.7 h1:VsD6acwRjz2zFxGO50gPO6AkNs7KKnvfzUjHQhZDz/A= gorm.io/gorm v1.25.7 h1:VsD6acwRjz2zFxGO50gPO6AkNs7KKnvfzUjHQhZDz/A=
gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
gorm.io/plugin/soft_delete v1.2.1 h1:qx9D/c4Xu6w5KT8LviX8DgLcB9hkKl6JC9f44Tj7cGU=
gorm.io/plugin/soft_delete v1.2.1/go.mod h1:Zv7vQctOJTGOsJ/bWgrN1n3od0GBAZgnLjEx+cApLGk=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

View File

@@ -32,7 +32,7 @@ func RecordLog(title string, reqTypes ...requestType) gin.HandlerFunc {
} }
return func(c *gin.Context) { return func(c *gin.Context) {
// 开始时间 // 开始时间
startTime := time.Now().UnixMilli() startTime := time.Now()
// 异常信息 // 异常信息
errStr := "" errStr := ""
var status uint8 = 1 // 1=成功, 2=失败 var status uint8 = 1 // 1=成功, 2=失败
@@ -85,9 +85,9 @@ func RecordLog(title string, reqTypes ...requestType) gin.HandlerFunc {
errStr = fmt.Sprintf("%+v", r) errStr = fmt.Sprintf("%+v", r)
status = 2 status = 2
// 结束时间 // 结束时间
endTime := time.Now().UnixMilli() endTime := time.Now()
// 执行时间(毫秒) // 执行时间(毫秒)
taskTime := endTime - startTime taskTime := endTime.UnixMilli() - startTime.UnixMilli()
// 获取当前的用户 // 获取当前的用户
adminId := config.AdminConfig.GetAdminId(c) adminId := config.AdminConfig.GetAdminId(c)
urlPath := c.Request.URL.Path urlPath := c.Request.URL.Path
@@ -96,7 +96,9 @@ func RecordLog(title string, reqTypes ...requestType) gin.HandlerFunc {
err := core.GetDB().Create(&system_model.SystemLogOperate{ err := core.GetDB().Create(&system_model.SystemLogOperate{
AdminId: adminId, Type: reqMethod, Title: title, Ip: ip, AdminId: adminId, Type: reqMethod, Title: title, Ip: ip,
Url: urlPath, Method: method, Args: args, Error: errStr, Status: status, Url: urlPath, Method: method, Args: args, Error: errStr, Status: status,
StartTime: startTime / 1000, EndTime: endTime / 1000, TaskTime: taskTime, StartTime: core.TsTime(startTime),
EndTime: core.TsTime(endTime),
TaskTime: taskTime,
}).Error }).Error
response.CheckErr(err, "RecordLog recover Create err") response.CheckErr(err, "RecordLog recover Create err")
core.Logger.WithOptions(zap.AddCallerSkip(2)).Infof( core.Logger.WithOptions(zap.AddCallerSkip(2)).Infof(
@@ -111,9 +113,9 @@ func RecordLog(title string, reqTypes ...requestType) gin.HandlerFunc {
status = 2 status = 2
} }
// 结束时间 // 结束时间
endTime := time.Now().UnixMilli() endTime := time.Now()
// 执行时间(毫秒) // 执行时间(毫秒)
taskTime := endTime - startTime taskTime := endTime.UnixMilli() - startTime.UnixMilli()
// 获取当前的用户 // 获取当前的用户
adminId := config.AdminConfig.GetAdminId(c) adminId := config.AdminConfig.GetAdminId(c)
urlPath := c.Request.URL.Path urlPath := c.Request.URL.Path
@@ -122,7 +124,9 @@ func RecordLog(title string, reqTypes ...requestType) gin.HandlerFunc {
err := core.GetDB().Create(&system_model.SystemLogOperate{ err := core.GetDB().Create(&system_model.SystemLogOperate{
AdminId: adminId, Type: reqMethod, Title: title, Ip: ip, AdminId: adminId, Type: reqMethod, Title: title, Ip: ip,
Url: urlPath, Method: method, Args: args, Error: errStr, Status: status, Url: urlPath, Method: method, Args: args, Error: errStr, Status: status,
StartTime: startTime / 1000, EndTime: endTime / 1000, TaskTime: taskTime, StartTime: core.TsTime(startTime),
EndTime: core.TsTime(endTime),
TaskTime: taskTime,
}).Error }).Error
response.CheckErr(err, "RecordLog Create err") response.CheckErr(err, "RecordLog Create err")
} }

View File

@@ -1,12 +1,14 @@
package model package model
import "x_admin/core"
//ArticleCollect 文章收藏实体 //ArticleCollect 文章收藏实体
type ArticleCollect struct { type ArticleCollect struct {
Id int `gorm:"primarykey;comment:'主键'"` // 主键 Id int `gorm:"primarykey;comment:'主键'"` // 主键
UserId int `gorm:"comment:'用户ID'"` // 用户ID UserId int `gorm:"comment:'用户ID'"` // 用户ID
ArticleId int `gorm:"comment:'文章ID'"` // 文章ID ArticleId int `gorm:"comment:'文章ID'"` // 文章ID
IsDelete int `gorm:"comment:'是否删除'"` // 是否删除 IsDelete int `gorm:"comment:'是否删除'"` // 是否删除
UpdateTime int64 `gorm:"autoUpdateTime;comment:'更新时间'"` // 更新时间 UpdateTime core.TsTime `gorm:"autoUpdateTime;comment:'更新时间'"` // 更新时间
CreateTime int64 `gorm:"autoCreateTime;comment:'创建时间'"` // 创建时间 CreateTime core.TsTime `gorm:"autoCreateTime;comment:'创建时间'"` // 创建时间
DeleteTime int64 `gorm:"comment:'删除时间'"` // 删除时间 DeleteTime core.TsTime `gorm:"default:null;comment:'删除时间'"` // 删除时间
} }

View File

@@ -1,30 +1,32 @@
package common_model package common_model
import "x_admin/core"
//Album 相册实体 //Album 相册实体
type Album struct { type Album struct {
ID uint `gorm:"primarykey;comment:'主键ID'"` ID uint `gorm:"primarykey;comment:'主键ID'"`
Cid uint `gorm:"not null;default:0;comment:'类目ID'"` Cid uint `gorm:"not null;default:0;comment:'类目ID'"`
Aid uint `gorm:"not null;default:0;comment:'管理ID'"` Aid uint `gorm:"not null;default:0;comment:'管理ID'"`
Uid uint `gorm:"not null;default:0;comment:'用户ID'"` Uid uint `gorm:"not null;default:0;comment:'用户ID'"`
Type int `gorm:"not null;default:10;comment:'文件类型: [10=图片, 20=视频]''"` Type int `gorm:"not null;default:10;comment:'文件类型: [10=图片, 20=视频]''"`
Name string `gorm:"not null;default:'';comment:'文件名称''"` Name string `gorm:"not null;default:'';comment:'文件名称''"`
Uri string `gorm:"not null;comment:'文件路径'"` Uri string `gorm:"not null;comment:'文件路径'"`
Ext string `gorm:"not null;default:'';comment:'文件扩展'"` Ext string `gorm:"not null;default:'';comment:'文件扩展'"`
Size int64 `gorm:"not null;default:0;comment:文件大小"` Size int64 `gorm:"not null;default:0;comment:文件大小"`
IsDelete uint8 `gorm:"not null;default:0;comment:'是否删除: 0=否, 1=是'"` IsDelete uint8 `gorm:"not null;default:0;softDelete:flag,DeletedAtField:DeleteTime;comment:'是否删除: 0=否, 1=是'"`
CreateTime int64 `gorm:"autoCreateTime;not null;comment:'创建时间'"` CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
UpdateTime int64 `gorm:"autoUpdateTime;not null;comment:'更新时间'"` UpdateTime core.TsTime `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
DeleteTime int64 `gorm:"not null;default:0;comment:'删除时间'"` DeleteTime core.TsTime `gorm:"default:null;comment:'删除时间'"`
} }
//AlbumCate 相册分类实体 //AlbumCate 相册分类实体
type AlbumCate struct { type AlbumCate struct {
ID uint `gorm:"primarykey;comment:'主键ID'"` ID uint `gorm:"primarykey;comment:'主键ID'"`
Pid uint `gorm:"not null;default:0;comment:'父级ID'"` Pid uint `gorm:"not null;default:0;comment:'父级ID'"`
Type int `gorm:"not null;default:10;comment:'文件类型: [10=图片, 20=视频]''"` Type int `gorm:"not null;default:10;comment:'文件类型: [10=图片, 20=视频]''"`
Name string `gorm:"not null;default:'';comment:'分类名称''"` Name string `gorm:"not null;default:'';comment:'分类名称''"`
IsDelete uint8 `gorm:"not null;default:0;comment:'是否删除: 0=否, 1=是'"` IsDelete uint8 `gorm:"not null;default:0;softDelete:flag,DeletedAtField:DeleteTime;comment:'是否删除: 0=否, 1=是'"`
CreateTime int64 `gorm:"autoCreateTime;not null;comment:'创建时间'"` CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
UpdateTime int64 `gorm:"autoUpdateTime;not null;comment:'更新时间'"` UpdateTime core.TsTime `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
DeleteTime int64 `gorm:"not null;default:0;comment:'删除时间'"` DeleteTime core.TsTime `gorm:"default:null;comment:'删除时间'"`
} }

View File

@@ -1,21 +1,23 @@
package model package model
import "x_admin/core"
//FlowApply 申请流程实体 //FlowApply 申请流程实体
type FlowApply struct { type FlowApply struct {
Id int `gorm:"primarykey;comment:''"` // Id int `gorm:"primarykey;comment:''"` //
TemplateId int `gorm:"comment:'模板'"` // 模板 TemplateId int `gorm:"comment:'模板'"` // 模板
ApplyUserId int `gorm:"comment:'申请人id'"` // 申请人id ApplyUserId int `gorm:"comment:'申请人id'"` // 申请人id
ApplyUserNickname string `gorm:"comment:'申请人昵称'"` // 申请人昵称 ApplyUserNickname string `gorm:"comment:'申请人昵称'"` // 申请人昵称
FlowName string `gorm:"comment:'流程名称'"` // 流程名称 FlowName string `gorm:"comment:'流程名称'"` // 流程名称
FlowGroup int `gorm:"comment:'流程分类'"` // 流程分类 FlowGroup int `gorm:"comment:'流程分类'"` // 流程分类
FlowRemark string `gorm:"comment:'流程描述'"` // 流程描述 FlowRemark string `gorm:"comment:'流程描述'"` // 流程描述
FlowFormData string `gorm:"comment:'表单配置'"` // 表单配置 FlowFormData string `gorm:"comment:'表单配置'"` // 表单配置
FlowProcessData string `gorm:"comment:'流程配置'"` // 流程配置 FlowProcessData string `gorm:"comment:'流程配置'"` // 流程配置
FlowProcessDataList string `gorm:"comment:'流程配置list数据'"` // 流程配置list数据 FlowProcessDataList string `gorm:"comment:'流程配置list数据'"` // 流程配置list数据
FormValue string `gorm:"comment:'表单值'"` // 表单值 FormValue string `gorm:"comment:'表单值'"` // 表单值
Status int `gorm:"comment:'状态1待提交2审批中3审批完成4审批失败'"` // 状态0待提交1审批中2审批完成3审批失败 Status int `gorm:"comment:'状态1待提交2审批中3审批完成4审批失败'"` // 状态0待提交1审批中2审批完成3审批失败
IsDelete int `gorm:"comment:'是否删除'"` // 是否删除 IsDelete int `gorm:"comment:'是否删除'"` // 是否删除
UpdateTime int64 `gorm:"autoUpdateTime;comment:'更新时间'"` // 更新时间 UpdateTime core.TsTime `gorm:"autoUpdateTime;comment:'更新时间'"` // 更新时间
CreateTime int64 `gorm:"autoCreateTime;comment:'创建时间'"` // 创建时间 CreateTime core.TsTime `gorm:"autoCreateTime;comment:'创建时间'"` // 创建时间
DeleteTime int64 `gorm:"comment:'删除时间'"` // 删除时间 DeleteTime core.TsTime `gorm:"default:null;comment:'删除时间'"` // 删除时间
} }

View File

@@ -1,5 +1,7 @@
package model package model
import "x_admin/core"
//FlowHistory 流程历史实体 //FlowHistory 流程历史实体
type FlowHistory struct { type FlowHistory struct {
Id int `gorm:"primarykey;comment:'历史id'"` // 历史id Id int `gorm:"primarykey;comment:'历史id'"` // 历史id
@@ -26,10 +28,10 @@ type FlowHistory struct {
PassRemark string `gorm:"comment:'通过备注'"` // 通过备注 PassRemark string `gorm:"comment:'通过备注'"` // 通过备注
UpdateTime int64 `gorm:"autoUpdateTime;comment:'更新时间'"` // 更新时间 UpdateTime core.TsTime `gorm:"autoUpdateTime;comment:'更新时间'"` // 更新时间
CreateTime int64 `gorm:"autoCreateTime;comment:'创建时间'"` // 创建时间 CreateTime core.TsTime `gorm:"autoCreateTime;comment:'创建时间'"` // 创建时间
DeleteTime int64 `gorm:"comment:'删除时间'"` // 删除时间 DeleteTime core.TsTime `gorm:"default:null;comment:'删除时间'"` // 删除时间
} }

View File

@@ -1,5 +1,7 @@
package model package model
import "x_admin/core"
//FlowTemplate 流程模板实体 //FlowTemplate 流程模板实体
type FlowTemplate struct { type FlowTemplate struct {
Id int `gorm:"primarykey;comment:''"` // Id int `gorm:"primarykey;comment:''"` //
@@ -9,4 +11,9 @@ type FlowTemplate struct {
FlowFormData string `gorm:"comment:'表单配置'"` // 表单配置 FlowFormData string `gorm:"comment:'表单配置'"` // 表单配置
FlowProcessData string `gorm:"comment:'流程配置'"` // 流程配置 FlowProcessData string `gorm:"comment:'流程配置'"` // 流程配置
FlowProcessDataList string `gorm:"comment:'流程配置list数据'"` // 流程配置list数据 FlowProcessDataList string `gorm:"comment:'流程配置list数据'"` // 流程配置list数据
IsDelete uint8 `gorm:"not null;default:0;softDelete:flag,DeletedAtField:DeleteTime;comment:'是否删除: 0=否, 1=是'"`
UpdateTime core.TsTime `gorm:"autoUpdateTime;comment:'更新时间'"` // 更新时间
CreateTime core.TsTime `gorm:"autoCreateTime;comment:'创建时间'"` // 创建时间
DeleteTime core.TsTime `gorm:"default:null;comment:'删除时间'"` // 删除时间
} }

View File

@@ -1,5 +1,7 @@
package gen_model package gen_model
import "x_admin/core"
//GenTable 代码生成业务实体 //GenTable 代码生成业务实体
type GenTable struct { type GenTable struct {
ID uint `gorm:"primarykey;comment:'主键'"` ID uint `gorm:"primarykey;comment:'主键'"`
@@ -16,32 +18,32 @@ type GenTable struct {
TreeName string `gorm:"not null;default:'';comment:'树显示字段'"` TreeName string `gorm:"not null;default:'';comment:'树显示字段'"`
GenTpl string `gorm:"not null;default:'crud';comment:'生成模板方式: [crud=单表, tree=树表]'"` GenTpl string `gorm:"not null;default:'crud';comment:'生成模板方式: [crud=单表, tree=树表]'"`
Remarks string `gorm:"not null;default:'';comment:'备注信息'"` Remarks string `gorm:"not null;default:'';comment:'备注信息'"`
CreateTime int64 `gorm:"autoCreateTime;not null;comment:'创建时间'"` CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
UpdateTime int64 `gorm:"autoUpdateTime;not null;comment:'更新时间'"` UpdateTime core.TsTime `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
} }
//GenTableColumn 代码生成表列实体 //GenTableColumn 代码生成表列实体
type GenTableColumn struct { type GenTableColumn struct {
ID uint `gorm:"primarykey;comment:'列主键'"` ID uint `gorm:"primarykey;comment:'列主键'"`
TableID uint `gorm:"not null;default:0;comment:'表外键'"` TableID uint `gorm:"not null;default:0;comment:'表外键'"`
ColumnName string `gorm:"not null;default:'';comment:'列名称'"` ColumnName string `gorm:"not null;default:'';comment:'列名称'"`
ColumnComment string `gorm:"not null;default:'';comment:'列描述'"` ColumnComment string `gorm:"not null;default:'';comment:'列描述'"`
ColumnLength int `gorm:"not null;default:0;comment:'列长度'"` ColumnLength int `gorm:"not null;default:0;comment:'列长度'"`
ColumnType string `gorm:"not null;default:'';comment:'列类型'"` ColumnType string `gorm:"not null;default:'';comment:'列类型'"`
GoType string `gorm:"not null;default:'';comment:'类型'"` GoType string `gorm:"not null;default:'';comment:'类型'"`
GoField string `gorm:"not null;default:'';comment:'字段名'"` GoField string `gorm:"not null;default:'';comment:'字段名'"`
IsPk uint8 `gorm:"not null;default:0;comment:'是否主键: [1=是, 0=否]'"` IsPk uint8 `gorm:"not null;default:0;comment:'是否主键: [1=是, 0=否]'"`
IsIncrement uint8 `gorm:"not null;default:0;comment:'是否自增: [1=是, 0=否]'"` IsIncrement uint8 `gorm:"not null;default:0;comment:'是否自增: [1=是, 0=否]'"`
IsRequired uint8 `gorm:"not null;default:0;comment:'是否必填: [1=是, 0=否]'"` IsRequired uint8 `gorm:"not null;default:0;comment:'是否必填: [1=是, 0=否]'"`
IsInsert uint8 `gorm:"not null;default:0;comment:'是否为插入字段: [1=是, 0=否]'"` IsInsert uint8 `gorm:"not null;default:0;comment:'是否为插入字段: [1=是, 0=否]'"`
IsEdit uint8 `gorm:"not null;default:0;comment:'是否编辑字段: [1=是, 0=否]'"` IsEdit uint8 `gorm:"not null;default:0;comment:'是否编辑字段: [1=是, 0=否]'"`
IsList uint8 `gorm:"not null;default:0;comment:'是否列表字段: [1=是, 0=否]'"` IsList uint8 `gorm:"not null;default:0;comment:'是否列表字段: [1=是, 0=否]'"`
IsQuery uint8 `gorm:"not null;default:0;comment:'是否查询字段: [1=是, 0=否]'"` IsQuery uint8 `gorm:"not null;default:0;comment:'是否查询字段: [1=是, 0=否]'"`
QueryType string `gorm:"not null;default:'=';comment:'查询方式: [等于、不等于、大于、小于、范围]'"` QueryType string `gorm:"not null;default:'=';comment:'查询方式: [等于、不等于、大于、小于、范围]'"`
HtmlType string `gorm:"not null;default:'';comment:'显示类型: [文本框、文本域、下拉框、复选框、单选框、日期控件]'"` HtmlType string `gorm:"not null;default:'';comment:'显示类型: [文本框、文本域、下拉框、复选框、单选框、日期控件]'"`
DictType string `gorm:"not null;default:'';comment:'字典类型'"` DictType string `gorm:"not null;default:'';comment:'字典类型'"`
Sort int `gorm:"not null;default:0;comment:'排序编号'"` Sort int `gorm:"not null;default:0;comment:'排序编号'"`
CreateTime int64 `gorm:"autoCreateTime;not null;comment:'创建时间'"` CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
UpdateTime int64 `gorm:"autoUpdateTime;not null;comment:'更新时间'"` UpdateTime core.TsTime `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
} }

View File

@@ -1,5 +1,7 @@
package model package model
import "x_admin/core"
//MonitorClient 客户端信息实体 //MonitorClient 客户端信息实体
type MonitorClient struct { type MonitorClient struct {
Id int `gorm:"primarykey;comment:'uuid'" excel:"name:uuid;"` // uuid Id int `gorm:"primarykey;comment:'uuid'" excel:"name:uuid;"` // uuid
@@ -22,8 +24,8 @@ type MonitorClient struct {
Ua string `gorm:"comment:'ua记录'" excel:"name:ua记录;"` // ua记录 Ua string `gorm:"comment:'ua记录'" excel:"name:ua记录;"` // ua记录
ClientTime int64 `gorm:"comment:'客户端时间'" excel:"name:客户端时间;"` // 客户端时间 ClientTime core.TsTime `gorm:"comment:'客户端时间'" excel:"name:客户端时间;"` // 客户端时间
CreateTime int64 `gorm:"autoCreateTime;comment:'创建时间'" excel:"name:创建时间;"` // 创建时间 CreateTime core.TsTime `gorm:"autoCreateTime;comment:'创建时间'" excel:"name:创建时间;"` // 创建时间
} }

View File

@@ -1,5 +1,7 @@
package model package model
import "x_admin/core"
//MonitorProject 错误项目实体 //MonitorProject 错误项目实体
type MonitorProject struct { type MonitorProject struct {
Id int `gorm:"primarykey;comment:'项目id'" excel:"name:项目id;"` // 项目id Id int `gorm:"primarykey;comment:'项目id'" excel:"name:项目id;"` // 项目id
@@ -12,10 +14,10 @@ type MonitorProject struct {
IsDelete int `gorm:"comment:'是否删除: 0=否, 1=是'" excel:"name:是否删除: 0=否, 1=是;"` // 是否删除: 0=否, 1=是 IsDelete int `gorm:"comment:'是否删除: 0=否, 1=是'" excel:"name:是否删除: 0=否, 1=是;"` // 是否删除: 0=否, 1=是
UpdateTime int64 `gorm:"autoUpdateTime;comment:'更新时间'" excel:"name:更新时间;"` // 更新时间 UpdateTime core.TsTime `gorm:"autoUpdateTime;comment:'更新时间'" excel:"name:更新时间;"` // 更新时间
CreateTime int64 `gorm:"autoCreateTime;comment:'创建时间'" excel:"name:创建时间;"` // 创建时间 CreateTime core.TsTime `gorm:"autoCreateTime;comment:'创建时间'" excel:"name:创建时间;"` // 创建时间
DeleteTime int64 `gorm:"comment:'删除时间'" excel:"name:删除时间;"` // 删除时间 DeleteTime core.TsTime `gorm:"default:null;comment:'删除时间'" excel:"name:删除时间;"` // 删除时间
} }

View File

@@ -1,5 +1,7 @@
package model package model
import "x_admin/core"
//MonitorWeb 错误收集error实体 //MonitorWeb 错误收集error实体
type MonitorWeb struct { type MonitorWeb struct {
Id int `gorm:"primarykey;comment:'uuid'" excel:"name:uuid;"` // uuid Id int `gorm:"primarykey;comment:'uuid'" excel:"name:uuid;"` // uuid
@@ -16,8 +18,8 @@ type MonitorWeb struct {
Stack string `gorm:"comment:'错误堆栈'" excel:"name:错误堆栈;"` // 错误堆栈 Stack string `gorm:"comment:'错误堆栈'" excel:"name:错误堆栈;"` // 错误堆栈
ClientTime int64 `gorm:"comment:'客户端时间'" excel:"name:客户端时间;"` // 客户端时间 ClientTime core.TsTime `gorm:"comment:'客户端时间'" excel:"name:客户端时间;"` // 客户端时间
CreateTime int64 `gorm:"autoCreateTime;comment:'创建时间'" excel:"name:创建时间;"` // 创建时间 CreateTime core.TsTime `gorm:"autoCreateTime;comment:'创建时间'" excel:"name:创建时间;"` // 创建时间
} }

View File

@@ -1,17 +1,19 @@
package setting_model package setting_model
import "x_admin/core"
//DictData 字典数据实体 //DictData 字典数据实体
type DictData struct { type DictData struct {
ID uint `gorm:"primarykey;comment:'主键'"` ID uint `gorm:"primarykey;comment:'主键'"`
TypeId uint `gorm:"not null;default:0;comment:'类型'"` TypeId uint `gorm:"not null;default:0;comment:'类型'"`
Name string `gorm:"not null;default:'';comment:'键名''"` Name string `gorm:"not null;default:'';comment:'键名''"`
Value string `gorm:"not null;default:'';comment:'数值'"` Value string `gorm:"not null;default:'';comment:'数值'"`
Color string `gorm:"default:'';comment:'颜色'"` Color string `gorm:"default:'';comment:'颜色'"`
Remark string `gorm:"not null;default:'';comment:'备注'"` Remark string `gorm:"not null;default:'';comment:'备注'"`
Sort uint16 `gorm:"not null;default:0;comment:'排序'"` Sort uint16 `gorm:"not null;default:0;comment:'排序'"`
Status uint8 `gorm:"not null;default:1;comment:'字典状态: 0=停用, 1=正常'"` Status uint8 `gorm:"not null;default:1;comment:'字典状态: 0=停用, 1=正常'"`
IsDelete uint8 `gorm:"not null;default:0;comment:'是否删除: 0=否, 1=是'"` IsDelete uint8 `gorm:"not null;default:0;comment:'是否删除: 0=否, 1=是'"`
CreateTime int64 `gorm:"autoCreateTime;not null;comment:'创建时间'"` CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
UpdateTime int64 `gorm:"autoUpdateTime;not null;comment:'更新时间'"` UpdateTime core.TsTime `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
DeleteTime int64 `gorm:"not null;default:0;comment:'删除时间'"` DeleteTime core.TsTime `gorm:"default:null;comment:'删除时间'"`
} }

View File

@@ -1,14 +1,16 @@
package setting_model package setting_model
import "x_admin/core"
//DictType 字典类型实体 //DictType 字典类型实体
type DictType struct { type DictType struct {
ID uint `gorm:"primarykey;comment:'主键'"` ID uint `gorm:"primarykey;comment:'主键'"`
DictName string `gorm:"not null;default:'';comment:'字典名称''"` DictName string `gorm:"not null;default:'';comment:'字典名称''"`
DictType string `gorm:"not null;default:'';comment:'字典类型'"` DictType string `gorm:"not null;default:'';comment:'字典类型'"`
DictRemark string `gorm:"not null;default:'';comment:'字典备注'"` DictRemark string `gorm:"not null;default:'';comment:'字典备注'"`
DictStatus uint8 `gorm:"not null;default:1;comment:'字典状态: 0=停用, 1=正常'"` DictStatus uint8 `gorm:"not null;default:1;comment:'字典状态: 0=停用, 1=正常'"`
IsDelete uint8 `gorm:"not null;default:0;comment:'是否删除: 0=否, 1=是'"` IsDelete uint8 `gorm:"not null;default:0;comment:'是否删除: 0=否, 1=是'"`
CreateTime int64 `gorm:"autoCreateTime;not null;comment:'创建时间'"` CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
UpdateTime int64 `gorm:"autoUpdateTime;not null;comment:'更新时间'"` UpdateTime core.TsTime `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
DeleteTime int64 `gorm:"not null;default:0;comment:'删除时间'"` DeleteTime core.TsTime `gorm:"default:null;comment:'删除时间'"`
} }

View File

@@ -1,130 +1,136 @@
package system_model package system_model
//SystemConfig 系统配置实体 import (
"x_admin/core"
"gorm.io/plugin/soft_delete"
)
// SystemConfig 系统配置实体
type SystemConfig struct { type SystemConfig struct {
ID uint `gorm:"primarykey;comment:'主键'"` ID uint `gorm:"primarykey;comment:'主键'"`
Type string `gorm:"default:'';comment:'类型''"` Type string `gorm:"default:'';comment:'类型''"`
Name string `gorm:"not null;default:'';comment:'键'"` Name string `gorm:"not null;default:'';comment:'键'"`
Value string `gorm:"type:text;not null;default:'';comment:'值'"` Value string `gorm:"type:text;not null;default:'';comment:'值'"`
CreateTime int64 `gorm:"autoCreateTime;not null;comment:'创建时间'"` CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
UpdateTime int64 `gorm:"autoUpdateTime;not null;comment:'更新时间'"` UpdateTime core.TsTime `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
} }
//SystemAuthAdmin 系统管理员实体 // SystemAuthAdmin 系统管理员实体
type SystemAuthAdmin struct { type SystemAuthAdmin struct {
ID uint `gorm:"primarykey;comment:'主键'"` ID uint `gorm:"primarykey;comment:'主键'"`
DeptId uint `gorm:"not null;default:0;comment:'部门ID'"` DeptId uint `gorm:"not null;default:0;comment:'部门ID'"`
PostId uint `gorm:"not null;default:0;comment:'岗位ID'"` PostId uint `gorm:"not null;default:0;comment:'岗位ID'"`
Username string `gorm:"not null;default:'';comment:'用户账号''"` Username string `gorm:"not null;default:'';comment:'用户账号''"`
Nickname string `gorm:"not null;default:'';comment:'用户昵称'"` Nickname string `gorm:"not null;default:'';comment:'用户昵称'"`
Password string `gorm:"not null;default:'';comment:'用户密码'"` Password string `gorm:"not null;default:'';comment:'用户密码'"`
Avatar string `gorm:"not null;default:'';comment:'用户头像'"` Avatar string `gorm:"not null;default:'';comment:'用户头像'"`
Role string `gorm:"not null;default:'';comment:'角色主键'"` Role string `gorm:"not null;default:'';comment:'角色主键'"`
Salt string `gorm:"not null;default:'';comment:'加密盐巴'"` Salt string `gorm:"not null;default:'';comment:'加密盐巴'"`
Sort uint16 `gorm:"not null;default:0;comment:'排序编号'"` Sort uint16 `gorm:"not null;default:0;comment:'排序编号'"`
IsDisable uint8 `gorm:"not null;default:0;comment:'是否禁用: 0=否, 1=是'"` IsDisable uint8 `gorm:"not null;default:0;comment:'是否禁用: 0=否, 1=是'"`
IsDelete uint8 `gorm:"not null;default:0;comment:'是否删除: 0=否, 1=是'"` IsDelete soft_delete.DeletedAt `gorm:"not null;default:0;softDelete:flag,DeletedAtField:DeleteTime;comment:'是否删除: 0=否, 1=是'"`
LastLoginIp string `gorm:"not null;default:'';comment:'最后登录IP'"` LastLoginIp string `gorm:"not null;default:'';comment:'最后登录IP'"`
LastLoginTime int64 `gorm:"not null;default:0;comment:'最后登录时间'"` LastLoginTime core.TsTime `gorm:"not null;default:null;comment:'最后登录时间'"`
CreateTime int64 `gorm:"autoCreateTime;not null;comment:'创建时间'"` CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
UpdateTime int64 `gorm:"autoUpdateTime;not null;comment:'更新时间'"` UpdateTime core.TsTime `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
DeleteTime int64 `gorm:"not null;default:0;comment:'删除时间'"` DeleteTime core.TsTime `gorm:"default:null;comment:'删除时间'"`
} }
//SystemAuthMenu 系统菜单实体 // SystemAuthMenu 系统菜单实体
type SystemAuthMenu struct { type SystemAuthMenu struct {
ID uint `gorm:"primarykey;comment:'主键'"` ID uint `gorm:"primarykey;comment:'主键'"`
Pid uint `gorm:"not null;default:0;comment:'上级菜单'"` Pid uint `gorm:"not null;default:0;comment:'上级菜单'"`
MenuType string `gorm:"not null;default:'';comment:'权限类型: M=目录C=菜单A=按钮''"` MenuType string `gorm:"not null;default:'';comment:'权限类型: M=目录C=菜单A=按钮''"`
MenuName string `gorm:"not null;default:'';comment:'菜单名称'"` MenuName string `gorm:"not null;default:'';comment:'菜单名称'"`
MenuIcon string `gorm:"not null;default:'';comment:'菜单图标'"` MenuIcon string `gorm:"not null;default:'';comment:'菜单图标'"`
MenuSort uint16 `gorm:"not null;default:0;comment:'菜单排序'"` MenuSort uint16 `gorm:"not null;default:0;comment:'菜单排序'"`
Perms string `gorm:"not null;default:'';comment:'权限标识'"` Perms string `gorm:"not null;default:'';comment:'权限标识'"`
Paths string `gorm:"not null;default:'';comment:'路由地址'"` Paths string `gorm:"not null;default:'';comment:'路由地址'"`
Component string `gorm:"not null;default:'';comment:'前端组件'"` Component string `gorm:"not null;default:'';comment:'前端组件'"`
Selected string `gorm:"not null;default:'';comment:'选中路径'"` Selected string `gorm:"not null;default:'';comment:'选中路径'"`
Params string `gorm:"not null;default:'';comment:'路由参数'"` Params string `gorm:"not null;default:'';comment:'路由参数'"`
IsCache uint8 `gorm:"not null;default:0;comment:'是否缓存: 0=否, 1=是''"` IsCache uint8 `gorm:"not null;default:0;comment:'是否缓存: 0=否, 1=是''"`
IsShow uint8 `gorm:"not null;default:1;comment:'是否显示: 0=否, 1=是'"` IsShow uint8 `gorm:"not null;default:1;comment:'是否显示: 0=否, 1=是'"`
IsDisable uint8 `gorm:"not null;default:0;comment:'是否禁用: 0=否, 1=是'"` IsDisable soft_delete.DeletedAt `gorm:"not null;default:0;comment:'是否禁用: 0=否, 1=是'"`
CreateTime int64 `gorm:"autoCreateTime;not null;comment:'创建时间'"` CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
UpdateTime int64 `gorm:"autoUpdateTime;not null;comment:'更新时间'"` UpdateTime core.TsTime `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
} }
//SystemAuthPerm 系统角色菜单实体 // SystemAuthPerm 系统角色菜单实体
type SystemAuthPerm struct { type SystemAuthPerm struct {
ID string `gorm:"primarykey;comment:'主键'"` ID string `gorm:"primarykey;comment:'主键'"`
RoleId uint `gorm:"not null;default:0;comment:'角色ID'"` RoleId uint `gorm:"not null;default:0;comment:'角色ID'"`
MenuId uint `gorm:"not null;default:0;comment:'菜单ID'"` MenuId uint `gorm:"not null;default:0;comment:'菜单ID'"`
} }
//SystemAuthRole 系统角色实体 // SystemAuthRole 系统角色实体
type SystemAuthRole struct { type SystemAuthRole struct {
ID uint `gorm:"primarykey;comment:'主键'"` ID uint `gorm:"primarykey;comment:'主键'"`
Name string `gorm:"not null;default:'';comment:'角色名称''"` Name string `gorm:"not null;default:'';comment:'角色名称''"`
Remark string `gorm:"not null;default:'';comment:'备注信息'"` Remark string `gorm:"not null;default:'';comment:'备注信息'"`
IsDisable uint8 `gorm:"not null;default:0;comment:'是否禁用: 0=否, 1=是'"` IsDisable uint8 `gorm:"not null;default:0;comment:'是否禁用: 0=否, 1=是'"`
Sort uint16 `gorm:"not null;default:0;comment:'角色排序'"` Sort uint16 `gorm:"not null;default:0;comment:'角色排序'"`
CreateTime int64 `gorm:"autoCreateTime;not null;comment:'创建时间'"` CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
UpdateTime int64 `gorm:"autoUpdateTime;not null;comment:'更新时间'"` UpdateTime core.TsTime `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
} }
//SystemAuthDept 系统部门实体 // SystemAuthDept 系统部门实体
type SystemAuthDept struct { type SystemAuthDept struct {
ID uint `gorm:"primarykey;comment:'主键'"` ID uint `gorm:"primarykey;comment:'主键'"`
Pid uint `gorm:"not null;default:0;comment:'上级主键'"` Pid uint `gorm:"not null;default:0;comment:'上级主键'"`
Name string `gorm:"not null;default:'';comment:'部门名称''"` Name string `gorm:"not null;default:'';comment:'部门名称''"`
DutyId int `gorm:"null;comment:'负责人id'"` DutyId int `gorm:"null;comment:'负责人id'"`
Duty string `gorm:"null;default:'';comment:'负责人名'"` Duty string `gorm:"null;default:'';comment:'负责人名'"`
Mobile string `gorm:"null;default:'';comment:'联系电话'"` Mobile string `gorm:"null;default:'';comment:'联系电话'"`
Sort uint16 `gorm:"not null;default:0;comment:'排序编号'"` Sort uint16 `gorm:"not null;default:0;comment:'排序编号'"`
IsStop uint8 `gorm:"not null;default:0;comment:'是否停用: 0=否, 1=是'"` IsStop uint8 `gorm:"not null;default:0;comment:'是否停用: 0=否, 1=是'"`
IsDelete uint8 `gorm:"not null;default:0;comment:'是否删除: 0=否, 1=是'"` IsDelete soft_delete.DeletedAt `gorm:"not null;default:0;softDelete:flag,DeletedAtField:DeleteTime;comment:'是否删除: 0=否, 1=是'"`
CreateTime int64 `gorm:"autoCreateTime;not null;comment:'创建时间'"` CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
UpdateTime int64 `gorm:"autoUpdateTime;not null;comment:'更新时间'"` UpdateTime core.TsTime `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
DeleteTime int64 `gorm:"not null;default:0;comment:'删除时间'"` DeleteTime core.TsTime `gorm:"default:0;comment:'删除时间'"`
} }
//SystemAuthPost 系统岗位管理 // SystemAuthPost 系统岗位管理
type SystemAuthPost struct { type SystemAuthPost struct {
ID uint `gorm:"primarykey;comment:'主键'"` ID uint `gorm:"primarykey;comment:'主键'"`
Code string `gorm:"not null;default:'';comment:'岗位编码''"` Code string `gorm:"not null;default:'';comment:'岗位编码''"`
Name string `gorm:"not null;default:'';comment:'岗位名称''"` Name string `gorm:"not null;default:'';comment:'岗位名称''"`
Remarks string `gorm:"not null;default:'';comment:'岗位备注''"` Remarks string `gorm:"not null;default:'';comment:'岗位备注''"`
Sort uint16 `gorm:"not null;default:0;comment:'岗位排序'"` Sort uint16 `gorm:"not null;default:0;comment:'岗位排序'"`
IsStop uint8 `gorm:"not null;default:0;comment:'是否停用: 0=否, 1=是'"` IsStop uint8 `gorm:"not null;default:0;comment:'是否停用: 0=否, 1=是'"`
IsDelete uint8 `gorm:"not null;default:0;comment:'是否删除: 0=否, 1=是'"` IsDelete soft_delete.DeletedAt `gorm:"not null;default:0;softDelete:flag,DeletedAtField:DeleteTime;comment:'是否删除: 0=否, 1=是'"`
CreateTime int64 `gorm:"autoCreateTime;not null;comment:'创建时间'"` CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
UpdateTime int64 `gorm:"autoUpdateTime;not null;comment:'更新时间'"` UpdateTime core.TsTime `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
DeleteTime int64 `gorm:"not null;default:0;comment:'删除时间'"` DeleteTime core.TsTime `gorm:"default:null;comment:'删除时间'"`
} }
//SystemLogLogin 系统登录日志实体 // SystemLogLogin 系统登录日志实体
type SystemLogLogin struct { type SystemLogLogin struct {
ID uint `gorm:"primarykey;comment:'主键'"` ID uint `gorm:"primarykey;comment:'主键'"`
AdminId uint `gorm:"not null;default:0;comment:'管理员ID'"` AdminId uint `gorm:"not null;default:0;comment:'管理员ID'"`
Username string `gorm:"not null;default:'';comment:'登录账号'"` Username string `gorm:"not null;default:'';comment:'登录账号'"`
Ip string `gorm:"not null;default:'';comment:'登录地址'"` Ip string `gorm:"not null;default:'';comment:'登录地址'"`
Os string `gorm:"not null;default:'';comment:'操作系统'"` Os string `gorm:"not null;default:'';comment:'操作系统'"`
Browser string `gorm:"not null;default:'';comment:'浏览器'"` Browser string `gorm:"not null;default:'';comment:'浏览器'"`
Status uint8 `gorm:"not null;default:0;comment:'操作状态: 1=成功, 0=失败'"` Status uint8 `gorm:"not null;default:0;comment:'操作状态: 1=成功, 0=失败'"`
CreateTime int64 `gorm:"autoCreateTime;not null;comment:'创建时间'"` CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
} }
//SystemLogOperate 系统操作日志实体 // SystemLogOperate 系统操作日志实体
type SystemLogOperate struct { type SystemLogOperate struct {
ID uint `gorm:"primarykey;comment:'主键'"` ID uint `gorm:"primarykey;comment:'主键'"`
AdminId uint `gorm:"not null;default:0;comment:'操作人ID'"` AdminId uint `gorm:"not null;default:0;comment:'操作人ID'"`
Type string `gorm:"not null;default:'';comment:'请求类型: GET/POST/PUT'"` Type string `gorm:"not null;default:'';comment:'请求类型: GET/POST/PUT'"`
Title string `gorm:"default:'';comment:'操作标题'"` Title string `gorm:"default:'';comment:'操作标题'"`
Ip string `gorm:"not null;default:'';comment:'请求IP'"` Ip string `gorm:"not null;default:'';comment:'请求IP'"`
Url string `gorm:"not null;default:'';comment:'请求接口'"` Url string `gorm:"not null;default:'';comment:'请求接口'"`
Method string `gorm:"not null;default:'';comment:'请求方法'"` Method string `gorm:"not null;default:'';comment:'请求方法'"`
Args string `gorm:"comment:'请求参数'"` Args string `gorm:"comment:'请求参数'"`
Error string `gorm:"comment:'错误信息'"` Error string `gorm:"comment:'错误信息'"`
Status uint8 `gorm:"not null;default:0;comment:'执行状态: 1=成功, 2=失败'"` Status uint8 `gorm:"not null;default:0;comment:'执行状态: 1=成功, 2=失败'"`
StartTime int64 `gorm:"not null;default:0;comment:'开始时间'"` StartTime core.TsTime `gorm:"not null;default:0;comment:'开始时间'"`
EndTime int64 `gorm:"not null;default:0;comment:'结束时间'"` EndTime core.TsTime `gorm:"not null;default:0;comment:'结束时间'"`
TaskTime int64 `gorm:"not null;default:0;comment:'执行耗时'"` TaskTime int64 `gorm:"not null;default:0;comment:'执行耗时'"`
CreateTime int64 `gorm:"autoCreateTime;not null;comment:'创建时间'"` CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
} }

1287
sql/x_admin - 副本.sql Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long