调整整体架构写法

调整db用法
调整日志用法
调整模版
This commit is contained in:
linwenxiang committed 2021-03-04 23:45:16 +08:00
1 parent 734a48dbb8
commit e2952fa393
137 files changed
+3638 -3544

No files matched your search

+1 -1
View File
@@ -2,9 +2,9 @@ package dto
import (
"github.com/gin-gonic/gin"
log "github.com/go-admin-team/go-admin-core/logger"
"go-admin/app/admin/models"
"go-admin/common/dto"
"go-admin/common/log"
common "go-admin/common/models"
"go-admin/tools"
)
+1 -1
View File
@@ -4,9 +4,9 @@ import (
"encoding/json"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
log "github.com/go-admin-team/go-admin-core/logger"
"go-admin/app/admin/models/system"
"go-admin/common/dto"
"go-admin/common/log"
common "go-admin/common/models"
"go-admin/tools"
)
+92
View File
@@ -0,0 +1,92 @@
package dto
import (
"github.com/gin-gonic/gin"
log "github.com/go-admin-team/go-admin-core/logger"
"go-admin/app/admin/models"
"go-admin/common/dto"
common "go-admin/common/models"
"go-admin/tools"
)
type SysContentSearch struct {
dto.Pagination `search:"-"`
}
func (m *SysContentSearch) GetNeedSearch() interface{} {
return *m
}
func (m *SysContentSearch) Bind(ctx *gin.Context) error {
msgID := tools.GenerateMsgIDFromContext(ctx)
err := ctx.ShouldBind(m)
if err != nil {
log.Debugf("MsgID[%s] ShouldBind error: %s", msgID, err.Error())
}
return err
}
func (m *SysContentSearch) Generate() dto.Index {
o := *m
return &o
}
type SysContentControl struct {
ID int `uri:"ID" comment:""` //
CateId string `json:"cateId" comment:""`
Name string `json:"name" comment:""`
Status string `json:"status" comment:""`
Img string `json:"img" comment:""`
Content string `json:"content" comment:""`
Remark string `json:"remark" comment:""`
Sort string `json:"sort" comment:""`
}
func (s *SysContentControl) Bind(ctx *gin.Context) error {
msgID := tools.GenerateMsgIDFromContext(ctx)
err := ctx.ShouldBindUri(s)
if err != nil {
log.Debugf("MsgID[%s] ShouldBindUri error: %s", msgID, err.Error())
return err
}
err = ctx.ShouldBind(s)
if err != nil {
log.Debugf("MsgID[%s] ShouldBind error: %#v", msgID, err.Error())
}
return err
}
func (s *SysContentControl) Generate() dto.Control {
cp := *s
return &cp
}
func (s *SysContentControl) GenerateM() (common.ActiveRecord, error) {
return &models.SysContent{
Id: s.ID,
CateId: s.CateId,
Name: s.Name,
Status: s.Status,
Img: s.Img,
Content: s.Content,
Remark: s.Remark,
Sort: s.Sort,
}, nil
}
func (s *SysContentControl) GetId() interface{} {
return s.ID
}
type SysContentById struct {
dto.ObjectById
}
func (s *SysContentById) Generate() dto.Control {
cp := *s
return &cp
}
func (s *SysContentById) GenerateM() (common.ActiveRecord, error) {
return &models.SysContent{}, nil
}
+6 -6
View File
@@ -4,9 +4,9 @@ import (
"encoding/json"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"go-admin/app/admin/models"
log "github.com/go-admin-team/go-admin-core/logger"
"go-admin/app/admin/models/system"
"go-admin/common/dto"
"go-admin/common/log"
"go-admin/tools"
)
@@ -73,8 +73,8 @@ func (s *SysDeptControl) Bind(ctx *gin.Context) error {
}
// Generate 结构体数据转化 从 SysConfigControl 至 system.SysConfig 对应的模型
func (s *SysDeptControl) Generate() (*models.SysDept, error) {
return &models.SysDept{
func (s *SysDeptControl) Generate() (*system.SysDept, error) {
return &system.SysDept{
DeptId: s.DeptId,
DeptName: s.DeptName,
ParentId: s.ParentId,
@@ -121,8 +121,8 @@ func (s *SysDeptById) Bind(ctx *gin.Context) error {
return err
}
func (s *SysDeptById) GenerateM() (*models.SysDept, error) {
return &models.SysDept{}, nil
func (s *SysDeptById) GenerateM() (*system.SysDept, error) {
return &system.SysDept{}, nil
}
type DeptLabel struct {
+1 -1
View File
@@ -4,9 +4,9 @@ import (
"github.com/gin-gonic/gin"
"net/http"
log "github.com/go-admin-team/go-admin-core/logger"
"go-admin/app/admin/models/system"
"go-admin/common/dto"
"go-admin/common/log"
common "go-admin/common/models"
"go-admin/tools"
)
+1 -1
View File
@@ -4,8 +4,8 @@ import (
"github.com/gin-gonic/gin"
"go-admin/app/admin/models/system"
log "github.com/go-admin-team/go-admin-core/logger"
"go-admin/common/dto"
"go-admin/common/log"
common "go-admin/common/models"
"go-admin/tools"
)
+1 -1
View File
@@ -1,9 +1,9 @@
package dto
import (
log "github.com/go-admin-team/go-admin-core/logger"
"go-admin/app/admin/models"
"go-admin/common/dto"
"go-admin/common/log"
common "go-admin/common/models"
"go-admin/tools"
+1 -1
View File
@@ -3,9 +3,9 @@ package dto
import (
"github.com/gin-gonic/gin"
log "github.com/go-admin-team/go-admin-core/logger"
"go-admin/app/admin/models"
"go-admin/common/dto"
"go-admin/common/log"
common "go-admin/common/models"
)
+1 -1
View File
@@ -2,9 +2,9 @@ package dto
import (
"github.com/gin-gonic/gin"
log "github.com/go-admin-team/go-admin-core/logger"
"go-admin/app/admin/models/system"
"go-admin/common/dto"
"go-admin/common/log"
common "go-admin/common/models"
"go-admin/tools"
+7 -7
View File
@@ -4,9 +4,9 @@ import (
"encoding/json"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"go-admin/app/admin/models"
log "github.com/go-admin-team/go-admin-core/logger"
"go-admin/app/admin/models/system"
"go-admin/common/dto"
"go-admin/common/log"
"go-admin/tools"
)
@@ -79,8 +79,8 @@ func (s *SysMenuControl) Bind(ctx *gin.Context) error {
}
// Generate 结构体数据转化 从 SysConfigControl 至 system.SysConfig 对应的模型
func (s *SysMenuControl) Generate() (*models.SysMenu, error) {
return &models.SysMenu{
func (s *SysMenuControl) Generate() (*system.SysMenu, error) {
return &system.SysMenu{
MenuId: s.MenuId,
MenuName: s.MenuName,
Title: s.Title,
@@ -134,8 +134,8 @@ func (s *SysMenuById) Bind(ctx *gin.Context) error {
return err
}
func (s *SysMenuById) GenerateM() (*models.SysMenu, error) {
return &models.SysMenu{}, nil
func (s *SysMenuById) GenerateM() (*system.SysMenu, error) {
return &system.SysMenu{}, nil
}
type MenuLabel struct {
@@ -145,6 +145,6 @@ type MenuLabel struct {
}
type MenuRole struct {
models.SysMenus
system.SysMenus
IsSelect bool `json:"is_select" gorm:"-"`
}
+1 -1
View File
@@ -2,9 +2,9 @@ package dto
import (
"github.com/gin-gonic/gin"
log "github.com/go-admin-team/go-admin-core/logger"
"go-admin/app/admin/models/system"
"go-admin/common/dto"
"go-admin/common/log"
common "go-admin/common/models"
"go-admin/tools"
+2 -2
View File
@@ -4,9 +4,9 @@ import (
"encoding/json"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
log "github.com/go-admin-team/go-admin-core/logger"
"go-admin/app/admin/models/system"
"go-admin/common/dto"
"go-admin/common/log"
"go-admin/tools"
)
@@ -74,7 +74,7 @@ func (s *SysPostControl) Generate() (*system.SysPost, error) {
PostCode: s.PostCode,
Sort: s.Sort,
Status: s.Status,
Remark: s.Remark,
Remark: s.Remark,
}, nil
}
+7 -4
View File
@@ -4,10 +4,9 @@ import (
"encoding/json"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"go-admin/app/admin/models"
log "github.com/go-admin-team/go-admin-core/logger"
"go-admin/app/admin/models/system"
"go-admin/common/dto"
"go-admin/common/log"
"go-admin/tools"
)
@@ -110,8 +109,8 @@ func (s *SysRoleById) GetId() interface{} {
return s.Id
}
func (s *SysRoleById) GenerateM() (*models.SysRole, error) {
return &models.SysRole{}, nil
func (s *SysRoleById) GenerateM() (*system.SysRole, error) {
return &system.SysRole{}, nil
}
// RoleDataScopeReq 角色数据权限修改
@@ -120,3 +119,7 @@ type RoleDataScopeReq struct {
DataScope string `json:"dataScope" binding:"required"`
DeptIds []int `json:"deptIds"`
}
type DeptIdList struct {
DeptId int `json:"DeptId"`
}
+1 -1
View File
@@ -3,8 +3,8 @@ package dto
import (
"encoding/json"
"github.com/gin-gonic/gin"
log "github.com/go-admin-team/go-admin-core/logger"
"go-admin/app/admin/models"
"go-admin/common/log"
"go-admin/tools"
)
+117
View File
@@ -0,0 +1,117 @@
package dto
import (
"github.com/gin-gonic/gin"
"go-admin/app/admin/models/system"
"go-admin/common/dto"
common "go-admin/common/models"
"go-admin/pkg/logger"
)
type SysUserSearch struct {
dto.Pagination `search:"-"`
UserId int `form:"UserId" search:"type:exact;column:user_id;table:sys_user" comment:"用户ID"`
Username string `form:"username" search:"type:contains;column:username;table:sys_user" comment:"用户名"`
NickName string `form:"nickName" search:"type:contains;column:nick_name;table:sys_user" comment:"昵称"`
Phone string `form:"phone" search:"type:contains;column:phone;table:sys_user" comment:"手机号"`
RoleId string `form:"roleId" search:"type:exact;column:role_id;table:sys_user" comment:"角色ID"`
Sex string `form:"sex" search:"type:exact;column:sex;table:sys_user" comment:"性别"`
Email string `form:"email" search:"type:contains;column:email;table:sys_user" comment:"邮箱"`
DeptId string `form:"deptId" search:"type:exact;column:dept_id;table:sys_user" comment:"部门"`
PostId string `form:"postId" search:"type:exact;column:post_id;table:sys_user" comment:"岗位"`
Status string `form:"status" search:"type:exact;column:status;table:sys_user" comment:"状态"`
}
func (m *SysUserSearch) GetNeedSearch() interface{} {
return *m
}
func (m *SysUserSearch) Bind(ctx *gin.Context) error {
log := logger.GetRequestLogger(ctx)
err := ctx.ShouldBind(m)
if err != nil {
log.Debugf("ShouldBind error: %s", err.Error())
}
return err
}
func (m *SysUserSearch) Generate() dto.Index {
o := *m
return &o
}
type SysUserControl struct {
UserId int `json:"userId" comment:"用户ID"` // 用户ID
Username string `json:"username" comment:"用户名"`
Password string `json:"password" comment:"密码"`
NickName string `json:"nickName" comment:"昵称"`
Phone string `json:"phone" comment:"手机号"`
RoleId int `json:"roleId" comment:"角色ID"`
Avatar string `json:"avatar" comment:"头像"`
Sex string `json:"sex" comment:"性别"`
Email string `json:"email" comment:"邮箱"`
DeptId int `json:"deptId" comment:"部门"`
PostId int `json:"postId" comment:"岗位"`
Remark string `json:"remark" comment:"备注"`
Status string `json:"status" comment:"状态"`
}
func (s *SysUserControl) Bind(ctx *gin.Context) error {
log := logger.GetRequestLogger(ctx)
//err := ctx.ShouldBindUri(s)
//if err != nil {
// log.Debugf("MsgID[%s] ShouldBindUri error: %s", msgID, err.Error())
// return err
//}
err := ctx.ShouldBind(s)
if err != nil {
log.Debugf("ShouldBind error: %s", err.Error())
}
return err
}
func (s *SysUserControl) Generate() dto.Control {
cp := *s
return &cp
}
func (s *SysUserControl) GenerateM() (common.ActiveRecord, error) {
return &system.SysUser{
UserId: s.UserId,
Username: s.Username,
Password: s.Password,
NickName: s.NickName,
Phone: s.Phone,
RoleId: s.RoleId,
Avatar: s.Avatar,
Sex: s.Sex,
Email: s.Email,
DeptId: s.DeptId,
PostId: s.PostId,
Remark: s.Remark,
Status: s.Status,
}, nil
}
func (s *SysUserControl) GetId() interface{} {
return s.UserId
}
type SysUserById struct {
dto.ObjectById
}
func (s *SysUserById) Generate() dto.Control {
cp := *s
return &cp
}
func (s *SysUserById) GenerateM() (common.ActiveRecord, error) {
return &system.SysUser{}, nil
}
// PassWord 密码
type PassWord struct {
Password string `json:"password"`
}