发布代码生成、更新20+表单组件,优化数据字典,gf版本更新到2.3.1

This commit is contained in:
孟帅
2023-01-18 16:23:39 +08:00
parent 50207ded90
commit 87c27a17a3
386 changed files with 27926 additions and 44297 deletions

View File

@@ -93,37 +93,38 @@ type MemberMaxSortModel struct {
Sort int
}
// MemberEditInp 修改/新增字典数据
// MemberEditInp 修改/新增管理员
type MemberEditInp struct {
Id int64 `json:"id" description:""`
PostIds []int64 `json:"postIds" v:"required#岗位不能为空" description:"岗位ID"`
DeptId int64 `json:"dept_id" v:"required#部门不能为空" description:"部门ID"`
Username string `json:"username" v:"required#账号不能为空" description:"帐号"`
Password string `json:"password" description:"密码"`
Realname string `json:"realname" description:"真实姓名"`
Avatar string `json:"avatar" description:"头像"`
Sex string `json:"sex" description:"性别[0:未知;1:男;2:女]"`
Qq string `json:"qq" description:"qq"`
Email string `json:"email" description:"邮箱"`
Birthday *gtime.Time `json:"birthday" description:"生日"`
ProvinceId int `json:"province_id" description:""`
CityId int `json:"city_id" description:"城市"`
AreaId int `json:"area_id" description:"地区"`
Address string `json:"address" description:"默认地址"`
Mobile string `json:"mobile" description:"手机号码"`
HomePhone string `json:"home_phone" description:"家庭号码"`
DingtalkRobotToken string `json:"dingtalk_robot_token" description:"钉钉机器人token"`
Role int `json:"role" v:"required#角色不能为空" description:"权限"`
Remark string `json:"remark" description:"备注"`
Status string `json:"status" description:"状态"`
CreatedAt *gtime.Time `json:"created_at" description:"创建时间"`
UpdatedAt *gtime.Time `json:"updated_at" description:"修改时间"`
Id int64 `json:"id" description:""`
RoleId int `json:"roleId" v:"required#角色不能为空" description:"角色ID"`
PostIds []int64 `json:"postIds" v:"required#岗位不能为空" description:"岗位ID"`
DeptId int64 `json:"deptId" v:"required#部门不能为空" description:"部门ID"`
Username string `json:"username" v:"required#账号不能为空" description:"帐号"`
Password string `json:"password" description:"密码"`
Realname string `json:"realName" description:"真实姓名"`
Avatar string `json:"avatar" description:"头像"`
Sex string `json:"sex" description:"性别"`
Qq string `json:"qq" description:"qq"`
Email string `json:"email" description:"邮箱"`
Birthday *gtime.Time `json:"birthday" description:"生日"`
ProvinceId int `json:"provinceId" description:""`
CityId int `json:"cityId" description:"城市"`
AreaId int `json:"areaId" description:"地区"`
Address string `json:"address" description:"默认地址"`
Mobile string `json:"mobile" description:"手机号码"`
Remark string `json:"remark" description:"备注"`
Status string `json:"status" description:"状态"`
CreatedAt *gtime.Time `json:"createdAt" description:"创建时间"`
UpdatedAt *gtime.Time `json:"updatedAt" description:"修改时间"`
}
type MemberAddInp struct {
MemberEditInp
PasswordHash string `json:"password_hash" description:"密码hash"`
PasswordHash string `json:"passwordHash" description:"密码hash"`
Salt string `json:"salt" description:"密码盐"`
Pid int64 `json:"pid" description:"上级ID"`
Level int `json:"level" description:"等级"`
Tree string `json:"tree" description:"关系树"`
}
type MemberEditModel struct{}
@@ -159,10 +160,10 @@ type MemberListInp struct {
type MemberListModel struct {
entity.AdminMember
DeptName string `json:"dept_name"`
RoleName string `json:"role_name"`
DeptName string `json:"deptName"`
RoleName string `json:"roleName"`
PostIds []int64 `json:"postIds"`
DeptId int64 `json:"dept_id" description:"部门ID"`
DeptId int64 `json:"deptId" description:"部门ID"`
}
// MemberLoginInp 登录
@@ -171,12 +172,12 @@ type MemberLoginInp struct {
Password string
}
type MemberLoginModel struct {
UserId int64 `json:"userId" description:"会员ID"`
Username string `json:"username" description:"用户名"`
RealName string `json:"realName" description:"昵称"`
Avatar string `json:"avatar" description:"头像"`
Token string `json:"token" v:"" description:"登录token"`
Permissions []MemberLoginPermissions `json:"permissions" description:"角色信息"`
UserId int64 `json:"userId" description:"会员ID"`
Username string `json:"username" description:"用户名"`
RealName string `json:"realName" description:"昵称"`
Avatar string `json:"avatar" description:"头像"`
Token string `json:"token" v:"" description:"登录token"`
Permissions []*MemberLoginPermissions `json:"permissions" description:"角色信息"`
}
// MemberLoginPermissions 登录用户角色信息

View File

@@ -14,8 +14,7 @@ import (
// RoleListInp 获取列表
type RoleListInp struct {
Page int64
PerPage int64
form.PageReq
}
type RoleListModel struct {
@@ -28,7 +27,7 @@ type RoleMemberListInp struct {
form.RangeDateReq
form.StatusReq
Role int `json:"role" description:"角色ID"`
DeptId int `json:"dept_id" description:"部门ID"`
DeptId int `json:"deptId" description:"部门ID"`
Mobile int `json:"mobile" description:"手机号"`
Username string `json:"username" description:"用户名"`
Realname string `json:"realname" description:"真实姓名"`
@@ -48,3 +47,9 @@ type MenuRoleListModel struct {
Menus []*model.LabelTreeMenu `json:"menus" description:"菜单列表"`
CheckedKeys []int64 `json:"checkedKeys" description:"选择的菜单ID"`
}
type DataScopeEditInp struct {
Id int64 `json:"id" v:"required" dc:"角色ID"`
DataScope int `json:"dataScope" v:"required" dc:"数据范围"`
CustomDept []int64 `json:"customDept" dc:"自定义部门权限"`
}

View File

@@ -0,0 +1,162 @@
// Package adminin
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2022 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
//
package adminin
import (
"context"
"errors"
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
"hotgo/internal/consts"
"hotgo/internal/model/entity"
"hotgo/internal/model/input/form"
"hotgo/utility/validate"
)
// TestEditInp 修改/新增
type TestEditInp struct {
entity.Test
}
type TestEditModel struct{}
func (in *TestEditInp) Filter(ctx context.Context) (err error) {
if in.Map.IsNil() {
in.Map = gjson.New(consts.NilJsonToString)
}
if in.Flag.IsNil() {
in.Flag = gjson.New(consts.NilJsonToString)
}
if in.Images.IsNil() {
in.Images = gjson.New(consts.NilJsonToString)
}
if in.Attachfiles.IsNil() {
in.Attachfiles = gjson.New(consts.NilJsonToString)
}
if in.Hobby.IsNil() {
in.Hobby = gjson.New(consts.NilJsonToString)
}
if in.Title == "" {
return errors.New("标题不能为空")
}
if in.Email != "" && !validate.IsEmail(in.Email) {
return errors.New("邮箱格式不正确")
}
if err := g.Validator().Rules("float|between:0,5").Messages("请输入一个浮点数|推荐星只能是0~5星").Data(in.Star).Run(ctx); err != nil {
return err.Current()
}
return
}
// TestDeleteInp 删除类型
type TestDeleteInp struct {
Id interface{} `json:"id" v:"required#测试ID不能为空" dc:"测试ID"`
}
type TestDeleteModel struct{}
// TestViewInp 获取信息
type TestViewInp struct {
Id int64 `json:"id" v:"required#测试ID不能为空" dc:"测试ID"`
}
type TestViewModel struct {
entity.Test
}
// TestListInp 获取列表
type TestListInp struct {
form.PageReq
Id int64 `json:"id" description:""`
Flag *gjson.Json `json:"flag" description:"标签"`
Title string `json:"title" description:"标题"`
Content string `json:"content" description:"内容"`
Price []float64 `json:"price" description:"价格"`
ActivityAt *gtime.Time `json:"activityAt" description:"活动时间"`
Switch int `json:"switch" description:"开关"`
Hobby *gjson.Json `json:"hobby" description:"爱好"`
Status int `json:"status" description:"状态"`
CreatedAt []*gtime.Time `json:"createdAt" description:"创建时间"`
}
type TestListModel struct {
entity.Test
TestCategoryName string `json:"testCategoryName" description:"分类名称"`
TestCategoryDescription string `json:"testCategoryDescription" description:"分类描述"`
TestCategoryRemark string `json:"testCategoryRemark" description:"分类备注"`
SysProvincesTitle string `json:"sysProvincesTitle" description:""`
}
func (in *TestListInp) Filter(ctx context.Context) (err error) {
if !in.Flag.IsNil() {
in.Flag = gjson.New(in.Flag.Var().Ints())
}
if !in.Hobby.IsNil() {
in.Hobby = gjson.New(in.Hobby.Var().Ints())
}
return
}
type TestExportModel struct {
Id int64 `json:"id" description:""`
CategoryId int64 `json:"categoryId" description:"分类ID"`
Flag *gjson.Json `json:"flag" description:"标签"`
Title string `json:"title" description:"标题"`
Star float64 `json:"star" description:"推荐星"`
Price float64 `json:"price" description:"价格"`
Views int64 `json:"views" description:"浏览次数"`
ActivityAt *gtime.Time `json:"activityAt" description:"活动时间"`
StartAt *gtime.Time `json:"startAt" description:"开启时间"`
EndAt *gtime.Time `json:"endAt" description:"结束时间"`
Switch int `json:"switch" description:"开关"`
Sort int `json:"sort" description:"排序"`
Avatar string `json:"avatar" description:"头像"`
Sex int `json:"sex" description:"性别"`
Qq string `json:"qq" description:"qq"`
Email string `json:"email" description:"邮箱"`
Mobile string `json:"mobile" description:"手机号码"`
Hobby *gjson.Json `json:"hobby" description:"爱好"`
Channel int `json:"channel" description:"渠道"`
Pid int64 `json:"pid" description:"上级ID"`
Level int `json:"level" description:"树等级"`
Tree string `json:"tree" description:"关系树"`
Remark string `json:"remark" description:"备注"`
Status int `json:"status" description:"状态"`
CreatedBy int64 `json:"createdBy" description:"创建者"`
UpdatedBy int64 `json:"updatedBy" description:"更新者"`
CreatedAt *gtime.Time `json:"createdAt" description:"创建时间"`
UpdatedAt *gtime.Time `json:"updatedAt" description:"修改时间"`
DeletedAt *gtime.Time `json:"deletedAt" description:"删除时间"`
}
// TestMaxSortInp 最大排序
type TestMaxSortInp struct{}
type TestMaxSortModel struct {
Sort int `json:"sort" description:"排序"`
}
// TestStatusInp 更新状态
type TestStatusInp struct {
Id int64 `json:"id" v:"required#测试ID不能为空" dc:"测试ID"`
Status int `json:"status" dc:"状态"`
}
type TestStatusModel struct{}
// TestSwitchInp 更新开关状态
type TestSwitchInp struct {
form.SwitchReq
Id int64 `json:"id" v:"required#测试ID不能为空" dc:"测试ID"`
}
type TestSwitchModel struct{}

View File

@@ -9,20 +9,21 @@ package form
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/util/gconv"
)
var (
page int64
pageSize int64
page int
pageSize int
)
// DefaultPageSize 列表分页默认加载页码
func DefaultPageSize(ctx context.Context) int64 {
func DefaultPageSize(ctx context.Context) int {
if pageSize > 0 {
return pageSize
}
defaultPageSize, _ := g.Cfg().Get(ctx, "hotgo.admin.defaultPageSize", 10)
pageSize = defaultPageSize.Int64()
defaultPageSize := g.Cfg().MustGet(ctx, "hotgo.admin.defaultPageSize", 10)
pageSize = defaultPageSize.Int()
if pageSize <= 0 {
pageSize = 10
}
@@ -30,26 +31,26 @@ func DefaultPageSize(ctx context.Context) int64 {
}
// DefaultPage 列表分页默认加载数量
func DefaultPage(ctx context.Context) int64 {
func DefaultPage(ctx context.Context) int {
if page > 0 {
return page
}
defaultPage, _ := g.Cfg().Get(ctx, "hotgo.admin.defaultPage", 1)
page = defaultPage.Int64()
defaultPage := g.Cfg().MustGet(ctx, "hotgo.admin.defaultPage", 1)
page = defaultPage.Int()
if page <= 0 {
page = 10
page = 1
}
return page
}
// PageReq 分页
type PageReq struct {
Page int64 `json:"page" example:"10" d:"1" v:"min:1#页码最小值不能低于1" dc:"当前页码"`
PerPage int64 `json:"pageSize" example:"1" d:"10" v:"min:1|max:100#|每页数量最小值不能低于1|最大值不能大于100" dc:"每页数量"`
Page int `json:"page" example:"10" d:"1" v:"min:1#页码最小值不能低于1" dc:"当前页码"`
PerPage int `json:"pageSize" example:"1" d:"10" v:"min:1|max:100#|每页数量最小值不能低于1|最大值不能大于100" dc:"每页数量"`
}
type PageRes struct {
PageReq
PageCount int64 `json:"pageCount" example:"0" dc:"全部数据量"`
PageCount int `json:"pageCount" example:"0" dc:"全部数据量"`
}
// RangeDateReq 时间查询
@@ -63,8 +64,14 @@ type StatusReq struct {
Status int `json:"status" v:"in:-1,0,1,2,3#输入的状态是无效的" dc:"状态"`
}
// SwitchReq 更新开关状态
type SwitchReq struct {
Key string `json:"key" v:"required#测试ID不能为空" dc:"开关字段"`
Value int `json:"value" v:"in:1,2#输入的开关值是无效的" dc:"更新值"`
}
// CalPage 解析分页
func CalPage(ctx context.Context, page, perPage int64) (newPage, newPerPage int64, offset int64) {
func CalPage(ctx context.Context, page, perPage int) (newPage, newPerPage int, offset int) {
if page <= 0 {
newPage = DefaultPage(ctx)
} else {
@@ -80,6 +87,31 @@ func CalPage(ctx context.Context, page, perPage int64) (newPage, newPerPage int6
return
}
func CalPageCount(totalCount int64, perPage int64) int64 {
func CalPageCount(totalCount int, perPage int) int {
return (totalCount + perPage - 1) / perPage
}
// Selects 选项
type Selects []*Select
type Select struct {
Value interface{} `json:"value"`
Label string `json:"label"`
Name string `json:"name"`
}
func (p Selects) Len() int {
return len(p)
}
func (p Selects) Swap(i, j int) {
p[i], p[j] = p[j], p[i]
}
func (p Selects) Less(i, j int) bool {
return gconv.Int64(p[j].Value) > gconv.Int64(p[i].Value)
}
type SelectInt64s []*SelectInt64
type SelectInt64 struct {
Value int64 `json:"value"`
Label string `json:"label"`
Name string `json:"name"`
}

View File

@@ -96,6 +96,6 @@ type ConfigListInp struct {
type ConfigListModel struct {
entity.SysConfig
DeptName string `json:"dept_name"`
RoleName string `json:"role_name"`
DeptName string `json:"deptName"`
RoleName string `json:"roleName"`
}

View File

@@ -0,0 +1,109 @@
// Package sysin
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.1.0
// @AutoGenerate Date 2023-01-18 15:19:42
//
package sysin
import (
"context"
"hotgo/internal/model/entity"
"hotgo/internal/model/input/form"
"github.com/gogf/gf/v2/os/gtime"
)
// CurdDemoEditInp 修改/新增生成演示
type CurdDemoEditInp struct {
entity.Test
}
func (in *CurdDemoEditInp) Filter(ctx context.Context) (err error) {
return
}
type CurdDemoEditModel struct{}
// CurdDemoDeleteInp 删除生成演示
type CurdDemoDeleteInp struct {
Id interface{} `json:"id" v:"required#ID不能为空" dc:"ID"`
}
type CurdDemoDeleteModel struct{}
// CurdDemoViewInp 获取指定生成演示信息
type CurdDemoViewInp struct {
Id int64 `json:"id" v:"required#ID不能为空" dc:"ID"`
}
type CurdDemoViewModel struct {
entity.Test
}
// CurdDemoListInp 获取生成演示列表
type CurdDemoListInp struct {
form.PageReq
Id int64 `json:"id" dc:"ID"`
Status int `json:"status" dc:"状态"`
CreatedAt []*gtime.Time `json:"createdAt" dc:"创建时间"`
TestCategoryName string `json:"testCategoryName" dc:"分类名称"`
}
type CurdDemoListModel struct {
Id int64 `json:"id" dc:"ID"`
CategoryId int64 `json:"categoryId" dc:"分类ID"`
Title string `json:"title" dc:"标题"`
Description string `json:"description" dc:"描述"`
Image string `json:"image" dc:"单图"`
Attachfile string `json:"attachfile" dc:"附件"`
Switch int `json:"switch" dc:"显示开关"`
Sort int `json:"sort" dc:"排序"`
Status int `json:"status" dc:"状态"`
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
TestCategoryName string `json:"testCategoryName" dc:"分类名称"`
}
func (in *CurdDemoListInp) Filter(ctx context.Context) (err error) {
return
}
// CurdDemoExportModel 导出生成演示
type CurdDemoExportModel struct {
Id int64 `json:"id" dc:"ID"`
CategoryId int64 `json:"categoryId" dc:"分类ID"`
Title string `json:"title" dc:"标题"`
Description string `json:"description" dc:"描述"`
Image string `json:"image" dc:"单图"`
Attachfile string `json:"attachfile" dc:"附件"`
Switch int `json:"switch" dc:"显示开关"`
Sort int `json:"sort" dc:"排序"`
Status int `json:"status" dc:"状态"`
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
TestCategoryName string `json:"testCategoryName" dc:"分类名称"`
}
// CurdDemoMaxSortInp 获取生成演示最大排序
type CurdDemoMaxSortInp struct{}
type CurdDemoMaxSortModel struct {
Sort int `json:"sort" description:"排序"`
}
// CurdDemoStatusInp 更新生成演示状态
type CurdDemoStatusInp struct {
Id int64 `json:"id" v:"required#ID不能为空" dc:"ID"`
Status int `json:"status" dc:"状态"`
}
type CurdDemoStatusModel struct{}
// CurdDemoSwitchInp 更新生成演示开关状态
type CurdDemoSwitchInp struct {
form.SwitchReq
Id int64 `json:"id" v:"required#ID不能为空" dc:"ID"`
}
type CurdDemoSwitchModel struct{}

View File

@@ -35,6 +35,23 @@ type DictDataListInp struct {
}
type DictDataListModel struct {
TypeID int64 `json:"typeId"`
TypeID int64 `json:"typeId"`
Key string `json:"key"`
entity.SysDictData
}
// DataSelectInp 获取指定字典选项
type DataSelectInp struct {
Type string
}
type DataSelectModel []*SelectData
type SelectData struct {
Key interface{} `json:"key"`
Label string `json:"label" description:"字典标签"`
Value interface{} `json:"value" description:"字典键值"`
ValueType string `json:"valueType" description:"键值数据类型string,int,uint,bool,datetime,date"`
Type string `json:"type" description:"字典类型"`
ListClass string `json:"listClass" description:"表格回显样式"`
}

View File

@@ -28,3 +28,9 @@ type DictTypeSelectInp struct {
}
type DictTypeSelectModel []g.Map
// DictTreeSelectInp 获取类型关系树选项
type DictTreeSelectInp struct {
}
type DictTreeSelectModel []g.Map

View File

@@ -0,0 +1,139 @@
// Package sysin
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2022 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
//
package sysin
import (
"hotgo/internal/model"
"hotgo/internal/model/entity"
"hotgo/internal/model/input/form"
)
// GenCodesMaxSortInp 最大排序
type GenCodesMaxSortInp struct {
Id int64
}
type GenCodesMaxSortModel struct {
Sort int
}
// GenCodesEditInp 修改/新增数据
type GenCodesEditInp struct {
entity.SysGenCodes
}
type GenCodesEditModel struct {
entity.SysGenCodes
}
// GenCodesDeleteInp 删除
type GenCodesDeleteInp struct {
Id interface{}
}
type GenCodesDeleteModel struct{}
// GenCodesViewInp 获取信息
type GenCodesViewInp struct {
Id int64
}
type GenCodesViewModel struct {
entity.SysGenCodes
}
// GenCodesListInp 获取列表
type GenCodesListInp struct {
form.PageReq
form.StatusReq
GenType int `json:"genType"`
VarName string `json:"varName"`
}
type GenCodesListModel struct {
entity.SysGenCodes
}
// GenCodesStatusInp 更新状态
type GenCodesStatusInp struct {
Id int64 `json:"id" description:"生成ID"`
Status int `json:"status" description:"生成状态"`
}
type GenCodesStatusModel struct{}
// GenCodesSelectsInp 选项
type GenCodesSelectsInp struct {
}
type GenCodesSelectsModel struct {
GenType form.Selects `json:"genType" dc:"生成类型"`
Db form.Selects `json:"db" dc:"数据库选项"`
Status form.Selects `json:"status" dc:"生成状态"`
LinkMode form.Selects `json:"linkMode" dc:"关联表方式"`
BuildMeth form.Selects `json:"buildMeth" dc:"生成方式"`
// 字段表格选项
FormMode form.Selects `json:"formMode" dc:"表单组件"`
FormRole form.Selects `json:"formRole" dc:"表单验证"`
DictMode DictTreeSelectModel `json:"dictMode" dc:"字典类型"`
WhereMode form.Selects `json:"whereMode" dc:"查询条件"`
}
// GenCodesTableSelectInp 数据库表选项
type GenCodesTableSelectInp struct {
Name string `json:"name" dc:"数据库配置名称"`
}
type GenCodesTableSelectModel struct {
Value string `json:"value"`
Label string `json:"label"`
Name string `json:"name"`
DaoName string `json:"daoName" dc:"orm模型名称"`
DefVarName string `json:"defVarName" dc:"默认实体名称"`
DefAlias string `json:"defAlias" dc:"默认关联表别名"`
DefTableComment string `json:"defTableComment" dc:"默认菜单名称"`
}
// GenCodesColumnSelectInp 表字段选项
type GenCodesColumnSelectInp struct {
Name string `json:"name" dc:"数据库配置名称"`
Table string `json:"table" dc:"表名称"`
}
type GenCodesColumnSelectModel struct {
Value string `json:"value"`
Label string `json:"label"`
Name string `json:"name"`
}
// GenCodesColumnListInp 表字段列表
type GenCodesColumnListInp struct {
Name string `json:"name" dc:"数据库配置名称"`
Table string `json:"table" dc:"表名称"`
IsLink int64 `json:"isLink" dc:"是否是关联表"`
Alias string `json:"alias" dc:"关联表别名"`
}
type GenCodesColumnListModel struct {
model.GenCodesColumn
}
// GenCodesPreviewInp 生成预览
type GenCodesPreviewInp struct {
entity.SysGenCodes
}
// GenFile 生成文件配置
type GenFile struct {
Content string `json:"content" dc:"页面内容"`
Path string `json:"path" dc:"生成路径"`
Meth int `json:"meth" dc:"生成方式"`
Required bool `json:"required" dc:"是否是必要构建文件"`
}
type GenCodesPreviewModel struct {
Config *model.GenerateConfig `json:"config"`
Views map[string]*GenFile `json:"views" dc:"页面"`
}
// GenCodesBuildInp 提交生成
type GenCodesBuildInp struct {
entity.SysGenCodes
}