mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-10-05 00:02:50 +08:00
统一时间
This commit is contained in:
@@ -113,7 +113,7 @@ import {
|
||||
monitor_web_export_file
|
||||
} from '@/api/monitor_web'
|
||||
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 feedback from '@/utils/feedback'
|
||||
import EditPopup from './edit.vue'
|
||||
|
@@ -30,3 +30,4 @@
|
||||
### Go应该注意的问题
|
||||
1. 循环依赖
|
||||
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
|
@@ -2,7 +2,6 @@ package album
|
||||
|
||||
import (
|
||||
"path"
|
||||
"time"
|
||||
"x_admin/config"
|
||||
"x_admin/core"
|
||||
"x_admin/core/request"
|
||||
@@ -154,7 +153,7 @@ func (albSrv albumService) AlbumDel(ids []uint) (e error) {
|
||||
return response.AssertArgumentError.Make("文件丢失!")
|
||||
}
|
||||
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")
|
||||
return
|
||||
}
|
||||
@@ -222,7 +221,7 @@ func (albSrv albumService) CateDel(id uint) (e error) {
|
||||
return response.AssertArgumentError.Make("当前分类正被使用中,不能删除!")
|
||||
}
|
||||
cate.IsDelete = 1
|
||||
cate.DeleteTime = time.Now().Unix()
|
||||
cate.DeleteTime = core.NowTime()
|
||||
err = albSrv.db.Save(&cate).Error
|
||||
e = response.CheckErr(err, "CateDel Save err")
|
||||
return
|
||||
|
@@ -159,6 +159,7 @@ func (Service flowApplyService) Del(id int) (e error) {
|
||||
}
|
||||
// 删除
|
||||
obj.IsDelete = 1
|
||||
obj.DeleteTime = core.NowTime()
|
||||
err = Service.db.Save(&obj).Error
|
||||
e = response.CheckErr(err, "Del Save err")
|
||||
return
|
||||
|
@@ -104,8 +104,8 @@ type DownloadReq struct {
|
||||
type DbTableResp struct {
|
||||
TableName string `json:"tableName" structs:"tableName"` // 表的名称
|
||||
TableComment string `json:"tableComment" structs:"tableComment"` // 表的描述
|
||||
CreateTime core.OnlyRespTsTime `json:"createTime" structs:"createTime"` // 创建时间
|
||||
UpdateTime core.OnlyRespTsTime `json:"updateTime" structs:"updateTime"` // 更新时间
|
||||
CreateTime core.TsTime `json:"createTime" structs:"createTime"` // 创建时间
|
||||
UpdateTime core.TsTime `json:"updateTime" structs:"updateTime"` // 更新时间
|
||||
}
|
||||
|
||||
// GenTableResp 生成表返回信息
|
||||
|
@@ -82,10 +82,10 @@ func (genSrv generateService) List(page request.PageReq, listReq ListTableReq) (
|
||||
genModel = genModel.Where("table_comment like ?", "%"+listReq.TableComment+"%")
|
||||
}
|
||||
if !listReq.StartTime.IsZero() {
|
||||
genModel = genModel.Where("create_time >= ?", listReq.StartTime.Unix())
|
||||
genModel = genModel.Where("create_time >= ?", listReq.StartTime)
|
||||
}
|
||||
if !listReq.EndTime.IsZero() {
|
||||
genModel = genModel.Where("create_time <= ?", listReq.EndTime.Unix())
|
||||
genModel = genModel.Where("create_time <= ?", listReq.EndTime)
|
||||
}
|
||||
// 总数
|
||||
var count int64
|
||||
|
@@ -1,14 +1,23 @@
|
||||
package model
|
||||
import (
|
||||
"x_admin/core"
|
||||
"gorm.io/plugin/soft_delete"
|
||||
)
|
||||
|
||||
//{{{ title (toCamelCase .EntityName) }}} {{{ .FunctionName }}}实体
|
||||
type {{{ title (toCamelCase .EntityName) }}} struct {
|
||||
{{{- range .Columns }}}
|
||||
{{{- if not (contains $.SubTableFields .ColumnName) }}}
|
||||
{{{ if eq .GoField "is_delete" }}}
|
||||
IsDelete soft_delete.DeletedAt `gorm:"not null;default:0;softDelete:flag,DeletedAtField:DeleteTime;comment:'是否删除: 0=否, 1=是'"`
|
||||
{{{ else }}}
|
||||
{{{ 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 }}}'" excel:"name:{{{ .ColumnComment }}};"` // {{{ .ColumnComment }}}
|
||||
{{{ 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 }}}
|
||||
}
|
||||
|
@@ -26,16 +26,16 @@ admin:{{{.ModuleName }}}:ExportFile
|
||||
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 }}}: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 }}}: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 }}}: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 }}}: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 }}}: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 }}}导出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 }}}: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 }}}添加','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, 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, 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, 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, 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, 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, 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, now(), now());
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -29,10 +29,10 @@ func (service {{{ toCamelCase .EntityName }}}Service) GetModel(listReq {{{ title
|
||||
{{{- $queryOpr := index $.ModelOprMap .QueryType }}}
|
||||
{{{- if eq .HtmlType "datetime" }}}
|
||||
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 != "" {
|
||||
dbModel = dbModel.Where("{{{ .ColumnName }}} <= UNIX_TIMESTAMP(?)", listReq.{{{ title (toCamelCase .ColumnName) }}}End)
|
||||
dbModel = dbModel.Where("{{{ .ColumnName }}} <= ?", listReq.{{{ title (toCamelCase .ColumnName) }}}End)
|
||||
}
|
||||
{{{- else }}}
|
||||
{{{- 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" }}}
|
||||
obj.IsDelete = 1
|
||||
{{{- if contains .AllFields "delete_time" }}}
|
||||
obj.DeleteTime = core.NowTime()
|
||||
{{{- end }}}
|
||||
err = service.db.Save(&obj).Error
|
||||
e = response.CheckErr(err, "删除失败")
|
||||
{{{- else }}}
|
||||
|
@@ -1,7 +1,8 @@
|
||||
<template>
|
||||
<div class="index-lists">
|
||||
<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 }}}
|
||||
{{{- if eq .IsQuery 1 }}}
|
||||
{{{- if eq .HtmlType "datetime" }}}
|
||||
|
@@ -3,8 +3,8 @@ package tpl_utils
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"x_admin/config"
|
||||
"x_admin/core"
|
||||
"x_admin/model/gen_model"
|
||||
"x_admin/util"
|
||||
|
||||
@@ -67,8 +67,8 @@ func (gu genUtil) InitTable(table gen_model.GenTable) gen_model.GenTable {
|
||||
EntityName: gu.ToClassName(table.TableName),
|
||||
ModuleName: gu.ToModuleName(table.TableName),
|
||||
FunctionName: strings.Replace(table.TableComment, "表", "", -1),
|
||||
CreateTime: time.Now().Unix(),
|
||||
UpdateTime: time.Now().Unix(),
|
||||
CreateTime: core.NowTime(),
|
||||
UpdateTime: core.NowTime(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,8 +89,8 @@ func (gu genUtil) InitColumn(tableId uint, column gen_model.GenTableColumn) gen_
|
||||
IsPk: column.IsPk,
|
||||
IsIncrement: column.IsIncrement,
|
||||
IsRequired: column.IsRequired,
|
||||
CreateTime: time.Now().Unix(),
|
||||
UpdateTime: time.Now().Unix(),
|
||||
CreateTime: core.NowTime(),
|
||||
UpdateTime: core.NowTime(),
|
||||
}
|
||||
if util.ToolsUtil.Contains(append(SqlConstants.ColumnTypeStr, SqlConstants.ColumnTypeText...), columnType) {
|
||||
//文本域组
|
||||
|
@@ -126,7 +126,7 @@ func (service monitorClientService) Detail(id int) (res MonitorClientResp, e err
|
||||
func (service monitorClientService) Add(addReq MonitorClientAddReq) (e error) {
|
||||
var obj model.MonitorClient
|
||||
response.Copy(&obj, addReq)
|
||||
obj.ClientTime = core.ToUnix(addReq.ClientTime)
|
||||
// obj.ClientTime = core.ToUnix(addReq.ClientTime)
|
||||
|
||||
err := service.db.Create(&obj).Error
|
||||
e = response.CheckMysqlErr(err)
|
||||
|
@@ -57,16 +57,16 @@ func (service monitorWebService) List(page request.PageReq, listReq MonitorWebLi
|
||||
dbModel = dbModel.Where("stack = ?", listReq.Stack)
|
||||
}
|
||||
if listReq.ClientTimeStart != "" {
|
||||
dbModel = dbModel.Where("client_time >= UNIX_TIMESTAMP(?)", listReq.ClientTimeStart)
|
||||
dbModel = dbModel.Where("client_time >= ?", listReq.ClientTimeStart)
|
||||
}
|
||||
if listReq.ClientTimeEnd != "" {
|
||||
dbModel = dbModel.Where("client_time <= UNIX_TIMESTAMP(?)", listReq.ClientTimeEnd)
|
||||
dbModel = dbModel.Where("client_time <= ?", listReq.ClientTimeEnd)
|
||||
}
|
||||
if listReq.CreateTimeStart != "" {
|
||||
dbModel = dbModel.Where("create_time >= UNIX_TIMESTAMP(?)", listReq.CreateTimeStart)
|
||||
dbModel = dbModel.Where("create_time >= ?", listReq.CreateTimeStart)
|
||||
}
|
||||
if listReq.CreateTimeEnd != "" {
|
||||
dbModel = dbModel.Where("create_time <= UNIX_TIMESTAMP(?)", listReq.CreateTimeEnd)
|
||||
dbModel = dbModel.Where("create_time <= ?", listReq.CreateTimeEnd)
|
||||
}
|
||||
|
||||
// 总数
|
||||
|
@@ -1,9 +1,10 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"x_admin/middleware"
|
||||
"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: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)
|
||||
func MonitorWebRoute(rg *gin.RouterGroup) {
|
||||
handle := monitor_web.MonitorWebHandler{}
|
||||
@@ -47,8 +36,8 @@ func MonitorWebRoute(rg *gin.RouterGroup) {
|
||||
rg.GET("/monitor_web/list", handle.List)
|
||||
rg.GET("/monitor_web/listAll", handle.ListAll)
|
||||
rg.GET("/monitor_web/detail", handle.Detail)
|
||||
rg.POST("/monitor_web/add",middleware.RecordLog("错误收集error新增"), handle.Add)
|
||||
rg.POST("/monitor_web/edit",middleware.RecordLog("错误收集error编辑"), handle.Edit)
|
||||
rg.POST("/monitor_web/add", middleware.RecordLog("错误收集error新增"), handle.Add)
|
||||
rg.POST("/monitor_web/edit", middleware.RecordLog("错误收集error编辑"), handle.Edit)
|
||||
rg.POST("/monitor_web/del", middleware.RecordLog("错误收集error删除"), handle.Del)
|
||||
rg.GET("/monitor_web/ExportFile", middleware.RecordLog("错误收集error导出"), handle.ExportFile)
|
||||
rg.POST("/monitor_web/ImportFile", handle.ImportFile)
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package dict_data
|
||||
|
||||
import (
|
||||
"time"
|
||||
"x_admin/core"
|
||||
"x_admin/core/request"
|
||||
"x_admin/core/response"
|
||||
@@ -152,6 +151,6 @@ func (ddSrv settingDictDataService) Edit(editReq SettingDictDataEditReq) (e erro
|
||||
// Del 字典数据删除
|
||||
func (ddSrv settingDictDataService) Del(delReq SettingDictDataDelReq) (e error) {
|
||||
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")
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package dict_type
|
||||
|
||||
import (
|
||||
"time"
|
||||
"x_admin/core"
|
||||
"x_admin/core/request"
|
||||
"x_admin/core/response"
|
||||
@@ -132,6 +131,6 @@ func (dtSrv settingDictTypeService) Edit(editReq SettingDictTypeEditReq) (e erro
|
||||
// Del 字典类型删除
|
||||
func (dtSrv settingDictTypeService) Del(delReq SettingDictTypeDelReq) (e error) {
|
||||
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")
|
||||
}
|
||||
|
@@ -425,7 +425,7 @@ func (adminSrv systemAuthAdminService) Del(c *gin.Context, id uint) (e error) {
|
||||
if id == config.AdminConfig.GetAdminId(c) {
|
||||
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")
|
||||
return
|
||||
}
|
||||
@@ -449,7 +449,7 @@ func (adminSrv systemAuthAdminService) Disable(c *gin.Context, id uint) (e error
|
||||
} else {
|
||||
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")
|
||||
return
|
||||
}
|
||||
|
@@ -31,9 +31,9 @@ type systemAuthDeptService struct {
|
||||
}
|
||||
|
||||
// All 部门所有
|
||||
func (deptSrv systemAuthDeptService) All() (res []SystemAuthDeptResp, e error) {
|
||||
func (service systemAuthDeptService) All() (res []SystemAuthDeptResp, e error) {
|
||||
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 {
|
||||
return
|
||||
}
|
||||
@@ -43,8 +43,8 @@ func (deptSrv systemAuthDeptService) All() (res []SystemAuthDeptResp, e error) {
|
||||
}
|
||||
|
||||
// List 部门列表
|
||||
func (deptSrv systemAuthDeptService) List(listReq SystemAuthDeptListReq) (deptResps []SystemAuthDeptResp, e error) {
|
||||
deptModel := deptSrv.db.Where("is_delete = ?", 0)
|
||||
func (service systemAuthDeptService) List(listReq SystemAuthDeptListReq) (deptResps []SystemAuthDeptResp, e error) {
|
||||
deptModel := service.db.Where("is_delete = ?", 0)
|
||||
if listReq.Name != "" {
|
||||
deptModel = deptModel.Where("name like ?", "%"+listReq.Name+"%")
|
||||
}
|
||||
@@ -64,9 +64,9 @@ func (deptSrv systemAuthDeptService) List(listReq SystemAuthDeptListReq) (deptRe
|
||||
}
|
||||
|
||||
// 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
|
||||
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 {
|
||||
return
|
||||
}
|
||||
@@ -78,9 +78,9 @@ func (deptSrv systemAuthDeptService) Detail(id uint) (res SystemAuthDeptResp, e
|
||||
}
|
||||
|
||||
// Add 部门新增
|
||||
func (deptSrv systemAuthDeptService) Add(addReq SystemAuthDeptAddReq) (e error) {
|
||||
func (service systemAuthDeptService) Add(addReq SystemAuthDeptAddReq) (e error) {
|
||||
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 {
|
||||
return
|
||||
}
|
||||
@@ -90,15 +90,15 @@ func (deptSrv systemAuthDeptService) Add(addReq SystemAuthDeptAddReq) (e error)
|
||||
}
|
||||
var dept system_model.SystemAuthDept
|
||||
response.Copy(&dept, addReq)
|
||||
err := deptSrv.db.Create(&dept).Error
|
||||
err := service.db.Create(&dept).Error
|
||||
e = response.CheckErr(err, "Add Create err")
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 部门编辑
|
||||
func (deptSrv systemAuthDeptService) Edit(editReq SystemAuthDeptEditReq) (e error) {
|
||||
func (service systemAuthDeptService) Edit(editReq SystemAuthDeptEditReq) (e error) {
|
||||
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 {
|
||||
return
|
||||
@@ -114,15 +114,15 @@ func (deptSrv systemAuthDeptService) Edit(editReq SystemAuthDeptEditReq) (e erro
|
||||
}
|
||||
// 更新
|
||||
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")
|
||||
return
|
||||
}
|
||||
|
||||
// Del 部门删除
|
||||
func (deptSrv systemAuthDeptService) Del(id uint) (e error) {
|
||||
func (service systemAuthDeptService) Del(id uint) (e error) {
|
||||
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 {
|
||||
return
|
||||
@@ -133,22 +133,23 @@ func (deptSrv systemAuthDeptService) Del(id uint) (e error) {
|
||||
if dept.Pid == 0 {
|
||||
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 {
|
||||
return
|
||||
}
|
||||
if r.RowsAffected > 0 {
|
||||
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 {
|
||||
return
|
||||
}
|
||||
if r.RowsAffected > 0 {
|
||||
return response.AssertArgumentError.Make("该部门已被管理员使用,请先移除!")
|
||||
}
|
||||
dept.IsDelete = 1
|
||||
err = deptSrv.db.Save(&dept).Error
|
||||
// dept.IsDelete = 1
|
||||
// err = service.db.Save(&dept).Error
|
||||
err = service.db.Delete(&dept).Error
|
||||
e = response.CheckErr(err, "Del Save err")
|
||||
return
|
||||
}
|
||||
|
@@ -59,10 +59,10 @@ func (logSrv systemLogsServer) Operate(page request.PageReq, logReq SystemLogOpe
|
||||
logModel = logModel.Where("url = ?", logReq.Url)
|
||||
}
|
||||
if logReq.StartTime != "" {
|
||||
logModel = logModel.Where("log.create_time >= UNIX_TIMESTAMP(?)", logReq.StartTime)
|
||||
logModel = logModel.Where("log.create_time >= ?", logReq.StartTime)
|
||||
}
|
||||
if logReq.EndTime != "" {
|
||||
logModel = logModel.Where("log.create_time <= UNIX_TIMESTAMP(?)", logReq.EndTime)
|
||||
logModel = logModel.Where("log.create_time <= ?", logReq.EndTime)
|
||||
}
|
||||
// 总数
|
||||
var count int64
|
||||
@@ -99,10 +99,10 @@ func (logSrv systemLogsServer) Login(page request.PageReq, logReq SystemLogLogin
|
||||
logModel = logModel.Where("status = ?", logReq.Status)
|
||||
}
|
||||
if logReq.StartTime != "" {
|
||||
logModel = logModel.Where("create_time >= UNIX_TIMESTAMP(?)", logReq.StartTime)
|
||||
logModel = logModel.Where("create_time >= now(?)", logReq.StartTime)
|
||||
}
|
||||
if logReq.EndTime != "" {
|
||||
logModel = logModel.Where("create_time <= UNIX_TIMESTAMP(?)", logReq.EndTime)
|
||||
logModel = logModel.Where("create_time <= now(?)", logReq.EndTime)
|
||||
}
|
||||
// 总数
|
||||
var count int64
|
||||
|
@@ -4,7 +4,6 @@ import (
|
||||
"errors"
|
||||
"runtime/debug"
|
||||
"strconv"
|
||||
"time"
|
||||
"x_admin/admin/system/admin"
|
||||
"x_admin/config"
|
||||
"x_admin/core"
|
||||
@@ -97,7 +96,7 @@ func (loginSrv systemLoginService) Login(c *gin.Context, req *SystemLoginReq) (r
|
||||
|
||||
// 更新登录信息
|
||||
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 e = loginSrv.RecordLoginLog(c, sysAdmin.ID, req.Username, response.SystemError.Msg()); e != nil {
|
||||
return
|
||||
|
@@ -32,9 +32,9 @@ type systemAuthPostService struct {
|
||||
}
|
||||
|
||||
// All 岗位所有
|
||||
func (postSrv systemAuthPostService) All() (res []SystemAuthPostResp, e error) {
|
||||
func (service systemAuthPostService) All() (res []SystemAuthPostResp, e error) {
|
||||
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 {
|
||||
return
|
||||
}
|
||||
@@ -44,12 +44,12 @@ func (postSrv systemAuthPostService) All() (res []SystemAuthPostResp, e error) {
|
||||
}
|
||||
|
||||
// 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
|
||||
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 != "" {
|
||||
postModel = postModel.Where("code like ?", "%"+listReq.Code+"%")
|
||||
}
|
||||
@@ -82,9 +82,9 @@ func (postSrv systemAuthPostService) List(page request.PageReq, listReq SystemAu
|
||||
}
|
||||
|
||||
// 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
|
||||
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 {
|
||||
return
|
||||
}
|
||||
@@ -96,8 +96,8 @@ func (postSrv systemAuthPostService) Detail(id uint) (res SystemAuthPostResp, e
|
||||
}
|
||||
|
||||
// Add 部门新增
|
||||
func (postSrv 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{})
|
||||
func (service systemAuthPostService) Add(addReq SystemAuthPostAddReq) (e error) {
|
||||
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 {
|
||||
return
|
||||
}
|
||||
@@ -106,15 +106,15 @@ func (postSrv systemAuthPostService) Add(addReq SystemAuthPostAddReq) (e error)
|
||||
}
|
||||
var post system_model.SystemAuthPost
|
||||
response.Copy(&post, addReq)
|
||||
err := postSrv.db.Create(&post).Error
|
||||
err := service.db.Create(&post).Error
|
||||
e = response.CheckErr(err, "Add Create err")
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 部门编辑
|
||||
func (postSrv systemAuthPostService) Edit(editReq SystemAuthPostEditReq) (e error) {
|
||||
func (service systemAuthPostService) Edit(editReq SystemAuthPostEditReq) (e error) {
|
||||
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 {
|
||||
return
|
||||
@@ -122,7 +122,7 @@ func (postSrv systemAuthPostService) Edit(editReq SystemAuthPostEditReq) (e erro
|
||||
if e = response.CheckErr(err, "Edit First err"); e != nil {
|
||||
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 {
|
||||
return
|
||||
}
|
||||
@@ -131,31 +131,31 @@ func (postSrv systemAuthPostService) Edit(editReq SystemAuthPostEditReq) (e erro
|
||||
}
|
||||
// 更新
|
||||
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")
|
||||
return
|
||||
}
|
||||
|
||||
// Del 部门删除
|
||||
func (postSrv systemAuthPostService) Del(id uint) (e error) {
|
||||
func (service systemAuthPostService) Del(id uint) (e error) {
|
||||
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
|
||||
}
|
||||
if e = response.CheckErr(err, "Del First err"); e != nil {
|
||||
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 {
|
||||
return
|
||||
}
|
||||
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")
|
||||
return
|
||||
}
|
||||
|
@@ -1,54 +1,39 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/schema"
|
||||
)
|
||||
|
||||
const DateFormat = "2006-01-02"
|
||||
const TimeFormat = "2006-01-02 15:04:05"
|
||||
|
||||
// TsTime 自定义时间格式
|
||||
type TsTime int64
|
||||
type TsTime time.Time
|
||||
type OnlyRespTsTime time.Time
|
||||
|
||||
// //TsDate 自定义日期格式
|
||||
// type TsDate int64
|
||||
//
|
||||
// func (tsd *TsDate) UnmarshalJSON(bs []byte) error {
|
||||
// func (tst *TsTime) UnmarshalJSON(bs []byte) error {
|
||||
// var date string
|
||||
// err := json.Unmarshal(bs, &date)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// tt, _ := time.ParseInLocation(DateFormat, date, time.Local)
|
||||
// *tsd = TsDate(tt.Unix())
|
||||
// tt, _ := time.ParseInLocation(TimeFormat, date, time.Local)
|
||||
// *tst = TsTime(tt.Unix())
|
||||
// return nil
|
||||
// }
|
||||
//
|
||||
// func (tsd TsDate) MarshalJSON() ([]byte, error) {
|
||||
// tt := time.Unix(int64(tsd), 0).Format(DateFormat)
|
||||
|
||||
// // MarshalJSON 将TsTime类型的时间转化为JSON字符串格式
|
||||
// // 返回转化后的JSON字符串和错误信息
|
||||
// func (tst TsTime) MarshalJSON() ([]byte, error) {
|
||||
// tt := time.Unix(int64(tst), 0).Format(TimeFormat)
|
||||
// return json.Marshal(tt)
|
||||
// }
|
||||
//
|
||||
|
||||
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.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 {
|
||||
@@ -58,8 +43,69 @@ func ToUnix(date string) int64 {
|
||||
tt, _ := time.ParseInLocation(TimeFormat, date, time.Local)
|
||||
return tt.Unix()
|
||||
}
|
||||
func NowTime() TsTime {
|
||||
return TsTime(time.Now())
|
||||
}
|
||||
|
||||
func (otst OnlyRespTsTime) MarshalJSON() ([]byte, error) {
|
||||
tt := time.Time(otst).Format(TimeFormat)
|
||||
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"
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ require (
|
||||
golang.org/x/image v0.15.0
|
||||
gorm.io/driver/mysql v1.5.4
|
||||
gorm.io/gorm v1.25.7
|
||||
gorm.io/plugin/soft_delete v1.2.1
|
||||
)
|
||||
|
||||
require (
|
||||
|
@@ -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/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/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/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
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.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
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/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
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=
|
||||
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/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 h1:VsD6acwRjz2zFxGO50gPO6AkNs7KKnvfzUjHQhZDz/A=
|
||||
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-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
|
@@ -32,7 +32,7 @@ func RecordLog(title string, reqTypes ...requestType) gin.HandlerFunc {
|
||||
}
|
||||
return func(c *gin.Context) {
|
||||
// 开始时间
|
||||
startTime := time.Now().UnixMilli()
|
||||
startTime := time.Now()
|
||||
// 异常信息
|
||||
errStr := ""
|
||||
var status uint8 = 1 // 1=成功, 2=失败
|
||||
@@ -85,9 +85,9 @@ func RecordLog(title string, reqTypes ...requestType) gin.HandlerFunc {
|
||||
errStr = fmt.Sprintf("%+v", r)
|
||||
status = 2
|
||||
// 结束时间
|
||||
endTime := time.Now().UnixMilli()
|
||||
endTime := time.Now()
|
||||
// 执行时间(毫秒)
|
||||
taskTime := endTime - startTime
|
||||
taskTime := endTime.UnixMilli() - startTime.UnixMilli()
|
||||
// 获取当前的用户
|
||||
adminId := config.AdminConfig.GetAdminId(c)
|
||||
urlPath := c.Request.URL.Path
|
||||
@@ -96,7 +96,9 @@ func RecordLog(title string, reqTypes ...requestType) gin.HandlerFunc {
|
||||
err := core.GetDB().Create(&system_model.SystemLogOperate{
|
||||
AdminId: adminId, Type: reqMethod, Title: title, Ip: ip,
|
||||
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
|
||||
response.CheckErr(err, "RecordLog recover Create err")
|
||||
core.Logger.WithOptions(zap.AddCallerSkip(2)).Infof(
|
||||
@@ -111,9 +113,9 @@ func RecordLog(title string, reqTypes ...requestType) gin.HandlerFunc {
|
||||
status = 2
|
||||
}
|
||||
// 结束时间
|
||||
endTime := time.Now().UnixMilli()
|
||||
endTime := time.Now()
|
||||
// 执行时间(毫秒)
|
||||
taskTime := endTime - startTime
|
||||
taskTime := endTime.UnixMilli() - startTime.UnixMilli()
|
||||
// 获取当前的用户
|
||||
adminId := config.AdminConfig.GetAdminId(c)
|
||||
urlPath := c.Request.URL.Path
|
||||
@@ -122,7 +124,9 @@ func RecordLog(title string, reqTypes ...requestType) gin.HandlerFunc {
|
||||
err := core.GetDB().Create(&system_model.SystemLogOperate{
|
||||
AdminId: adminId, Type: reqMethod, Title: title, Ip: ip,
|
||||
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
|
||||
response.CheckErr(err, "RecordLog Create err")
|
||||
}
|
||||
|
@@ -1,12 +1,14 @@
|
||||
package model
|
||||
|
||||
import "x_admin/core"
|
||||
|
||||
//ArticleCollect 文章收藏实体
|
||||
type ArticleCollect struct {
|
||||
Id int `gorm:"primarykey;comment:'主键'"` // 主键
|
||||
UserId int `gorm:"comment:'用户ID'"` // 用户ID
|
||||
ArticleId int `gorm:"comment:'文章ID'"` // 文章ID
|
||||
IsDelete int `gorm:"comment:'是否删除'"` // 是否删除
|
||||
UpdateTime int64 `gorm:"autoUpdateTime;comment:'更新时间'"` // 更新时间
|
||||
CreateTime int64 `gorm:"autoCreateTime;comment:'创建时间'"` // 创建时间
|
||||
DeleteTime int64 `gorm:"comment:'删除时间'"` // 删除时间
|
||||
UpdateTime core.TsTime `gorm:"autoUpdateTime;comment:'更新时间'"` // 更新时间
|
||||
CreateTime core.TsTime `gorm:"autoCreateTime;comment:'创建时间'"` // 创建时间
|
||||
DeleteTime core.TsTime `gorm:"default:null;comment:'删除时间'"` // 删除时间
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package common_model
|
||||
|
||||
import "x_admin/core"
|
||||
|
||||
//Album 相册实体
|
||||
type Album struct {
|
||||
ID uint `gorm:"primarykey;comment:'主键ID'"`
|
||||
@@ -11,10 +13,10 @@ type Album struct {
|
||||
Uri string `gorm:"not null;comment:'文件路径'"`
|
||||
Ext string `gorm:"not null;default:'';comment:'文件扩展'"`
|
||||
Size int64 `gorm:"not null;default:0;comment:文件大小"`
|
||||
IsDelete uint8 `gorm:"not null;default:0;comment:'是否删除: 0=否, 1=是'"`
|
||||
CreateTime int64 `gorm:"autoCreateTime;not null;comment:'创建时间'"`
|
||||
UpdateTime int64 `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
|
||||
DeleteTime int64 `gorm:"not null;default:0;comment:'删除时间'"`
|
||||
IsDelete uint8 `gorm:"not null;default:0;softDelete:flag,DeletedAtField:DeleteTime;comment:'是否删除: 0=否, 1=是'"`
|
||||
CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
|
||||
UpdateTime core.TsTime `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
|
||||
DeleteTime core.TsTime `gorm:"default:null;comment:'删除时间'"`
|
||||
}
|
||||
|
||||
//AlbumCate 相册分类实体
|
||||
@@ -23,8 +25,8 @@ type AlbumCate struct {
|
||||
Pid uint `gorm:"not null;default:0;comment:'父级ID'"`
|
||||
Type int `gorm:"not null;default:10;comment:'文件类型: [10=图片, 20=视频]''"`
|
||||
Name string `gorm:"not null;default:'';comment:'分类名称''"`
|
||||
IsDelete uint8 `gorm:"not null;default:0;comment:'是否删除: 0=否, 1=是'"`
|
||||
CreateTime int64 `gorm:"autoCreateTime;not null;comment:'创建时间'"`
|
||||
UpdateTime int64 `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
|
||||
DeleteTime int64 `gorm:"not null;default:0;comment:'删除时间'"`
|
||||
IsDelete uint8 `gorm:"not null;default:0;softDelete:flag,DeletedAtField:DeleteTime;comment:'是否删除: 0=否, 1=是'"`
|
||||
CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
|
||||
UpdateTime core.TsTime `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
|
||||
DeleteTime core.TsTime `gorm:"default:null;comment:'删除时间'"`
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package model
|
||||
|
||||
import "x_admin/core"
|
||||
|
||||
//FlowApply 申请流程实体
|
||||
type FlowApply struct {
|
||||
Id int `gorm:"primarykey;comment:''"` //
|
||||
@@ -15,7 +17,7 @@ type FlowApply struct {
|
||||
FormValue string `gorm:"comment:'表单值'"` // 表单值
|
||||
Status int `gorm:"comment:'状态:1待提交,2审批中,3审批完成,4审批失败'"` // 状态:0待提交,1审批中,2审批完成,3审批失败
|
||||
IsDelete int `gorm:"comment:'是否删除'"` // 是否删除
|
||||
UpdateTime int64 `gorm:"autoUpdateTime;comment:'更新时间'"` // 更新时间
|
||||
CreateTime int64 `gorm:"autoCreateTime;comment:'创建时间'"` // 创建时间
|
||||
DeleteTime int64 `gorm:"comment:'删除时间'"` // 删除时间
|
||||
UpdateTime core.TsTime `gorm:"autoUpdateTime;comment:'更新时间'"` // 更新时间
|
||||
CreateTime core.TsTime `gorm:"autoCreateTime;comment:'创建时间'"` // 创建时间
|
||||
DeleteTime core.TsTime `gorm:"default:null;comment:'删除时间'"` // 删除时间
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package model
|
||||
|
||||
import "x_admin/core"
|
||||
|
||||
//FlowHistory 流程历史实体
|
||||
type FlowHistory struct {
|
||||
Id int `gorm:"primarykey;comment:'历史id'"` // 历史id
|
||||
@@ -26,10 +28,10 @@ type FlowHistory struct {
|
||||
|
||||
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:'删除时间'"` // 删除时间
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package model
|
||||
|
||||
import "x_admin/core"
|
||||
|
||||
//FlowTemplate 流程模板实体
|
||||
type FlowTemplate struct {
|
||||
Id int `gorm:"primarykey;comment:''"` //
|
||||
@@ -9,4 +11,9 @@ type FlowTemplate struct {
|
||||
FlowFormData string `gorm:"comment:'表单配置'"` // 表单配置
|
||||
FlowProcessData string `gorm:"comment:'流程配置'"` // 流程配置
|
||||
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:'删除时间'"` // 删除时间
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package gen_model
|
||||
|
||||
import "x_admin/core"
|
||||
|
||||
//GenTable 代码生成业务实体
|
||||
type GenTable struct {
|
||||
ID uint `gorm:"primarykey;comment:'主键'"`
|
||||
@@ -17,8 +19,8 @@ type GenTable struct {
|
||||
GenTpl string `gorm:"not null;default:'crud';comment:'生成模板方式: [crud=单表, tree=树表]'"`
|
||||
|
||||
Remarks string `gorm:"not null;default:'';comment:'备注信息'"`
|
||||
CreateTime int64 `gorm:"autoCreateTime;not null;comment:'创建时间'"`
|
||||
UpdateTime int64 `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
|
||||
CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
|
||||
UpdateTime core.TsTime `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
|
||||
}
|
||||
|
||||
//GenTableColumn 代码生成表列实体
|
||||
@@ -42,6 +44,6 @@ type GenTableColumn struct {
|
||||
HtmlType string `gorm:"not null;default:'';comment:'显示类型: [文本框、文本域、下拉框、复选框、单选框、日期控件]'"`
|
||||
DictType string `gorm:"not null;default:'';comment:'字典类型'"`
|
||||
Sort int `gorm:"not null;default:0;comment:'排序编号'"`
|
||||
CreateTime int64 `gorm:"autoCreateTime;not null;comment:'创建时间'"`
|
||||
UpdateTime int64 `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
|
||||
CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
|
||||
UpdateTime core.TsTime `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package model
|
||||
|
||||
import "x_admin/core"
|
||||
|
||||
//MonitorClient 客户端信息实体
|
||||
type MonitorClient struct {
|
||||
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记录
|
||||
|
||||
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:创建时间;"` // 创建时间
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package model
|
||||
|
||||
import "x_admin/core"
|
||||
|
||||
//MonitorProject 错误项目实体
|
||||
type MonitorProject struct {
|
||||
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=是
|
||||
|
||||
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:删除时间;"` // 删除时间
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package model
|
||||
|
||||
import "x_admin/core"
|
||||
|
||||
//MonitorWeb 错误收集error实体
|
||||
type MonitorWeb struct {
|
||||
Id int `gorm:"primarykey;comment:'uuid'" excel:"name:uuid;"` // uuid
|
||||
@@ -16,8 +18,8 @@ type MonitorWeb struct {
|
||||
|
||||
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:创建时间;"` // 创建时间
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package setting_model
|
||||
|
||||
import "x_admin/core"
|
||||
|
||||
//DictData 字典数据实体
|
||||
type DictData struct {
|
||||
ID uint `gorm:"primarykey;comment:'主键'"`
|
||||
@@ -11,7 +13,7 @@ type DictData struct {
|
||||
Sort uint16 `gorm:"not null;default:0;comment:'排序'"`
|
||||
Status uint8 `gorm:"not null;default:1;comment:'字典状态: 0=停用, 1=正常'"`
|
||||
IsDelete uint8 `gorm:"not null;default:0;comment:'是否删除: 0=否, 1=是'"`
|
||||
CreateTime int64 `gorm:"autoCreateTime;not null;comment:'创建时间'"`
|
||||
UpdateTime int64 `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
|
||||
DeleteTime int64 `gorm:"not null;default:0;comment:'删除时间'"`
|
||||
CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
|
||||
UpdateTime core.TsTime `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
|
||||
DeleteTime core.TsTime `gorm:"default:null;comment:'删除时间'"`
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package setting_model
|
||||
|
||||
import "x_admin/core"
|
||||
|
||||
//DictType 字典类型实体
|
||||
type DictType struct {
|
||||
ID uint `gorm:"primarykey;comment:'主键'"`
|
||||
@@ -8,7 +10,7 @@ type DictType struct {
|
||||
DictRemark string `gorm:"not null;default:'';comment:'字典备注'"`
|
||||
DictStatus uint8 `gorm:"not null;default:1;comment:'字典状态: 0=停用, 1=正常'"`
|
||||
IsDelete uint8 `gorm:"not null;default:0;comment:'是否删除: 0=否, 1=是'"`
|
||||
CreateTime int64 `gorm:"autoCreateTime;not null;comment:'创建时间'"`
|
||||
UpdateTime int64 `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
|
||||
DeleteTime int64 `gorm:"not null;default:0;comment:'删除时间'"`
|
||||
CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
|
||||
UpdateTime core.TsTime `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
|
||||
DeleteTime core.TsTime `gorm:"default:null;comment:'删除时间'"`
|
||||
}
|
||||
|
@@ -1,16 +1,22 @@
|
||||
package system_model
|
||||
|
||||
//SystemConfig 系统配置实体
|
||||
import (
|
||||
"x_admin/core"
|
||||
|
||||
"gorm.io/plugin/soft_delete"
|
||||
)
|
||||
|
||||
// SystemConfig 系统配置实体
|
||||
type SystemConfig struct {
|
||||
ID uint `gorm:"primarykey;comment:'主键'"`
|
||||
Type string `gorm:"default:'';comment:'类型''"`
|
||||
Name string `gorm:"not null;default:'';comment:'键'"`
|
||||
Value string `gorm:"type:text;not null;default:'';comment:'值'"`
|
||||
CreateTime int64 `gorm:"autoCreateTime;not null;comment:'创建时间'"`
|
||||
UpdateTime int64 `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
|
||||
CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
|
||||
UpdateTime core.TsTime `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
|
||||
}
|
||||
|
||||
//SystemAuthAdmin 系统管理员实体
|
||||
// SystemAuthAdmin 系统管理员实体
|
||||
type SystemAuthAdmin struct {
|
||||
ID uint `gorm:"primarykey;comment:'主键'"`
|
||||
DeptId uint `gorm:"not null;default:0;comment:'部门ID'"`
|
||||
@@ -23,15 +29,15 @@ type SystemAuthAdmin struct {
|
||||
Salt string `gorm:"not null;default:'';comment:'加密盐巴'"`
|
||||
Sort uint16 `gorm:"not null;default:0;comment:'排序编号'"`
|
||||
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'"`
|
||||
LastLoginTime int64 `gorm:"not null;default:0;comment:'最后登录时间'"`
|
||||
CreateTime int64 `gorm:"autoCreateTime;not null;comment:'创建时间'"`
|
||||
UpdateTime int64 `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
|
||||
DeleteTime int64 `gorm:"not null;default:0;comment:'删除时间'"`
|
||||
LastLoginTime core.TsTime `gorm:"not null;default:null;comment:'最后登录时间'"`
|
||||
CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
|
||||
UpdateTime core.TsTime `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
|
||||
DeleteTime core.TsTime `gorm:"default:null;comment:'删除时间'"`
|
||||
}
|
||||
|
||||
//SystemAuthMenu 系统菜单实体
|
||||
// SystemAuthMenu 系统菜单实体
|
||||
type SystemAuthMenu struct {
|
||||
ID uint `gorm:"primarykey;comment:'主键'"`
|
||||
Pid uint `gorm:"not null;default:0;comment:'上级菜单'"`
|
||||
@@ -46,30 +52,30 @@ type SystemAuthMenu struct {
|
||||
Params string `gorm:"not null;default:'';comment:'路由参数'"`
|
||||
IsCache uint8 `gorm:"not null;default:0;comment:'是否缓存: 0=否, 1=是''"`
|
||||
IsShow uint8 `gorm:"not null;default:1;comment:'是否显示: 0=否, 1=是'"`
|
||||
IsDisable uint8 `gorm:"not null;default:0;comment:'是否禁用: 0=否, 1=是'"`
|
||||
CreateTime int64 `gorm:"autoCreateTime;not null;comment:'创建时间'"`
|
||||
UpdateTime int64 `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
|
||||
IsDisable soft_delete.DeletedAt `gorm:"not null;default:0;comment:'是否禁用: 0=否, 1=是'"`
|
||||
CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
|
||||
UpdateTime core.TsTime `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
|
||||
}
|
||||
|
||||
//SystemAuthPerm 系统角色菜单实体
|
||||
// SystemAuthPerm 系统角色菜单实体
|
||||
type SystemAuthPerm struct {
|
||||
ID string `gorm:"primarykey;comment:'主键'"`
|
||||
RoleId uint `gorm:"not null;default:0;comment:'角色ID'"`
|
||||
MenuId uint `gorm:"not null;default:0;comment:'菜单ID'"`
|
||||
}
|
||||
|
||||
//SystemAuthRole 系统角色实体
|
||||
// SystemAuthRole 系统角色实体
|
||||
type SystemAuthRole struct {
|
||||
ID uint `gorm:"primarykey;comment:'主键'"`
|
||||
Name string `gorm:"not null;default:'';comment:'角色名称''"`
|
||||
Remark string `gorm:"not null;default:'';comment:'备注信息'"`
|
||||
IsDisable uint8 `gorm:"not null;default:0;comment:'是否禁用: 0=否, 1=是'"`
|
||||
Sort uint16 `gorm:"not null;default:0;comment:'角色排序'"`
|
||||
CreateTime int64 `gorm:"autoCreateTime;not null;comment:'创建时间'"`
|
||||
UpdateTime int64 `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
|
||||
CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
|
||||
UpdateTime core.TsTime `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
|
||||
}
|
||||
|
||||
//SystemAuthDept 系统部门实体
|
||||
// SystemAuthDept 系统部门实体
|
||||
type SystemAuthDept struct {
|
||||
ID uint `gorm:"primarykey;comment:'主键'"`
|
||||
Pid uint `gorm:"not null;default:0;comment:'上级主键'"`
|
||||
@@ -79,13 +85,13 @@ type SystemAuthDept struct {
|
||||
Mobile string `gorm:"null;default:'';comment:'联系电话'"`
|
||||
Sort uint16 `gorm:"not null;default:0;comment:'排序编号'"`
|
||||
IsStop 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:'创建时间'"`
|
||||
UpdateTime int64 `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
|
||||
DeleteTime int64 `gorm:"not null;default:0;comment:'删除时间'"`
|
||||
IsDelete soft_delete.DeletedAt `gorm:"not null;default:0;softDelete:flag,DeletedAtField:DeleteTime;comment:'是否删除: 0=否, 1=是'"`
|
||||
CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
|
||||
UpdateTime core.TsTime `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
|
||||
DeleteTime core.TsTime `gorm:"default:0;comment:'删除时间'"`
|
||||
}
|
||||
|
||||
//SystemAuthPost 系统岗位管理
|
||||
// SystemAuthPost 系统岗位管理
|
||||
type SystemAuthPost struct {
|
||||
ID uint `gorm:"primarykey;comment:'主键'"`
|
||||
Code string `gorm:"not null;default:'';comment:'岗位编码''"`
|
||||
@@ -93,13 +99,13 @@ type SystemAuthPost struct {
|
||||
Remarks string `gorm:"not null;default:'';comment:'岗位备注''"`
|
||||
Sort uint16 `gorm:"not null;default:0;comment:'岗位排序'"`
|
||||
IsStop 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:'创建时间'"`
|
||||
UpdateTime int64 `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
|
||||
DeleteTime int64 `gorm:"not null;default:0;comment:'删除时间'"`
|
||||
IsDelete soft_delete.DeletedAt `gorm:"not null;default:0;softDelete:flag,DeletedAtField:DeleteTime;comment:'是否删除: 0=否, 1=是'"`
|
||||
CreateTime core.TsTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
|
||||
UpdateTime core.TsTime `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
|
||||
DeleteTime core.TsTime `gorm:"default:null;comment:'删除时间'"`
|
||||
}
|
||||
|
||||
//SystemLogLogin 系统登录日志实体
|
||||
// SystemLogLogin 系统登录日志实体
|
||||
type SystemLogLogin struct {
|
||||
ID uint `gorm:"primarykey;comment:'主键'"`
|
||||
AdminId uint `gorm:"not null;default:0;comment:'管理员ID'"`
|
||||
@@ -108,10 +114,10 @@ type SystemLogLogin struct {
|
||||
Os string `gorm:"not null;default:'';comment:'操作系统'"`
|
||||
Browser string `gorm:"not null;default:'';comment:'浏览器'"`
|
||||
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 {
|
||||
ID uint `gorm:"primarykey;comment:'主键'"`
|
||||
AdminId uint `gorm:"not null;default:0;comment:'操作人ID'"`
|
||||
@@ -123,8 +129,8 @@ type SystemLogOperate struct {
|
||||
Args string `gorm:"comment:'请求参数'"`
|
||||
Error string `gorm:"comment:'错误信息'"`
|
||||
Status uint8 `gorm:"not null;default:0;comment:'执行状态: 1=成功, 2=失败'"`
|
||||
StartTime int64 `gorm:"not null;default:0;comment:'开始时间'"`
|
||||
EndTime int64 `gorm:"not null;default:0;comment:'结束时间'"`
|
||||
StartTime core.TsTime `gorm:"not null;default:0;comment:'开始时间'"`
|
||||
EndTime core.TsTime `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
1287
sql/x_admin - 副本.sql
Normal file
File diff suppressed because one or more lines are too long
864
sql/x_admin.sql
864
sql/x_admin.sql
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user