fix 角色授权模式修改,数据权限修改,代码生成bug修复

This commit is contained in:
yxh 2024-04-12 17:13:53 +08:00
parent e3b1b0fe34
commit b0034fad8e
30 changed files with 627 additions and 289 deletions

View File

@ -93,34 +93,42 @@ type RoleDeleteRes struct {
type RoleDeptTreeSelectReq struct {
g.Meta `path:"/role/deptTreeSelect" tags:"系统后台/角色管理" method:"get" summary:"获取部门树"`
commonApi.Author
RoleId int64 `p:"roleId" v:"required#角色id必须"`
}
type RoleDeptTreeSelectRes struct {
g.Meta `mime:"application/json"`
Depts []*model.SysDeptTreeRes `json:"depts"`
CheckedKeys []int64 `json:"checkedKeys"`
}
type RoleMenuTreeSelectReq struct {
g.Meta `path:"/role/menuTreeSelect" tags:"系统后台/角色管理" method:"get" summary:"获取菜单树"`
commonApi.Author
RoleId int64 `p:"roleId" v:"required#角色id必须"`
RoleId uint `p:"roleId" v:"required#角色id必须"`
}
type RoleMenuTreeSelectRes struct {
g.Meta `mime:"application/json"`
Rules []*model.SysAuthRuleTreeRes `json:"rules"`
DataScope []*model.ScopeAuthData `json:"dataScope"`
}
// DataScopeReq 角色数据授权参数
type DataScopeReq struct {
g.Meta `path:"/role/dataScope" tags:"系统后台/角色管理" method:"put" summary:"角色数据授权"`
RoleId uint `p:"roleId" v:"required#角色ID不能为空"`
DataScope uint `p:"dataScope" v:"required#权限范围不能为空"`
DeptIds []uint `p:"deptIds"`
AuthData []*model.ScopeAuthDataReq `p:"authData"`
}
type DataScopeRes struct {
commonApi.EmptyRes
}
type SetRoleUserReq struct {
g.Meta `path:"/role/setRoleUser" tags:"系统后台/角色管理" method:"put" summary:"角色用户授权"`
RoleId uint `p:"roleId" v:"required#角色ID不能为空"`
UserIds []uint64 `p:"userIds"`
}
type SetRoleUserRes struct {
commonApi.EmptyRes
}

View File

@ -124,6 +124,16 @@ type UserDeleteReq struct {
type UserDeleteRes struct {
}
type UsersRoleIdReq struct {
g.Meta `path:"/user/getByRoleId" tags:"系统后台/用户管理" method:"get" summary:"获取角色对应用户"`
RoleId uint `p:"roleId"`
}
type UsersRoleIdRes struct {
commonApi.EmptyRes
UserList []*model.SysUserRoleDeptRes `json:"userList"`
}
type UserSelectorReq struct {
g.Meta `path:"/user/selector" tags:"系统后台/用户管理" method:"get" summary:"获取用户选择器"`
DeptId string `p:"deptId"` //部门id

View File

@ -7,4 +7,9 @@ const (
SysNoticeType = 1
// SysLetterType 系统私信
SysLetterType = 2
// EffectiveTypeStartEnd 按起止时间段
EffectiveTypeStartEnd = 1
// EffectiveTypeDate 按时间段
EffectiveTypeDate = 2
)

View File

@ -72,7 +72,7 @@ func (c *roleController) Delete(ctx context.Context, req *system.RoleDeleteReq)
// DeptTreeSelect 获取角色授权部门数据
func (c *roleController) DeptTreeSelect(ctx context.Context, req *system.RoleDeptTreeSelectReq) (res *system.RoleDeptTreeSelectRes, err error) {
res, err = service.SysRole().RoleDeptTreeSelect(ctx, req.RoleId)
res, err = service.SysRole().RoleDeptTreeSelect(ctx)
return
}
@ -83,7 +83,11 @@ func (c *roleController) MenuTreeSelect(ctx context.Context, req *system.RoleMen
Rules: make([]*model.SysAuthRuleTreeRes, 0),
}
list, err = service.SysAuthRule().GetMenuListSearch(ctx, &system.RuleSearchReq{})
if err != nil {
return
}
res.Rules = service.SysAuthRule().GetMenuListTree(0, list)
res.DataScope, err = service.SysRole().GetRoleDataScope(ctx, req.RoleId)
return
}
@ -92,3 +96,8 @@ func (c *roleController) RoleDataScope(ctx context.Context, req *system.DataScop
err = service.SysRole().RoleDataScope(ctx, req)
return
}
func (s *roleController) SetRoleUsers(ctx context.Context, req *system.SetRoleUserReq) (res *system.SetRoleUserRes, err error) {
err = service.SysUser().SetUserRole(ctx, req.RoleId, req.UserIds)
return
}

View File

@ -49,6 +49,13 @@ func (c *userController) List(ctx context.Context, req *system.UserSearchReq) (r
return
}
// GetUsersByRoleId 通过角色id获取用户数据
func (c *userController) GetUsersByRoleId(ctx context.Context, req *system.UsersRoleIdReq) (res *system.UsersRoleIdRes, err error) {
res = new(system.UsersRoleIdRes)
res.UserList, err = service.SysUser().GetUsersByRoleId(ctx, req.RoleId)
return
}
// GetParams 获取用户维护相关参数
func (c *userController) GetParams(ctx context.Context, req *system.UserGetParamsReq) (res *system.UserGetParamsRes, err error) {
res = new(system.UserGetParamsRes)

View File

@ -1,75 +0,0 @@
// ==========================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// SysRoleDeptDao is the data access object for table sys_role_dept.
type SysRoleDeptDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of current DAO.
columns SysRoleDeptColumns // columns contains all the column names of Table for convenient usage.
}
// SysRoleDeptColumns defines and stores column names for table sys_role_dept.
type SysRoleDeptColumns struct {
RoleId string // 角色ID
DeptId string // 部门ID
}
// sysRoleDeptColumns holds the columns for table sys_role_dept.
var sysRoleDeptColumns = SysRoleDeptColumns{
RoleId: "role_id",
DeptId: "dept_id",
}
// NewSysRoleDeptDao creates and returns a new DAO object for table data access.
func NewSysRoleDeptDao() *SysRoleDeptDao {
return &SysRoleDeptDao{
group: "default",
table: "sys_role_dept",
columns: sysRoleDeptColumns,
}
}
// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *SysRoleDeptDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of current dao.
func (dao *SysRoleDeptDao) Table() string {
return dao.table
}
// Columns returns all column names of current dao.
func (dao *SysRoleDeptDao) Columns() SysRoleDeptColumns {
return dao.columns
}
// Group returns the configuration group name of database of current dao.
func (dao *SysRoleDeptDao) Group() string {
return dao.group
}
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *SysRoleDeptDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *SysRoleDeptDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -0,0 +1,81 @@
// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// SysRoleScopeDao is the data access object for table sys_role_scope.
type SysRoleScopeDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of current DAO.
columns SysRoleScopeColumns // columns contains all the column names of Table for convenient usage.
}
// SysRoleScopeColumns defines and stores column names for table sys_role_scope.
type SysRoleScopeColumns struct {
Id string // ID
RoleId string // 角色id
MenuId string // api接口id
DataScope string // 数据范围1全部数据权限 2自定数据权限 3本部门数据权限 4本部门及以下数据权限
DeptIds string // 扩展数据
}
// sysRoleScopeColumns holds the columns for table sys_role_scope.
var sysRoleScopeColumns = SysRoleScopeColumns{
Id: "id",
RoleId: "role_id",
MenuId: "menu_id",
DataScope: "data_scope",
DeptIds: "dept_ids",
}
// NewSysRoleScopeDao creates and returns a new DAO object for table data access.
func NewSysRoleScopeDao() *SysRoleScopeDao {
return &SysRoleScopeDao{
group: "default",
table: "sys_role_scope",
columns: sysRoleScopeColumns,
}
}
// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *SysRoleScopeDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of current dao.
func (dao *SysRoleScopeDao) Table() string {
return dao.table
}
// Columns returns all column names of current dao.
func (dao *SysRoleScopeDao) Columns() SysRoleScopeColumns {
return dao.columns
}
// Group returns the configuration group name of database of current dao.
func (dao *SysRoleScopeDao) Group() string {
return dao.group
}
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *SysRoleScopeDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *SysRoleScopeDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}

View File

@ -8,19 +8,19 @@ import (
"github.com/tiger1103/gfast/v3/internal/app/system/dao/internal"
)
// internalSysRoleDeptDao is internal type for wrapping internal DAO implements.
type internalSysRoleDeptDao = *internal.SysRoleDeptDao
// internalSysRoleScopeDao is internal type for wrapping internal DAO implements.
type internalSysRoleScopeDao = *internal.SysRoleScopeDao
// sysRoleDeptDao is the data access object for table sys_role_dept.
// sysRoleScopeDao is the data access object for table sys_role_scope.
// You can define custom methods on it to extend its functionality as you wish.
type sysRoleDeptDao struct {
internalSysRoleDeptDao
type sysRoleScopeDao struct {
internalSysRoleScopeDao
}
var (
// SysRoleDept is globally public accessible object for table sys_role_dept operations.
SysRoleDept = sysRoleDeptDao{
internal.NewSysRoleDeptDao(),
// SysRoleScope is globally public accessible object for table sys_role_scope operations.
SysRoleScope = sysRoleScopeDao{
internal.NewSysRoleScopeDao(),
}
)

View File

@ -8,15 +8,23 @@
package middleware
import (
"fmt"
"context"
"errors"
"github.com/casbin/casbin/v2"
"github.com/gogf/gf/v2/container/garray"
"github.com/gogf/gf/v2/container/gmap"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"
commonService "github.com/tiger1103/gfast/v3/internal/app/common/service"
"github.com/tiger1103/gfast/v3/internal/app/system/consts"
"github.com/tiger1103/gfast/v3/internal/app/system/model"
"github.com/tiger1103/gfast/v3/internal/app/system/model/entity"
"github.com/tiger1103/gfast/v3/internal/app/system/service"
"github.com/tiger1103/gfast/v3/library/libResponse"
"github.com/tiger1103/gfast/v3/library/liberr"
)
func init() {
@ -59,12 +67,7 @@ func (s *sMiddleware) Auth(r *ghttp.Request) {
ctx := r.GetCtx()
//获取登陆用户id
adminId := service.Context().GetUserId(ctx)
accessParams := r.Get("accessParams").Strings()
accessParamsStr := ""
if len(accessParams) > 0 && accessParams[0] != "undefined" {
accessParamsStr = "?" + gstr.Join(accessParams, "&")
}
url := gstr.TrimLeft(r.Request.URL.Path, "/") + accessParamsStr
url := gstr.TrimLeft(r.Request.URL.Path, "/")
/*if r.Method != "GET" && adminId != 1 && url!="api/v1/system/login" {
libResponse.FailJson(true, r, "对不起!演示系统,不能删改数据!")
}*/
@ -108,23 +111,74 @@ func (s *sMiddleware) Auth(r *ghttp.Request) {
//菜单没存数据库不验证权限
if menuId != 0 {
//判断权限操作
enforcer, err := commonService.CasbinEnforcer(ctx)
err = s.checkAuth(ctx, adminId, menuId)
if err != nil {
g.Log().Error(ctx, err)
libResponse.FailJson(true, r, "获取权限失败")
}
hasAccess := false
hasAccess, err = enforcer.Enforce(fmt.Sprintf("%s%d", service.SysUser().GetCasBinUserPrefix(), adminId), gconv.String(menuId), "All")
if err != nil {
g.Log().Error(ctx, err)
libResponse.FailJson(true, r, "判断权限失败")
}
if !hasAccess {
libResponse.FailJson(true, r, "没有访问权限")
libResponse.FailJson(true, r, err.Error())
}
}
} else if menu == nil && accessParamsStr != "" {
libResponse.FailJson(true, r, "没有访问权限")
}
r.Middleware.Next()
}
func (s *sMiddleware) checkAuth(ctx context.Context, adminId uint64, menuId uint) (err error) {
var (
roleIds []uint
roleList []*entity.SysRole
roleIdsMap = gmap.New()
enforcer *casbin.SyncedEnforcer
b bool
)
err = g.Try(ctx, func(ctx context.Context) {
roleIds, err = service.SysUser().GetAdminRoleIds(ctx, adminId)
liberr.ErrIsNil(ctx, err)
for _, v := range roleIds {
roleIdsMap.Set(v, v)
}
//获取对应角色
roleList, err = service.SysRole().GetRoleList(ctx)
liberr.ErrIsNil(ctx, err)
for _, v := range roleList {
if roleIdsMap.Contains(v.Id) {
//判断是否在角色有效时间段内
if v.EffectiveTime != "" {
var effective *model.EffectiveTimeInfo
err = gconv.Struct(v.EffectiveTime, &effective)
liberr.ErrIsNil(ctx, err, "获取角色有效时间段失败")
if effective != nil && effective.EffectiveType == consts.EffectiveTypeStartEnd {
//按起止日期
now := gtime.Now()
if now.Before(effective.DateRange[0]) || now.After(effective.DateRange[1]) {
roleIdsMap.Remove(v.Id)
}
} else if effective != nil && effective.EffectiveType == consts.EffectiveTypeDate {
//按时间段
now := gtime.Now()
arr := garray.NewIntArrayFrom(effective.WeekDay)
if arr.Contains(gconv.Int(now.Format("w"))) {
sHis := effective.DayRange[0].Format("H:i:s")
eHis := effective.DayRange[1].Format("H:i:s")
start := gtime.NewFromStr(now.Format("Y-m-d " + sHis))
end := gtime.NewFromStr(now.Format("Y-m-d " + eHis))
if now.Before(start) || now.After(end) {
roleIdsMap.Remove(v.Id)
}
} else {
roleIdsMap.Remove(v.Id)
}
}
}
}
}
enforcer, err = commonService.CasbinEnforcer(ctx)
liberr.ErrIsNil(ctx, err)
roleIdsMap.Iterator(func(k interface{}, v interface{}) bool {
b, err = enforcer.Enforce(gconv.String(v), gconv.String(menuId), "All")
liberr.ErrIsNil(ctx, err)
return b
})
if !b {
liberr.ErrIsNil(ctx, errors.New("没有权限"))
}
})
return
}

View File

@ -314,3 +314,17 @@ func (s *sSysAuthRule) FindSonByParentId(list []*model.SysAuthRuleInfoRes, pid u
}
return children
}
func (s *sSysAuthRule) GetIdByName(ctx context.Context, name string) (id uint, err error) {
var menuList []*model.SysAuthRuleInfoRes
menuList, err = s.GetMenuList(ctx)
if err != nil {
return
}
for _, menu := range menuList {
if menu.Name == name {
id = menu.Id
}
}
return
}

View File

@ -306,55 +306,60 @@ func (s *sSysRole) DeleteByIds(ctx context.Context, ids []int64) (err error) {
return
}
func (s *sSysRole) RoleDeptTreeSelect(ctx context.Context, roleId int64) (res *system.RoleDeptTreeSelectRes, err error) {
func (s *sSysRole) RoleDeptTreeSelect(ctx context.Context) (res *system.RoleDeptTreeSelectRes, err error) {
res = new(system.RoleDeptTreeSelectRes)
err = g.Try(ctx, func(ctx context.Context) {
list, err := service.SysDept().GetList(ctx, &system.DeptSearchReq{
Status: "1",
})
liberr.ErrIsNil(ctx, err)
//获取关联的角色数据权限
checkedKeys, err := s.GetRoleDepts(ctx, roleId)
liberr.ErrIsNil(ctx, err)
dList := service.SysDept().GetListTree(0, list)
res.Depts = dList
res.CheckedKeys = checkedKeys
})
return
}
func (s *sSysRole) GetRoleDepts(ctx context.Context, roleId int64) ([]int64, error) {
var entities []*entity.SysRoleDept
err := dao.SysRoleDept.Ctx(ctx).Where("role_id", roleId).Scan(&entities)
if err != nil {
return nil, err
func (s *sSysRole) GetRoleDataScope(ctx context.Context, roleId uint) (data []*model.ScopeAuthData, err error) {
err = g.Try(ctx, func(ctx context.Context) {
err = dao.SysRoleScope.Ctx(ctx).Where("role_id", roleId).Scan(&data)
liberr.ErrIsNil(ctx, err, "获取角色数据权限失败")
})
return
}
result := make([]int64, 0)
for _, v := range entities {
result = append(result, v.DeptId)
}
return result, nil
func (s *sSysRole) GetRoleMenuScope(ctx context.Context, roleIds []uint, menuId uint) (data []*model.ScopeAuthData, err error) {
err = g.Try(ctx, func(ctx context.Context) {
err = dao.SysRoleScope.Ctx(ctx).WhereIn("role_id", roleIds).
Where("menu_id", menuId).
Scan(&data)
liberr.ErrIsNil(ctx, err, "获取角色数据权限失败")
})
return
}
// RoleDataScope 设置角色数据权限
func (s *sSysRole) RoleDataScope(ctx context.Context, req *system.DataScopeReq) error {
err := g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
err := g.Try(ctx, func(ctx context.Context) {
_, err := tx.Model(dao.SysRole.Table()).Where("id", req.RoleId).Data(g.Map{"data_scope": req.DataScope}).Update()
liberr.ErrIsNil(ctx, err, "设置失败")
if req.DataScope == 2 {
_, err = tx.Model(dao.SysRoleDept.Table()).Where("role_id", req.RoleId).Delete()
liberr.ErrIsNil(ctx, err, "设置失败")
data := g.List{}
for _, deptId := range req.DeptIds {
data = append(data, g.Map{"role_id": req.RoleId, "dept_id": deptId})
data := make([]do.SysRoleScope, 0, len(req.AuthData))
for _, v := range req.AuthData {
if v.MenuId != 0 && v.Scope != 0 {
data = append(data, do.SysRoleScope{
RoleId: req.RoleId,
MenuId: v.MenuId,
DataScope: v.Scope,
DeptIds: gconv.String(v.DeptIds),
})
}
_, err = tx.Model(dao.SysRoleDept.Table()).Data(data).Insert()
liberr.ErrIsNil(ctx, err, "设置失败")
}
//清除缓存
commonService.Cache().Remove(ctx, consts.CacheSysRole)
//清除旧权限
_, err := dao.SysRoleScope.Ctx(ctx).Where(dao.SysRoleScope.Columns().RoleId, req.RoleId).
Delete()
liberr.ErrIsNil(ctx, err, "清除旧权限信息失败")
if len(data) > 0 {
_, err = dao.SysRoleScope.Ctx(ctx).Data(data).Insert()
liberr.ErrIsNil(ctx, err, "设置权限信息失败")
}
})
return err
})

View File

@ -11,6 +11,7 @@ import (
"context"
"fmt"
"github.com/gogf/gf/v2/container/garray"
"github.com/gogf/gf/v2/encoding/gurl"
"reflect"
"github.com/gogf/gf/v2/container/gset"
@ -287,6 +288,7 @@ func (s *sSysUser) GetAdminMenusByRoleIds(ctx context.Context, roleIds []uint) (
var (
menuArr *garray.Array
menuIds = map[uint]uint{}
menuNameId = map[string]*model.SysAuthRuleInfoRes{}
)
menuArr, err = s.GetAdminMenusIdsByRoleIds(ctx, roleIds)
liberr.ErrIsNil(ctx, err)
@ -300,11 +302,21 @@ func (s *sSysUser) GetAdminMenusByRoleIds(ctx context.Context, roleIds []uint) (
liberr.ErrIsNil(ctx, err)
menus = make([]*model.UserMenus, 0, len(allMenus))
for _, v := range allMenus {
if _, ok := menuIds[v.Id]; gstr.Equal(v.Condition, "nocheck") || ok {
urlMap, _ := gurl.ParseURL(v.Name, -1)
if query, ok := urlMap["query"]; ok && query != "" {
menuNameId[urlMap["path"]+"#query"] = v
}
}
for _, v := range allMenus {
var roleMenu *model.UserMenu
if _, ok := menuIds[v.Id]; gstr.Equal(v.Condition, "nocheck") || ok {
roleMenu = s.setMenuData(roleMenu, v)
menus = append(menus, &model.UserMenus{UserMenu: roleMenu})
}
if info, ok := menuNameId[v.Name+"#query"]; ok && roleMenu != nil {
roleMenu = s.setMenuData(roleMenu, info)
menus = append(menus, &model.UserMenus{UserMenu: roleMenu})
}
}
menus = s.GetMenusTree(menus, 0)
})
@ -481,6 +493,17 @@ func (s *sSysUser) List(ctx context.Context, req *system.UserSearchReq) (total i
return
}
func (s *sSysUser) GetUsersByRoleId(ctx context.Context, roleId uint) (users []*model.SysUserRoleDeptRes, err error) {
err = g.Try(ctx, func(ctx context.Context) {
m := dao.SysUser.Ctx(ctx)
m = m.As("a").LeftJoin("casbin_rule", "b", "b.v0 = CONCAT('u_',a.id )").
Where("v1 = ? and SUBSTR(v0,1,2) = 'u_'", roleId)
err = m.Order("id asc").Scan(&users)
liberr.ErrIsNil(ctx, err, "获取用户数据失败")
})
return
}
// GetUserSelector 获取用户选择器数据
func (s *sSysUser) GetUserSelector(ctx context.Context, req *system.UserSelectorReq) (total interface{}, userList []*model.SysUserSimpleRes, err error) {
err = g.Try(ctx, func(ctx context.Context) {
@ -722,6 +745,23 @@ func (s *sSysUser) EditUserRole(ctx context.Context, roleIds []uint, userId int6
return
}
// SetUserRole 设置用户角色
func (s *sSysUser) SetUserRole(ctx context.Context, roleId uint, userIds []uint64) (err error) {
err = g.Try(ctx, func(ctx context.Context) {
enforcer, e := commonService.CasbinEnforcer(ctx)
liberr.ErrIsNil(ctx, e)
//删除用户旧角色信息
_, err = enforcer.RemoveFilteredGroupingPolicy(1, fmt.Sprintf("%d", roleId))
liberr.ErrIsNil(ctx, err)
for _, v := range userIds {
_, err = enforcer.AddGroupingPolicy(fmt.Sprintf("%s%d", s.casBinUserPrefix, v), gconv.String(roleId))
liberr.ErrIsNil(ctx, err)
}
})
return
}
func (s *sSysUser) UserNameOrMobileExists(ctx context.Context, userName, mobile string, id ...int64) error {
user := (*entity.SysUser)(nil)
err := g.Try(ctx, func(ctx context.Context) {
@ -852,48 +892,46 @@ func (s *sSysUser) GetUsers(ctx context.Context, ids []int) (users []*model.SysU
}
// GetDataWhere 获取数据权限判断条件
func (s *sSysUser) GetDataWhere(ctx context.Context, userInfo *model.ContextUser, entityData interface{}) (where g.Map, err error) {
func (s *sSysUser) GetDataWhere(ctx context.Context, userInfo *model.ContextUser, entityData interface{}, menuId uint) (where g.Map, err error) {
whereJustMe := g.Map{} //本人数据权限
t := reflect.TypeOf(entityData)
err = g.Try(ctx, func(ctx context.Context) {
for i := 0; i < t.Elem().NumField(); i++ {
if t.Elem().Field(i).Name == "CreatedBy" {
//若存在用户id的字段则生成判断数据权限的条件
//1、获取当前用户所属角色
allRoles := ([]*entity.SysRole)(nil)
allRoles, err = service.SysRole().GetRoleList(ctx)
if err != nil {
return nil, err
}
roles := ([]*entity.SysRole)(nil)
roles, err = s.GetAdminRole(ctx, userInfo.Id, allRoles)
if err != nil {
return nil, err
}
//1、获取当前用户所属角色Ids
var (
roleIds []uint
scope []*model.ScopeAuthData
deptIdArr = gset.New()
allScope = false
)
roleIds, err = s.GetAdminRoleIds(ctx, userInfo.Id)
liberr.ErrIsNil(ctx, err)
scope, err = service.SysRole().GetRoleMenuScope(ctx, roleIds, menuId)
liberr.ErrIsNil(ctx, err)
if scope == nil {
//角色未设置数据权限,默认仅本人数据权限
whereJustMe = g.Map{"user.id": userInfo.Id}
} else {
//2获取角色对应数据权限
deptIdArr := gset.New()
for _, role := range roles {
switch role.DataScope {
for _, sv := range scope {
switch sv.DataScope {
case 1: //全部数据权限
return
allScope = true
goto endLoop
case 2: //自定数据权限
var deptIds []int64
deptIds, err = service.SysRole().GetRoleDepts(ctx, gconv.Int64(role.Id))
if err != nil {
return
}
deptIdArr.Add(gconv.Interfaces(deptIds)...)
deptIdArr.Add(gconv.Interfaces(sv.DeptIds)...)
case 3: //本部门数据权限
deptIdArr.Add(gconv.Int64(userInfo.DeptId))
case 4: //本部门及以下数据权限
deptIdArr.Add(gconv.Int64(userInfo.DeptId))
//获取正常状态部门数据
depts := ([]*entity.SysDept)(nil)
depts, err = service.SysDept().GetList(ctx, &system.DeptSearchReq{Status: "1"})
if err != nil {
return
}
deptList := ([]*entity.SysDept)(nil)
deptList, err = service.SysDept().GetList(ctx, &system.DeptSearchReq{Status: "1"})
liberr.ErrIsNil(ctx, err)
var dList g.List
for _, d := range depts {
for _, d := range deptList {
m := g.Map{
"id": d.DeptId,
"pid": d.ParentId,
@ -909,13 +947,17 @@ func (s *sSysUser) GetDataWhere(ctx context.Context, userInfo *model.ContextUser
whereJustMe = g.Map{"user.id": userInfo.Id}
}
}
if deptIdArr.Size() > 0 {
}
endLoop:
if !allScope && deptIdArr.Size() > 0 {
where = g.Map{"user.dept_id": deptIdArr.Slice()}
} else if len(whereJustMe) > 0 {
} else if !allScope && len(whereJustMe) > 0 {
where = whereJustMe
}
break
}
}
})
return
}

View File

@ -955,12 +955,12 @@ func (s *sToolsGenTable) SelectRecordById(ctx context.Context, tableId int64) (t
tableEx.HasConversion = true
break
case "date":
columnEx.FieldValidation = gstr.CaseCamelLower(columnName) + "@" + dateValidationRule + "#" + column.ColumnComment + "需为YYYY-MM-DD格式"
columnEx.FieldConversion = "gconv.Time"
tableEx.HasConversion = true
break
case "Time":
if column.ColumnType == "date" {
columnEx.FieldValidation = gstr.CaseCamelLower(columnName) + "@" + dateValidationRule + "#" + column.ColumnComment + "需为YYYY-MM-DD格式"
} else {
columnEx.FieldValidation = gstr.CaseCamelLower(columnName) + "@" + datetimeValidationRule + "#" + column.ColumnComment + "需为YYYY-MM-DD hh:mm:ss格式"
}
columnEx.FieldConversion = "gconv.Time"
tableEx.HasConversion = true
break

View File

@ -1,16 +0,0 @@
// =================================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
)
// SysRoleDept is the golang structure of table sys_role_dept for DAO operations like Where/Data.
type SysRoleDept struct {
g.Meta `orm:"table:sys_role_dept, do:true"`
RoleId interface{} // 角色ID
DeptId interface{} // 部门ID
}

View File

@ -0,0 +1,19 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
)
// SysRoleScope is the golang structure of table sys_role_scope for DAO operations like Where/Data.
type SysRoleScope struct {
g.Meta `orm:"table:sys_role_scope, do:true"`
Id interface{} // ID
RoleId interface{} // 角色id
MenuId interface{} // api接口id
DataScope interface{} // 数据范围1全部数据权限 2自定数据权限 3本部门数据权限 4本部门及以下数据权限
DeptIds interface{} // 扩展数据
}

View File

@ -1,11 +0,0 @@
// =================================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
// SysRoleDept is the golang structure for table sys_role_dept.
type SysRoleDept struct {
RoleId int64 `json:"roleId" description:"角色ID"`
DeptId int64 `json:"deptId" description:"部门ID"`
}

View File

@ -0,0 +1,14 @@
// =================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
// SysRoleScope is the golang structure for table sys_role_scope.
type SysRoleScope struct {
Id uint64 `json:"id" description:"ID"`
RoleId uint64 `json:"roleId" description:"角色id"`
MenuId int `json:"menuId" description:"api接口id"`
DataScope int `json:"dataScope" description:"数据范围1全部数据权限 2自定数据权限 3本部门数据权限 4本部门及以下数据权限"`
DeptIds string `json:"deptIds" description:"扩展数据"`
}

View File

@ -0,0 +1,22 @@
/*
* @desc:xxxx功能描述
* @company:云南奇讯科技有限公司
* @Author: yixiaohu<yxh669@qq.com>
* @Date: 2024/3/26 10:24
*/
package model
type ScopeAuthDataReq struct {
MenuId uint `p:"menuId"`
Scope int `p:"scope"`
DeptIds []uint64 `p:"deptIds"`
}
type ScopeAuthData struct {
Id uint64 `json:"id"`
RoleId uint `json:"roleId"`
MenuId uint `json:"menuId"`
DataScope int `json:"dataScope"`
DeptIds []int64 `json:"deptIds"`
}

View File

@ -28,6 +28,7 @@ type (
GetMenuListTree(pid uint, list []*model.SysAuthRuleInfoRes) []*model.SysAuthRuleTreeRes
DeleteMenuByIds(ctx context.Context, ids []int) (err error)
FindSonByParentId(list []*model.SysAuthRuleInfoRes, pid uint) []*model.SysAuthRuleInfoRes
GetIdByName(ctx context.Context,name string)(id uint,err error)
}
)

View File

@ -24,11 +24,12 @@ type (
GetFilteredNamedPolicy(ctx context.Context, id uint) (gpSlice []int, err error)
EditRole(ctx context.Context, req *system.RoleEditReq) (err error)
DeleteByIds(ctx context.Context, ids []int64) (err error)
RoleDeptTreeSelect(ctx context.Context, roleId int64) (res *system.RoleDeptTreeSelectRes, err error)
GetRoleDepts(ctx context.Context, roleId int64) ([]int64, error)
RoleDeptTreeSelect(ctx context.Context) (res *system.RoleDeptTreeSelectRes, err error)
RoleDataScope(ctx context.Context, req *system.DataScopeReq) error
FindSonByParentId(roleList []*entity.SysRole, id uint) []*entity.SysRole
FindSonIdsByParentId(roleList []*entity.SysRole, id uint) []uint
GetRoleDataScope(ctx context.Context, roleId uint) (data []*model.ScopeAuthData, err error)
GetRoleMenuScope(ctx context.Context, roleIds []uint, menuId uint) (data []*model.ScopeAuthData, err error)
}
)

View File

@ -43,6 +43,7 @@ type (
Edit(ctx context.Context, req *system.UserEditReq) (err error)
AddUserPost(ctx context.Context, tx gdb.TX, postIds []int64, userId int64) (err error)
EditUserRole(ctx context.Context, roleIds []uint, userId int64) (err error)
SetUserRole(ctx context.Context, roleId uint, userIds []uint64) (err error)
UserNameOrMobileExists(ctx context.Context, userName, mobile string, id ...int64) error
GetEditUser(ctx context.Context, id uint64) (res *system.UserGetEditRes, err error)
GetUserInfoById(ctx context.Context, id uint64, withPwd ...bool) (user *entity.SysUser, err error)
@ -51,10 +52,11 @@ type (
ChangeUserStatus(ctx context.Context, req *system.UserStatusReq) (err error)
Delete(ctx context.Context, ids []int) (err error)
GetUsers(ctx context.Context, ids []int) (users []*model.SysUserSimpleRes, err error)
GetDataWhere(ctx context.Context, userInfo *model.ContextUser, entityData interface{}) (where g.Map, err error)
GetDataWhere(ctx context.Context, userInfo *model.ContextUser, entityData interface{},menuId uint) (where g.Map, err error)
HasAccessByDataWhere(ctx context.Context, where g.Map, uid interface{}) bool
AccessRule(ctx context.Context, userId uint64, rule string) bool
GetUserSelector(ctx context.Context, req *system.UserSelectorReq) (total interface{}, userList []*model.SysUserSimpleRes, err error)
GetUsersByRoleId(ctx context.Context,roleId uint)(users []*model.SysUserRoleDeptRes,err error)
}
)

View File

@ -9,5 +9,5 @@ package consts
const (
Logo = `CiAgIF9fX19fX19fX19fXyAgICAgICAgICAgX18gCiAgLyBfX19fLyBfX19fL19fXyBfX19fX18vIC9fCiAvIC8gX18vIC9fICAvIF9fIGAvIF9fXy8gX18vCi8gL18vIC8gX18vIC8gL18vIChfXyAgKSAvXyAgClxfX19fL18vICAgIFxfXyxfL19fX18vXF9fLyAg`
Version = "3.2.21"
Version = "3.2.22"
)

View File

@ -12,7 +12,7 @@
Target Server Version : 140010
File Encoding : 65001
Date: 18/03/2024 10:32:41
Date: 12/04/2024 17:11:52
*/
@ -227,6 +227,17 @@ MAXVALUE 9223372036854775807
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for sys_role_scope_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "sys_role_scope_id_seq";
CREATE SEQUENCE "sys_role_scope_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for sys_user_id_seq
-- ----------------------------
@ -4460,6 +4471,12 @@ INSERT INTO "sys_auth_rule" VALUES (89, 87, 'api/v1/system/sysNotice/add', '通
INSERT INTO "sys_auth_rule" VALUES (90, 87, 'api/v1/system/sysNotice/edit', '通知公告修改', '', '', '通知公告修改', 2, 0, 0, '', '', 0, 'sys_admin', 0, 0, 1, '', 0, '', NULL, NULL);
INSERT INTO "sys_auth_rule" VALUES (91, 87, 'api/v1/system/sysNotice/delete', '通知公告删除', '', '', '通知公告删除', 2, 0, 0, '', '', 0, 'sys_admin', 0, 0, 1, '', 0, '', NULL, NULL);
INSERT INTO "sys_auth_rule" VALUES (92, 86, 'api/v1/system/sysNotice/show', '通知公告扎展示', 'iconfont icon-tongzhi', '', '', 0, 0, 0, '/system/sysNotice/show', 'system/sysNotice/show/index', 0, '', 0, 0, 1, '', 0, '', '2023-12-25 10:34:32', '2023-12-25 10:34:32');
INSERT INTO "sys_auth_rule" VALUES (93, 10, 'api/v1/system/role/dataScope', '授权数据权限', '', '', '', 2, 0, 0, '', '', 0, '', 0, 0, 1, '', 0, '', '2024-04-11 11:18:23', '2024-04-11 11:19:17');
INSERT INTO "sys_auth_rule" VALUES (94, 10, 'api/v1/system/role/setRoleUser', '授权用户权限', '', '', '', 2, 0, 0, '', '', 0, '', 0, 0, 1, '', 0, '', '2024-04-11 11:18:59', '2024-04-11 11:18:59');
INSERT INTO "sys_auth_rule" VALUES (95, 26, 'api/v1/system/user/add', '新增用户', '', '', '', 2, 0, 0, '', '', 0, '', 0, 0, 1, '', 0, '', '2024-04-11 11:16:14', '2024-04-11 11:16:14');
INSERT INTO "sys_auth_rule" VALUES (96, 26, 'api/v1/system/user/edit', '修改用户', '', '', '', 2, 0, 0, '', '', 0, '', 0, 0, 1, '', 0, '', '2024-04-11 11:16:45', '2024-04-11 11:19:25');
INSERT INTO "sys_auth_rule" VALUES (97, 26, 'api/v1/system/user/getEdit', '用户信息', '', '', '', 2, 0, 0, '', '', 0, '', 0, 0, 1, '', 0, '', '2024-04-11 11:17:21', '2024-04-11 11:19:30');
INSERT INTO "sys_auth_rule" VALUES (98, 26, 'api/v1/system/user/delete', '删除用户', '', '', '', 2, 0, 0, '', '', 0, '', 0, 0, 1, '', 0, '', '2024-04-11 11:17:39', '2024-04-11 11:19:34');
-- ----------------------------
-- Table structure for sys_config
@ -5047,6 +5064,29 @@ INSERT INTO "sys_role_dept" VALUES (5, 105);
INSERT INTO "sys_role_dept" VALUES (8, 105);
INSERT INTO "sys_role_dept" VALUES (8, 106);
-- ----------------------------
-- Table structure for sys_role_scope
-- ----------------------------
DROP TABLE IF EXISTS "sys_role_scope";
CREATE TABLE "sys_role_scope" (
"id" int8 NOT NULL DEFAULT nextval('sys_role_scope_id_seq'::regclass),
"role_id" int8 NOT NULL DEFAULT 0,
"menu_id" int4 NOT NULL,
"data_scope" int4 NOT NULL,
"dept_ids" json
)
;
COMMENT ON COLUMN "sys_role_scope"."id" IS 'ID';
COMMENT ON COLUMN "sys_role_scope"."role_id" IS '角色id';
COMMENT ON COLUMN "sys_role_scope"."menu_id" IS 'api接口id';
COMMENT ON COLUMN "sys_role_scope"."data_scope" IS '数据范围1全部数据权限 2自定数据权限 3本部门数据权限 4本部门及以下数据权限)';
COMMENT ON COLUMN "sys_role_scope"."dept_ids" IS '扩展数据';
COMMENT ON TABLE "sys_role_scope" IS '角色数据权限';
-- ----------------------------
-- Records of sys_role_scope
-- ----------------------------
-- ----------------------------
-- Table structure for sys_user
-- ----------------------------
@ -5465,7 +5505,7 @@ SELECT setval('"demo_gen_tree_id_seq"', 11, false);
-- ----------------------------
ALTER SEQUENCE "sys_auth_rule_id_seq"
OWNED BY "sys_auth_rule"."id";
SELECT setval('"sys_auth_rule_id_seq"', 92, true);
SELECT setval('"sys_auth_rule_id_seq"', 98, true);
-- ----------------------------
-- Alter sequences owned by
@ -5547,6 +5587,13 @@ ALTER SEQUENCE "sys_role_id_seq"
OWNED BY "sys_role"."id";
SELECT setval('"sys_role_id_seq"', 10, false);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "sys_role_scope_id_seq"
OWNED BY "sys_role_scope"."id";
SELECT setval('"sys_role_scope_id_seq"', 1, false);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
@ -5740,6 +5787,16 @@ ALTER TABLE "sys_role" ADD CONSTRAINT "pk_sys_role" PRIMARY KEY ("id");
-- ----------------------------
ALTER TABLE "sys_role_dept" ADD CONSTRAINT "pk_sys_role_dept" PRIMARY KEY ("role_id", "dept_id");
-- ----------------------------
-- Uniques structure for table sys_role_scope
-- ----------------------------
ALTER TABLE "sys_role_scope" ADD CONSTRAINT "sys_role_scope_role_id_menu_id_key" UNIQUE ("role_id", "menu_id");
-- ----------------------------
-- Primary Key structure for table sys_role_scope
-- ----------------------------
ALTER TABLE "sys_role_scope" ADD CONSTRAINT "sys_role_scope_pkey" PRIMARY KEY ("id");
-- ----------------------------
-- Indexes structure for table sys_user
-- ----------------------------

View File

@ -11,7 +11,7 @@
Target Server Version : 50736
File Encoding : 65001
Date: 18/03/2024 10:34:48
Date: 12/04/2024 17:11:01
*/
SET NAMES utf8mb4;
@ -104,8 +104,6 @@ CREATE TABLE `casbin_rule` (
-- Records of casbin_rule
-- ----------------------------
INSERT INTO `casbin_rule` VALUES ('g', 'u_3', '1', '', '', '', '');
INSERT INTO `casbin_rule` VALUES ('g', 'u_3', '2', '', '', '', '');
INSERT INTO `casbin_rule` VALUES ('g', 'u_31', '2', '', '', '', '');
INSERT INTO `casbin_rule` VALUES ('g', 'u_1', '1', '', '', '', '');
INSERT INTO `casbin_rule` VALUES ('g', 'u_43', '1', '', '', '', '');
INSERT INTO `casbin_rule` VALUES ('p', '1', '27', 'All', '', '', '');
@ -170,7 +168,10 @@ INSERT INTO `casbin_rule` VALUES ('p', '9', '23', 'All', '', '', '');
INSERT INTO `casbin_rule` VALUES ('p', '9', '24', 'All', '', '', '');
INSERT INTO `casbin_rule` VALUES ('p', '9', '25', 'All', '', '', '');
INSERT INTO `casbin_rule` VALUES ('p', '9', '26', 'All', '', '', '');
INSERT INTO `casbin_rule` VALUES ('g', 'u_3', '2', '', '', '', '');
INSERT INTO `casbin_rule` VALUES ('g', 'u_5', '2', '', '', '', '');
INSERT INTO `casbin_rule` VALUES ('g', 'u_31', '2', '', '', '', '');
INSERT INTO `casbin_rule` VALUES ('g', 'u_6', '2', '', '', '', '');
INSERT INTO `casbin_rule` VALUES ('p', '2', '1', 'All', '', '', '');
INSERT INTO `casbin_rule` VALUES ('p', '2', '2', 'All', '', '', '');
INSERT INTO `casbin_rule` VALUES ('p', '2', '3', 'All', '', '', '');
@ -4056,7 +4057,7 @@ CREATE TABLE `sys_auth_rule` (
UNIQUE INDEX `name`(`name`) USING BTREE,
INDEX `pid`(`pid`) USING BTREE,
INDEX `weigh`(`weigh`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 66 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '菜单节点表' ROW_FORMAT = COMPACT;
) ENGINE = InnoDB AUTO_INCREMENT = 120 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '菜单节点表' ROW_FORMAT = COMPACT;
-- ----------------------------
-- Records of sys_auth_rule
@ -4108,6 +4109,12 @@ INSERT INTO `sys_auth_rule` VALUES (62, 60, 'api/v1/system/sysNotice/add', '通
INSERT INTO `sys_auth_rule` VALUES (63, 60, 'api/v1/system/sysNotice/edit', '通知公告修改', '', '', '通知公告修改', 2, 0, 0, '', '', 0, 'sys_admin', 0, 0, 1, '', 0, '', NULL, NULL);
INSERT INTO `sys_auth_rule` VALUES (64, 60, 'api/v1/system/sysNotice/delete', '通知公告删除', '', '', '通知公告删除', 2, 0, 0, '', '', 0, 'sys_admin', 0, 0, 1, '', 0, '', NULL, NULL);
INSERT INTO `sys_auth_rule` VALUES (65, 59, 'api/v1/system/sysNotice/show', '通知公告展示', 'iconfont icon-tongzhi', '', '', 0, 0, 0, '/system/sysNotice/show', 'system/sysNotice/show/index', 0, '', 0, 0, 1, '', 0, '', '2023-12-25 10:34:32', '2024-01-03 10:09:12');
INSERT INTO `sys_auth_rule` VALUES (114, 10, 'api/v1/system/role/dataScope', '授权数据权限', '', '', '', 2, 0, 0, '', '', 0, '', 0, 0, 1, '', 0, '', '2024-04-11 11:18:23', '2024-04-11 11:19:17');
INSERT INTO `sys_auth_rule` VALUES (115, 10, 'api/v1/system/role/setRoleUser', '授权用户权限', '', '', '', 2, 0, 0, '', '', 0, '', 0, 0, 1, '', 0, '', '2024-04-11 11:18:59', '2024-04-11 11:18:59');
INSERT INTO `sys_auth_rule` VALUES (116, 26, 'api/v1/system/user/add', '新增用户', '', '', '', 2, 0, 0, '', '', 0, '', 0, 0, 1, '', 0, '', '2024-04-11 11:16:14', '2024-04-11 11:16:14');
INSERT INTO `sys_auth_rule` VALUES (117, 26, 'api/v1/system/user/edit', '修改用户', '', '', '', 2, 0, 0, '', '', 0, '', 0, 0, 1, '', 0, '', '2024-04-11 11:16:45', '2024-04-11 11:19:25');
INSERT INTO `sys_auth_rule` VALUES (118, 26, 'api/v1/system/user/getEdit', '用户信息', '', '', '', 2, 0, 0, '', '', 0, '', 0, 0, 1, '', 0, '', '2024-04-11 11:17:21', '2024-04-11 11:19:30');
INSERT INTO `sys_auth_rule` VALUES (119, 26, 'api/v1/system/user/delete', '删除用户', '', '', '', 2, 0, 0, '', '', 0, '', 0, 0, 1, '', 0, '', '2024-04-11 11:17:39', '2024-04-11 11:19:34');
-- ----------------------------
-- Table structure for sys_config
@ -4525,7 +4532,7 @@ CREATE TABLE `sys_role` (
-- Records of sys_role
-- ----------------------------
INSERT INTO `sys_role` VALUES (1, 0, 1, 0, '超级管理员', '备注', 2, '2022-04-01 11:38:39', '2023-09-28 10:27:55', 0, NULL);
INSERT INTO `sys_role` VALUES (2, 1, 1, 0, '普通管理员', '备注', 5, '2022-04-01 11:38:39', '2024-01-29 15:18:28', 0, NULL);
INSERT INTO `sys_role` VALUES (2, 1, 1, 0, '普通管理员', '备注', 5, '2022-04-01 11:38:39', '2024-04-12 17:09:26', 0, '{\"effectiveType\":2,\"weekDay\":[1,2,3,4,5],\"dayRange\":[\"2024-04-12 08:00:00\",\"2024-04-12 18:00:00\"],\"dateRange\":null}');
INSERT INTO `sys_role` VALUES (3, 0, 1, 0, '站点管理员', '站点管理人员', 3, '2022-04-01 11:38:39', '2022-04-01 11:38:39', 0, NULL);
INSERT INTO `sys_role` VALUES (4, 5, 1, 0, '初级管理员', '初级管理员', 3, '2022-04-01 11:38:39', '2024-03-18 10:16:15', 0, '{\"effectiveType\":0,\"weekDay\":null,\"dayRange\":null,\"dateRange\":null}');
INSERT INTO `sys_role` VALUES (5, 0, 1, 0, '高级管理员', '高级管理员', 2, '2022-04-01 11:38:39', '2022-04-01 11:38:39', 0, NULL);
@ -4557,6 +4564,31 @@ INSERT INTO `sys_role_dept` VALUES (5, 105);
INSERT INTO `sys_role_dept` VALUES (8, 105);
INSERT INTO `sys_role_dept` VALUES (8, 106);
-- ----------------------------
-- Table structure for sys_role_scope
-- ----------------------------
DROP TABLE IF EXISTS `sys_role_scope`;
CREATE TABLE `sys_role_scope` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID',
`role_id` bigint(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT '角色id',
`menu_id` int(11) NOT NULL COMMENT 'api接口id',
`data_scope` int(11) NOT NULL COMMENT '数据范围1全部数据权限 2自定数据权限 3本部门数据权限 4本部门及以下数据权限',
`dept_ids` json NULL COMMENT '扩展数据',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `role_id`(`role_id`, `menu_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 15 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色数据权限' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of sys_role_scope
-- ----------------------------
INSERT INTO `sys_role_scope` VALUES (8, 2, 59, 5, '[]');
INSERT INTO `sys_role_scope` VALUES (9, 2, 60, 5, '[]');
INSERT INTO `sys_role_scope` VALUES (10, 2, 61, 2, '[101, 103, 104, 105, 106, 107]');
INSERT INTO `sys_role_scope` VALUES (11, 2, 62, 5, '[]');
INSERT INTO `sys_role_scope` VALUES (12, 2, 63, 5, '[]');
INSERT INTO `sys_role_scope` VALUES (13, 2, 64, 5, '[]');
INSERT INTO `sys_role_scope` VALUES (14, 2, 65, 5, '[]');
-- ----------------------------
-- Table structure for sys_user
-- ----------------------------
@ -4611,7 +4643,7 @@ INSERT INTO `sys_user` VALUES (22, 'yxfmlbb', '15969423326', '大数据部门测
INSERT INTO `sys_user` VALUES (23, 'wangming', '18687460581', '王明', 0, '542a6e44dbac171f260fc4a032cd5522', 'dlqVVBTADg', 1, '', 0, '', 0, '', 1, '', '', '::1', '2023-11-03 16:03:56', '2021-06-22 17:58:00', '2021-06-22 17:58:00', NULL, 'oHUVQ6CKETZ7gvqkHdJqdlw2WXNE');
INSERT INTO `sys_user` VALUES (24, 'zhk', '13699885591', '综合科', 0, '542a6e44dbac171f260fc4a032cd5522', 'dlqVVBTADg', 1, '', 0, '', 0, '', 1, '', '', '192.168.0.146', NULL, '2021-06-22 17:58:00', '2021-06-22 17:58:00', NULL, '');
INSERT INTO `sys_user` VALUES (28, 'demo3', '18699888855', '测试账号1', 0, '542a6e44dbac171f260fc4a032cd5522', 'dlqVVBTADg', 1, '123132@qq.com', 0, '', 109, '', 1, '', '', '192.168.0.229', NULL, '2021-06-22 17:58:00', '2021-06-22 17:58:00', NULL, '');
INSERT INTO `sys_user` VALUES (31, 'demo', '15334455789', '李四', 0, '6dd68eea81e0fca319add0bd58c3fdf6', '46PvWe1Sl7', 1, '123@qq.com', 2, 'upload_file/2023-11-01/cwn4m6vp1qxkxvfqlx.jpg', 109, '3', 1, '云南省曲靖市22223', '生活变的再糟糕,也不妨碍我变得更好', '::1', '2024-03-18 09:25:54', '2021-06-22 17:58:00', '2023-11-01 10:40:19', NULL, '');
INSERT INTO `sys_user` VALUES (31, 'demo', '15334455789', '李四', 0, '6dd68eea81e0fca319add0bd58c3fdf6', '46PvWe1Sl7', 1, '123@qq.com', 2, 'upload_file/2024-03-25/d02qmdqwk47kraexvh.jpg', 109, '3', 1, '云南省曲靖市22223', '生活变的再糟糕,也不妨碍我变得更好', '::1', '2024-04-12 16:59:11', '2021-06-22 17:58:00', '2024-03-25 17:52:53', NULL, '');
INSERT INTO `sys_user` VALUES (32, 'demo100', '18699888859', '测试账号1', 0, '542a6e44dbac171f260fc4a032cd5522', 'dlqVVBTADg', 1, '', 0, '', 0, '', 1, '', '', '[::1]', '2021-11-24 18:01:21', '2021-06-22 17:58:00', '2021-06-22 17:58:00', NULL, '');
INSERT INTO `sys_user` VALUES (33, 'demo110', '18699888853', '测试账号1', 0, '542a6e44dbac171f260fc4a032cd5522', 'dlqVVBTADg', 1, '', 0, '', 0, '', 1, '', '', '', NULL, '2021-06-22 17:58:00', '2021-06-22 17:58:00', NULL, '');
INSERT INTO `sys_user` VALUES (34, 'yxfmlbb2', '15969423327', '研发部门测试', 0, '542a6e44dbac171f260fc4a032cd5522', 'dlqVVBTADg', 1, '1111@qqq.com', 1, '', 103, '', 0, '', '', '127.0.0.1', NULL, '2021-06-22 17:58:00', '2021-06-22 17:58:00', NULL, '');
@ -4640,13 +4672,12 @@ CREATE TABLE `sys_user_online` (
`os` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '操作系统',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `uni_token`(`token`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 16 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户在线状态表' ROW_FORMAT = COMPACT;
) ENGINE = InnoDB AUTO_INCREMENT = 25 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户在线状态表' ROW_FORMAT = COMPACT;
-- ----------------------------
-- Records of sys_user_online
-- ----------------------------
INSERT INTO `sys_user_online` VALUES (14, 'fbb637e7a7babe0d8baf41e4aa82d2e6', '7ZUSfVIf2HyYjcv86SKPPs29v003ECPEScsdYsYYqO2wMop+JHFZf/yt1ELqjTJMqqVsRyuOr5KCYVYPtppY7PZObwWyrJnrdsNoNKmIPppl/7ZQXLIjEtbkdOW16VbCVuN8BysS4FqcD0kQ3N282A==', '2024-03-18 09:04:21', 'demo', '::1', 'Chrome', 'Windows 10');
INSERT INTO `sys_user_online` VALUES (15, '971718350e51a3ef017d7dd2959376ac', '7ZUSfVIf2HyYjcv86SKPPs29v003ECPEScsdYsYYqO2wMop+JHFZf/yt1ELqjTJMD9pHUJLWArEmhBWGfrsJWS2XL9AgfCvBwNBD87mX8MF1fsPKYREna3phbaK5zVihZw7cjB08NO3Z8YPtgdxVRQ==', '2024-03-18 09:25:54', 'demo', '::1', 'Chrome', 'Windows 10');
INSERT INTO `sys_user_online` VALUES (24, '28f6ff7ef1b458a8045c28d230cc407d', '7ZUSfVIf2HyYjcv86SKPPs29v003ECPEScsdYsYYqO2stWX3CLiQnNjppjBEfqsS32u585t9PjZ2foOtqiALTZXn1TV10cNP+J+Aa5CDWcsnteYNacuGQZBID8Ab9DYstNmkHzInT0B85Gu0XiPl3g==', '2024-04-12 16:59:11', 'demo', '::1', 'Chrome', 'Windows 10');
-- ----------------------------
-- Table structure for sys_user_post
@ -4718,17 +4749,18 @@ CREATE TABLE `tools_gen_table` (
`excel_imp` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否导入excel',
`overwrite_info` json NULL COMMENT '生成覆盖的文件',
PRIMARY KEY (`table_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 97 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '代码生成业务表' ROW_FORMAT = COMPACT;
) ENGINE = InnoDB AUTO_INCREMENT = 98 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '代码生成业务表' ROW_FORMAT = COMPACT;
-- ----------------------------
-- Records of tools_gen_table
-- ----------------------------
INSERT INTO `tools_gen_table` VALUES (91, 'demo_gen', '代码生成测试表', 'DemoGen', 'crud', 'internal/app/demo', 'demo', 'demo_gen', '代码生成测试', 'gfast', '', '2022-11-01 17:27:43', '2024-03-18 10:17:04', '', b'1', 'id', 'asc', b'1', b'1', b'0', b'0', b'1', '[{\"key\": \"api\", \"value\": true}, {\"key\": \"controller\", \"value\": true}, {\"key\": \"dao\", \"value\": true}, {\"key\": \"dao_internal\", \"value\": true}, {\"key\": \"logic\", \"value\": true}, {\"key\": \"model\", \"value\": true}, {\"key\": \"model_do\", \"value\": true}, {\"key\": \"model_entity\", \"value\": true}, {\"key\": \"router\", \"value\": true}, {\"key\": \"router_func\", \"value\": true}, {\"key\": \"service\", \"value\": true}, {\"key\": \"sql\", \"value\": true}, {\"key\": \"tsApi\", \"value\": true}, {\"key\": \"tsModel\", \"value\": true}, {\"key\": \"vue\", \"value\": true}, {\"key\": \"vueDetail\", \"value\": true}, {\"key\": \"vueEdit\", \"value\": true}]');
INSERT INTO `tools_gen_table` VALUES (92, 'demo_gen_class', '代码生成关联测试表', 'DemoGenClass', 'crud', 'internal/app/demo', 'demo', 'demo_gen_class', '分类信息', 'gfast', '', '2022-11-03 06:36:57', '2024-03-18 10:17:14', '分类', b'1', 'id', 'asc', b'1', b'1', b'0', b'0', b'0', '[{\"key\": \"api\", \"value\": true}, {\"key\": \"controller\", \"value\": true}, {\"key\": \"dao\", \"value\": true}, {\"key\": \"dao_internal\", \"value\": true}, {\"key\": \"logic\", \"value\": true}, {\"key\": \"model\", \"value\": true}, {\"key\": \"model_do\", \"value\": true}, {\"key\": \"model_entity\", \"value\": true}, {\"key\": \"router\", \"value\": true}, {\"key\": \"router_func\", \"value\": true}, {\"key\": \"service\", \"value\": true}, {\"key\": \"sql\", \"value\": true}, {\"key\": \"tsApi\", \"value\": true}, {\"key\": \"tsModel\", \"value\": true}, {\"key\": \"vue\", \"value\": true}, {\"key\": \"vueDetail\", \"value\": true}, {\"key\": \"vueEdit\", \"value\": true}]');
INSERT INTO `tools_gen_table` VALUES (92, 'demo_gen_class', '代码生成关联测试表', 'DemoGenClass', 'crud', 'internal/app/demo', 'demo', 'demo_gen_class', '分类信息', 'gfast', '', '2022-11-03 06:36:57', '2024-03-19 09:29:18', '分类', b'1', 'id', 'asc', b'1', b'1', b'0', b'0', b'0', '[{\"key\": \"api\", \"value\": true}, {\"key\": \"controller\", \"value\": true}, {\"key\": \"dao\", \"value\": true}, {\"key\": \"dao_internal\", \"value\": true}, {\"key\": \"logic\", \"value\": true}, {\"key\": \"model\", \"value\": true}, {\"key\": \"model_do\", \"value\": true}, {\"key\": \"model_entity\", \"value\": true}, {\"key\": \"router\", \"value\": true}, {\"key\": \"router_func\", \"value\": true}, {\"key\": \"service\", \"value\": true}, {\"key\": \"sql\", \"value\": true}, {\"key\": \"tsApi\", \"value\": true}, {\"key\": \"tsModel\", \"value\": true}, {\"key\": \"vue\", \"value\": true}, {\"key\": \"vueDetail\", \"value\": true}, {\"key\": \"vueEdit\", \"value\": true}]');
INSERT INTO `tools_gen_table` VALUES (93, 'demo_gen_tree', '代码生成树形结构测试表', 'DemoGenTree', 'tree', 'internal/app/demo', 'demo', 'demo_gen_tree', '代码生成树形结构测试', 'gfast', '{\"treeCode\":\"id\",\"treeName\":\"demoName\",\"treeParentCode\":\"parentId\"}', '2022-11-29 15:11:34', '2024-03-18 10:17:50', '', b'1', 'id', 'asc', b'1', b'0', b'0', b'1', b'0', '[{\"key\": \"api\", \"value\": true}, {\"key\": \"controller\", \"value\": true}, {\"key\": \"dao\", \"value\": true}, {\"key\": \"dao_internal\", \"value\": true}, {\"key\": \"logic\", \"value\": true}, {\"key\": \"model\", \"value\": true}, {\"key\": \"model_do\", \"value\": true}, {\"key\": \"model_entity\", \"value\": true}, {\"key\": \"router\", \"value\": true}, {\"key\": \"router_func\", \"value\": true}, {\"key\": \"service\", \"value\": true}, {\"key\": \"sql\", \"value\": true}, {\"key\": \"tsApi\", \"value\": true}, {\"key\": \"tsModel\", \"value\": true}, {\"key\": \"vue\", \"value\": true}, {\"key\": \"vueDetail\", \"value\": true}, {\"key\": \"vueEdit\", \"value\": true}]');
INSERT INTO `tools_gen_table` VALUES (94, 'demo_data_auth', '数据权限测试', 'DemoDataAuth', 'crud', 'internal/app/demo', 'demo', 'demo_data_auth', '数据权限测试', 'gfast', '', '2023-02-12 11:18:42', '2024-03-18 10:18:00', '', b'1', 'id', 'asc', b'0', b'0', b'0', b'0', b'0', '[{\"key\": \"api\", \"value\": true}, {\"key\": \"controller\", \"value\": true}, {\"key\": \"dao\", \"value\": true}, {\"key\": \"dao_internal\", \"value\": true}, {\"key\": \"logic\", \"value\": true}, {\"key\": \"model\", \"value\": true}, {\"key\": \"model_do\", \"value\": true}, {\"key\": \"model_entity\", \"value\": true}, {\"key\": \"router\", \"value\": true}, {\"key\": \"router_func\", \"value\": true}, {\"key\": \"service\", \"value\": true}, {\"key\": \"sql\", \"value\": true}, {\"key\": \"tsApi\", \"value\": true}, {\"key\": \"tsModel\", \"value\": true}, {\"key\": \"vue\", \"value\": true}, {\"key\": \"vueDetail\", \"value\": true}, {\"key\": \"vueEdit\", \"value\": true}]');
INSERT INTO `tools_gen_table` VALUES (95, 'demo_snow_id', '雪花ID测试', 'DemoSnowId', 'crud', 'internal/app/demo', 'demo', 'demo_snow_id', '雪花ID测试', 'gfast', '', '2023-09-19 15:34:46', '2024-03-18 10:16:51', '', b'1', 'id', 'asc', b'1', b'1', b'1', b'0', b'0', '[{\"key\": \"api\", \"value\": true}, {\"key\": \"controller\", \"value\": true}, {\"key\": \"dao\", \"value\": true}, {\"key\": \"dao_internal\", \"value\": true}, {\"key\": \"logic\", \"value\": true}, {\"key\": \"model\", \"value\": true}, {\"key\": \"model_do\", \"value\": true}, {\"key\": \"model_entity\", \"value\": true}, {\"key\": \"router\", \"value\": true}, {\"key\": \"router_func\", \"value\": true}, {\"key\": \"service\", \"value\": true}, {\"key\": \"sql\", \"value\": true}, {\"key\": \"tsApi\", \"value\": true}, {\"key\": \"tsModel\", \"value\": true}, {\"key\": \"vue\", \"value\": true}, {\"key\": \"vueDetail\", \"value\": true}, {\"key\": \"vueEdit\", \"value\": true}]');
INSERT INTO `tools_gen_table` VALUES (96, 'demo_city_code', '省市区县和天气预报编码', 'DemoCityCode', 'tree', 'internal/app/demo', 'demo', 'demo_city_code', '省市区县', 'gfast', '{\"treeCode\":\"id\",\"treeName\":\"name\",\"treeParentCode\":\"pid\"}', '2023-11-02 10:38:51', '2024-03-18 10:18:14', '', b'1', 'id', 'asc', b'1', b'0', b'0', b'1', b'0', '[{\"key\": \"api\", \"value\": true}, {\"key\": \"controller\", \"value\": true}, {\"key\": \"dao\", \"value\": true}, {\"key\": \"dao_internal\", \"value\": true}, {\"key\": \"logic\", \"value\": true}, {\"key\": \"model\", \"value\": true}, {\"key\": \"model_do\", \"value\": true}, {\"key\": \"model_entity\", \"value\": true}, {\"key\": \"router\", \"value\": true}, {\"key\": \"router_func\", \"value\": true}, {\"key\": \"service\", \"value\": true}, {\"key\": \"sql\", \"value\": true}, {\"key\": \"tsApi\", \"value\": true}, {\"key\": \"tsModel\", \"value\": true}, {\"key\": \"vue\", \"value\": true}, {\"key\": \"vueDetail\", \"value\": true}, {\"key\": \"vueEdit\", \"value\": true}]');
INSERT INTO `tools_gen_table` VALUES (96, 'demo_city_code', '省市区县和天气预报编码', 'DemoCityCode', 'tree', 'internal/app/demo', 'demo', 'demo_city_code', '省市区县', 'gfast', '{\"treeCode\":\"id\",\"treeName\":\"name\",\"treeParentCode\":\"pid\"}', '2023-11-02 10:38:51', '2024-04-07 09:30:57', '', b'1', 'id', 'asc', b'1', b'0', b'0', b'1', b'0', '[{\"key\": \"api\", \"value\": true}, {\"key\": \"controller\", \"value\": true}, {\"key\": \"dao\", \"value\": true}, {\"key\": \"dao_internal\", \"value\": true}, {\"key\": \"logic\", \"value\": true}, {\"key\": \"model\", \"value\": true}, {\"key\": \"model_do\", \"value\": true}, {\"key\": \"model_entity\", \"value\": true}, {\"key\": \"router\", \"value\": true}, {\"key\": \"router_func\", \"value\": true}, {\"key\": \"service\", \"value\": true}, {\"key\": \"sql\", \"value\": true}, {\"key\": \"tsApi\", \"value\": true}, {\"key\": \"tsModel\", \"value\": true}, {\"key\": \"vue\", \"value\": true}, {\"key\": \"vueDetail\", \"value\": true}, {\"key\": \"vueEdit\", \"value\": true}]');
INSERT INTO `tools_gen_table` VALUES (97, 'product_category', '商品分类表', 'ProductCategory', 'tree', 'internal/app/demo', 'demo', 'product_category', '商品分类表', 'gfast', '{\"treeCode\":\"categoryId\",\"treeName\":\"categoryName\",\"treeParentCode\":\"parentId\"}', '2024-04-07 09:08:30', '2024-04-07 10:08:26', '', b'1', 'category_id', 'asc', b'0', b'0', b'0', b'1', b'0', '[{\"key\": \"api\", \"value\": true}, {\"key\": \"controller\", \"value\": true}, {\"key\": \"dao\", \"value\": true}, {\"key\": \"dao_internal\", \"value\": true}, {\"key\": \"logic\", \"value\": true}, {\"key\": \"model\", \"value\": true}, {\"key\": \"model_do\", \"value\": true}, {\"key\": \"model_entity\", \"value\": true}, {\"key\": \"router\", \"value\": true}, {\"key\": \"router_func\", \"value\": true}, {\"key\": \"service\", \"value\": true}, {\"key\": \"sql\", \"value\": true}, {\"key\": \"tsApi\", \"value\": true}, {\"key\": \"tsModel\", \"value\": true}, {\"key\": \"vue\", \"value\": true}, {\"key\": \"vueDetail\", \"value\": true}, {\"key\": \"vueEdit\", \"value\": true}]');
-- ----------------------------
-- Table structure for tools_gen_table_column
@ -4775,7 +4807,7 @@ CREATE TABLE `tools_gen_table_column` (
`parent_column_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '上级字段名',
`cascade_column_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '级联查询字段',
PRIMARY KEY (`column_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1009 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '代码生成业务表字段' ROW_FORMAT = COMPACT;
) ENGINE = InnoDB AUTO_INCREMENT = 1023 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '代码生成业务表字段' ROW_FORMAT = COMPACT;
-- ----------------------------
-- Records of tools_gen_table_column
@ -4836,5 +4868,19 @@ INSERT INTO `tools_gen_table_column` VALUES (1005, 96, 'pinyin', '城市拼音',
INSERT INTO `tools_gen_table_column` VALUES (1006, 96, 'ext_id', '完整ID', 'varchar(255)', 'string', 'string', 'ExtId', 'extId', b'0', b'0', b'0', b'1', b'0', b'1', b'0', 7, 7, 7, 7, 'EQ', 'input', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', '');
INSERT INTO `tools_gen_table_column` VALUES (1007, 96, 'ext_name', '城市全称', 'varchar(255)', 'string', 'string', 'ExtName', 'extName', b'0', b'0', b'1', b'1', b'1', b'1', b'0', 8, 8, 8, 8, 'LIKE', 'input', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', '');
INSERT INTO `tools_gen_table_column` VALUES (1008, 96, 'weathercode', '天气预报的编码', 'varchar(255)', 'string', 'string', 'Weathercode', 'weathercode', b'0', b'0', b'0', b'1', b'0', b'1', b'0', 9, 9, 9, 9, 'EQ', 'input', '', '', '', '', '', '', '', '', 12, 1, b'0', 100, b'0', b'0', b'0', '', '');
INSERT INTO `tools_gen_table_column` VALUES (1009, 97, 'category_id', '分类ID', 'bigint(10) unsigned', 'uint64', 'number', 'CategoryId', 'categoryId', b'1', b'1', b'1', b'0', b'1', b'1', b'0', 1, 1, 1, 1, 'EQ', 'input', '', '', '', '', '', '', '', '', 12, 1, b'0', 150, b'0', b'0', b'0', '', '');
INSERT INTO `tools_gen_table_column` VALUES (1010, 97, 'category_name', '分类名称', 'varchar(11)', 'string', 'string', 'CategoryName', 'categoryName', b'0', b'0', b'1', b'1', b'1', b'1', b'1', 2, 2, 2, 2, 'LIKE', 'input', '', '', '', '', '', '', '', '', 12, 1, b'0', 150, b'0', b'0', b'0', '', '');
INSERT INTO `tools_gen_table_column` VALUES (1011, 97, 'parent_id', '父分类ID', 'bigint(10) unsigned', 'uint64', 'number', 'ParentId', 'parentId', b'0', b'0', b'0', b'1', b'0', b'1', b'0', 3, 3, 3, 3, 'EQ', 'treeSelect', '', '', '', '', '', '', '', '', 12, 1, b'0', 150, b'0', b'0', b'0', '', '');
INSERT INTO `tools_gen_table_column` VALUES (1012, 97, 'category_pic', '分类图标', 'varchar(255)', 'string', 'string', 'CategoryPic', 'categoryPic', b'0', b'0', b'0', b'1', b'0', b'1', b'0', 4, 4, 4, 4, 'EQ', 'imagefile', '', '', '', '', '', '', '', '', 12, 1, b'0', 150, b'0', b'0', b'0', '', '');
INSERT INTO `tools_gen_table_column` VALUES (1013, 97, 'category_big_pic', '分类图片', 'varchar(255)', 'string', 'string', 'CategoryBigPic', 'categoryBigPic', b'0', b'0', b'0', b'1', b'0', b'1', b'0', 5, 5, 5, 5, 'EQ', 'imagefile', '', '', '', '', '', '', '', '', 12, 1, b'0', 150, b'0', b'0', b'0', '', '');
INSERT INTO `tools_gen_table_column` VALUES (1014, 97, 'category_code', '分类编码', 'varchar(11)', 'string', 'string', 'CategoryCode', 'categoryCode', b'0', b'0', b'1', b'1', b'1', b'1', b'0', 6, 6, 6, 6, 'EQ', 'input', '', '', '', '', '', '', '', '', 12, 1, b'0', 150, b'0', b'0', b'0', '', '');
INSERT INTO `tools_gen_table_column` VALUES (1015, 97, 'category_level', '分类层级', 'tinyint(4)', 'int', 'number', 'CategoryLevel', 'categoryLevel', b'0', b'0', b'0', b'1', b'0', b'1', b'0', 7, 7, 7, 7, 'EQ', 'input', '', '', '', '', '', '', '', '', 12, 1, b'0', 150, b'0', b'0', b'0', '', '');
INSERT INTO `tools_gen_table_column` VALUES (1016, 97, 'category_status', '分类状态', 'tinyint(4)', 'int', 'number', 'CategoryStatus', 'categoryStatus', b'0', b'0', b'1', b'1', b'0', b'1', b'0', 8, 8, 8, 8, 'EQ', 'radio', '', '', '', '', '', '', '', '', 12, 1, b'0', 150, b'0', b'0', b'0', '', '');
INSERT INTO `tools_gen_table_column` VALUES (1017, 97, 'is_show', '是否推荐', 'tinyint(4)', 'int', 'number', 'IsShow', 'isShow', b'0', b'0', b'0', b'1', b'0', b'1', b'0', 9, 9, 9, 9, 'EQ', 'input', '', '', '', '', '', '', '', '', 12, 1, b'0', 150, b'0', b'0', b'0', '', '');
INSERT INTO `tools_gen_table_column` VALUES (1018, 97, 'sort', '排序方式(数字越小越靠前)', 'int(11) unsigned', 'uint', 'number', 'Sort', 'sort', b'0', b'0', b'0', b'1', b'1', b'1', b'0', 10, 10, 10, 10, 'EQ', 'input', '', '', '', '', '', '', '', '', 12, 1, b'0', 150, b'0', b'0', b'0', '', '');
INSERT INTO `tools_gen_table_column` VALUES (1019, 97, 'app_id', '应用id', 'int(11) unsigned', 'uint', 'number', 'AppId', 'appId', b'0', b'0', b'0', b'1', b'0', b'1', b'0', 11, 11, 11, 11, 'EQ', 'input', '', '', '', '', '', '', '', '', 12, 1, b'0', 150, b'0', b'0', b'0', '', '');
INSERT INTO `tools_gen_table_column` VALUES (1020, 97, 'created_at', '', 'datetime', 'Time', 'string', 'CreatedAt', 'createdAt', b'0', b'0', b'0', b'0', b'1', b'1', b'0', 12, 12, 12, 12, 'EQ', 'datetime', '', '', '', '', '', '', '', '', 12, 1, b'0', 150, b'0', b'0', b'0', '', '');
INSERT INTO `tools_gen_table_column` VALUES (1021, 97, 'updated_at', '', 'datetime', 'Time', 'string', 'UpdatedAt', 'updatedAt', b'0', b'0', b'0', b'0', b'0', b'0', b'0', 13, 13, 13, 13, 'EQ', 'datetime', '', '', '', '', '', '', '', '', 12, 1, b'0', 150, b'0', b'0', b'0', '', '');
INSERT INTO `tools_gen_table_column` VALUES (1022, 97, 'deleted_at', '', 'datetime', 'Time', 'string', 'DeletedAt', 'deletedAt', b'0', b'0', b'0', b'0', b'0', b'0', b'0', 14, 14, 14, 14, 'EQ', 'datetime', '', '', '', '', '', '', '', '', 12, 1, b'0', 150, b'0', b'0', b'0', '', '');
SET FOREIGN_KEY_CHECKS = 1;

View File

@ -21,7 +21,7 @@ import (
// {{.table.ClassName}}SearchReq 分页请求参数
type {{.table.ClassName}}SearchReq struct {
g.Meta `path:"/list" tags:"{{$.table.FunctionName}}" method:"get" summary:"{{$.table.FunctionName}}列表"`
g.Meta `path:"/list" tags:"{{$.table.FunctionName}}" method:"get" summary:"{{$.table.TableComment}}列表"`
commonApi.Author
model.{{.table.ClassName}}SearchReq
}
@ -36,7 +36,7 @@ type {{.table.ClassName}}SearchRes struct {
{{if .table.ExcelPort }}
// {{.table.ClassName}}ExportReq 导出请求
type {{.table.ClassName}}ExportReq struct {
g.Meta `path:"/export" tags:"{{$.table.FunctionName}}" method:"get" summary:"{{$.table.FunctionName}}导出"`
g.Meta `path:"/export" tags:"{{$.table.FunctionName}}" method:"get" summary:"{{$.table.TableComment}}导出"`
commonApi.Author
model.{{.table.ClassName}}SearchReq
}
@ -58,7 +58,7 @@ type {{.table.ClassName}}ExcelTemplateRes struct {
}
type {{.table.ClassName}}ImportReq struct {
g.Meta `path:"/import" tags:"{{$.table.FunctionName}}" method:"post" summary:"{{$.table.FunctionName}}导入"`
g.Meta `path:"/import" tags:"{{$.table.FunctionName}}" method:"post" summary:"{{$.table.TableComment}}导入"`
commonApi.Author
File *ghttp.UploadFile `p:"file" type:"file" dc:"选择上传文件" v:"required#上传文件必须"`
}
@ -71,7 +71,7 @@ type {{.table.ClassName}}ImportRes struct {
{{if gt (len .table.LinkedTables) 0}}
//相关连表查询数据
type Linked{{$.table.ClassName}}DataSearchReq struct{
g.Meta `path:"/linkedData" tags:"{{$.table.FunctionName}}" method:"get" summary:"{{$.table.FunctionName}}关联表数据"`
g.Meta `path:"/linkedData" tags:"{{$.table.FunctionName}}" method:"get" summary:"{{$.table.TableComment}}关联表数据"`
commonApi.Author
}
{{end}}
@ -87,7 +87,7 @@ type Linked{{$.table.ClassName}}DataSearchRes struct{
// {{.table.ClassName}}AddReq 添加操作请求参数
type {{.table.ClassName}}AddReq struct {
g.Meta `path:"/add" tags:"{{$.table.FunctionName}}" method:"post" summary:"{{$.table.FunctionName}}添加"`
g.Meta `path:"/add" tags:"{{$.table.FunctionName}}" method:"post" summary:"{{$.table.TableComment}}添加"`
commonApi.Author
*model.{{.table.ClassName}}AddReq
}
@ -100,7 +100,7 @@ type {{.table.ClassName}}AddRes struct {
// {{.table.ClassName}}EditReq 修改操作请求参数
type {{.table.ClassName}}EditReq struct {
g.Meta `path:"/edit" tags:"{{$.table.FunctionName}}" method:"put" summary:"{{$.table.FunctionName}}修改"`
g.Meta `path:"/edit" tags:"{{$.table.FunctionName}}" method:"put" summary:"{{$.table.TableComment}}修改"`
commonApi.Author
*model.{{.table.ClassName}}EditReq
}
@ -112,7 +112,7 @@ type {{.table.ClassName}}EditRes struct {
// {{.table.ClassName}}GetReq 获取一条数据请求
type {{.table.ClassName}}GetReq struct {
g.Meta `path:"/get" tags:"{{$.table.FunctionName}}" method:"get" summary:"获取{{$.table.FunctionName}}信息"`
g.Meta `path:"/get" tags:"{{$.table.FunctionName}}" method:"get" summary:"获取{{$.table.TableComment}}信息"`
commonApi.Author
{{$.table.PkColumn.GoField}} {{$.table.PkColumn.GoType}} `p:"{{$.table.PkColumn.HtmlField}}" v:"required#主键必须"` //通过主键获取
}
@ -125,7 +125,7 @@ type {{.table.ClassName}}GetRes struct {
// {{.table.ClassName}}DeleteReq 删除数据请求
type {{.table.ClassName}}DeleteReq struct {
g.Meta `path:"/delete" tags:"{{$.table.FunctionName}}" method:"delete" summary:"删除{{$.table.FunctionName}}"`
g.Meta `path:"/delete" tags:"{{$.table.FunctionName}}" method:"delete" summary:"删除{{$.table.TableComment}}"`
commonApi.Author
{{$.table.PkColumn.GoField}}s []{{$.table.PkColumn.GoType}} `p:"{{$.table.PkColumn.HtmlField}}s" v:"required#主键必须"` //通过主键删除
}

View File

@ -29,44 +29,44 @@ select @now := now();
-- 目录 SQL
INSERT INTO `sys_auth_rule` (`pid`,`name`,`title`,`icon`,`condition`,`remark`,`menu_type`,`weigh`,`is_cached`,`is_hide`,`path`,`link_url`,`component`,`is_iframe`,`module_type`,`model_id`,`created_at`,`updated_at` )
VALUES(0,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}','{{.table.FunctionName}}管理','iconfont icon-fuwenbenkuang','','{{.table.FunctionName}}管理',0,0,1,0,'/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}','','layout/routerView/parent',0,'sys_admin',0,@now,@now);
VALUES(0,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}','{{.table.TableComment}}管理','iconfont icon-fuwenbenkuang','','{{.table.TableComment}}管理',0,0,1,0,'/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}','','layout/routerView/parent',0,'sys_admin',0,@now,@now);
-- 菜单父目录ID
SELECT @parentId := LAST_INSERT_ID();
-- 菜单 SQL
INSERT INTO `sys_auth_rule` (`pid`,`name`,`title`,`icon`,`condition`,`remark`,`menu_type`,`weigh`,`is_cached`,`is_hide`,`path`,`link_url`,`component`,`is_iframe`,`module_type`,`model_id`,`created_at`,`updated_at`)
VALUES(@parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/list','{{.table.FunctionName}}列表','ele-Fold','','{{.table.FunctionName}}列表',1,0,1,0,'/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/list','','{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/list/index',0,'sys_admin',0,@now,@now);
VALUES(@parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/list','{{.table.TableComment}}列表','ele-Fold','','{{.table.TableComment}}列表',1,0,1,0,'/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/list','','{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/list/index',0,'sys_admin',0,@now,@now);
-- 按钮父目录ID
SELECT @parentId := LAST_INSERT_ID();
-- 按钮 SQL
INSERT INTO `sys_auth_rule` (`pid`,`name`,`title`,`icon`,`condition`,`remark`,`menu_type`,`weigh`,`is_cached`,`is_hide`,`path`,`link_url`,`component`,`is_iframe`,`module_type`,`model_id`,`created_at`,`updated_at`)
VALUES(@parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/get','{{.table.FunctionName}}查询','','','{{.table.FunctionName}}查询',2,0,1,0,'','','',0,'sys_admin',0,@now,@now);
VALUES(@parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/get','{{.table.TableComment}}查询','','','{{.table.TableComment}}查询',2,0,1,0,'','','',0,'sys_admin',0,@now,@now);
INSERT INTO `sys_auth_rule` (`pid`,`name`,`title`,`icon`,`condition`,`remark`,`menu_type`,`weigh`,`is_cached`,`is_hide`,`path`,`link_url`,`component`,`is_iframe`,`module_type`,`model_id`,`created_at`,`updated_at`)
VALUES(@parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/add','{{.table.FunctionName}}添加','','','{{.table.FunctionName}}添加',2,0,1,0,'','','',0,'sys_admin',0,@now,@now);
VALUES(@parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/add','{{.table.TableComment}}添加','','','{{.table.TableComment}}添加',2,0,1,0,'','','',0,'sys_admin',0,@now,@now);
INSERT INTO `sys_auth_rule` (`pid`,`name`,`title`,`icon`,`condition`,`remark`,`menu_type`,`weigh`,`is_cached`,`is_hide`,`path`,`link_url`,`component`,`is_iframe`,`module_type`,`model_id`,`created_at`,`updated_at`)
VALUES(@parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/edit','{{.table.FunctionName}}修改','','','{{.table.FunctionName}}修改',2,0,1,0,'','','',0,'sys_admin',0,@now,@now);
VALUES(@parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/edit','{{.table.TableComment}}修改','','','{{.table.TableComment}}修改',2,0,1,0,'','','',0,'sys_admin',0,@now,@now);
INSERT INTO `sys_auth_rule` (`pid`,`name`,`title`,`icon`,`condition`,`remark`,`menu_type`,`weigh`,`is_cached`,`is_hide`,`path`,`link_url`,`component`,`is_iframe`,`module_type`,`model_id`,`created_at`,`updated_at`)
VALUES(@parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/delete','{{.table.FunctionName}}删除','','','{{.table.FunctionName}}删除',2,0,1,0,'','','',0,'sys_admin',0,@now,@now);
VALUES(@parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/delete','{{.table.TableComment}}删除','','','{{.table.TableComment}}删除',2,0,1,0,'','','',0,'sys_admin',0,@now,@now);
{{if .table.ExcelPort}}
INSERT INTO `sys_auth_rule` (`pid`,`name`,`title`,`icon`,`condition`,`remark`,`menu_type`,`weigh`,`is_cached`,`is_hide`,`path`,`link_url`,`component`,`is_iframe`,`module_type`,`model_id`,`created_at`,`updated_at`)
VALUES(@parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/export','{{.table.FunctionName}}导出','','','{{.table.FunctionName}}导出',2,0,1,0,'','','',0,'sys_admin',0,@now,@now);
VALUES(@parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/export','{{.table.TableComment}}导出','','','{{.table.TableComment}}导出',2,0,1,0,'','','',0,'sys_admin',0,@now,@now);
{{end}}
{{if .table.ExcelImp}}
INSERT INTO `sys_auth_rule` (`pid`,`name`,`title`,`icon`,`condition`,`remark`,`menu_type`,`weigh`,`is_cached`,`is_hide`,`path`,`link_url`,`component`,`is_iframe`,`module_type`,`model_id`,`created_at`,`updated_at`)
VALUES(@parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/import','{{.table.FunctionName}}导入','','','{{.table.FunctionName}}导入',2,0,1,0,'','','',0,'sys_admin',0,@now,@now);
VALUES(@parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/import','{{.table.TableComment}}导入','','','{{.table.TableComment}}导入',2,0,1,0,'','','',0,'sys_admin',0,@now,@now);
{{end}}
{{range $index,$column:= .table.Columns}}
{{if and $column.IsStatus $column.IsList}}
INSERT INTO `sys_auth_rule` (`pid`,`name`,`title`,`icon`,`condition`,`remark`,`menu_type`,`weigh`,`is_cached`,`is_hide`,`path`,`link_url`,`component`,`is_iframe`,`module_type`,`model_id`,`created_at`,`updated_at`)
VALUES(@parentId,'{{.apiVersion}}/{{.modulePath}}/{{$.table.BusinessName | CaseCamelLower}}/change{{$column.GoField}}','{{$.table.FunctionName}}{{$column.ColumnComment}}修改','','','{{$.table.FunctionName}}{{$column.ColumnComment}}修改',2,0,1,0,'','','',0,'sys_admin',0,@now,@now);
VALUES(@parentId,'{{.apiVersion}}/{{.modulePath}}/{{$.table.BusinessName | CaseCamelLower}}/change{{$column.GoField}}','{{$.table.TableComment}}{{$column.ColumnComment}}修改','','','{{$.table.TableComment}}{{$column.ColumnComment}}修改',2,0,1,0,'','','',0,'sys_admin',0,@now,@now);
{{end}}
{{end}}

View File

@ -32,39 +32,39 @@ DELETE FROM sys_auth_rule WHERE name = '{{.apiVersion}}/{{.modulePath}}/{{$.tabl
-- 目录 SQL
INSERT INTO sys_auth_rule (pid,name,title,icon,condition,remark,menu_type,weigh,is_cached,is_hide,path,link_url,component,is_iframe,module_type,model_id,created_at,updated_at )
VALUES(0,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}','{{.table.FunctionName}}管理','iconfont icon-fuwenbenkuang','','{{.table.FunctionName}}管理',0,0,1,0,'/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}','','layout/routerView/parent',0,'sys_admin',0,v_time,v_time) RETURNING id INTO parentId;
VALUES(0,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}','{{.table.TableComment}}管理','iconfont icon-fuwenbenkuang','','{{.table.TableComment}}管理',0,0,1,0,'/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}','','layout/routerView/parent',0,'sys_admin',0,v_time,v_time) RETURNING id INTO parentId;
-- 菜单 SQL
INSERT INTO sys_auth_rule (pid,name,title,icon,condition,remark,menu_type,weigh,is_cached,is_hide,path,link_url,component,is_iframe,module_type,model_id,created_at,updated_at)
VALUES(parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/list','{{.table.FunctionName}}列表','ele-Fold','','{{.table.FunctionName}}列表',1,0,1,0,'/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/list','','{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/list/index',0,'sys_admin',0,v_time,v_time) RETURNING id INTO parentId;
VALUES(parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/list','{{.table.TableComment}}列表','ele-Fold','','{{.table.TableComment}}列表',1,0,1,0,'/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/list','','{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/list/index',0,'sys_admin',0,v_time,v_time) RETURNING id INTO parentId;
-- 按钮 SQL
INSERT INTO sys_auth_rule (pid,name,title,icon,condition,remark,menu_type,weigh,is_cached,is_hide,path,link_url,component,is_iframe,module_type,model_id,created_at,updated_at)
VALUES(parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/get','{{.table.FunctionName}}查询','','','{{.table.FunctionName}}查询',2,0,1,0,'','','',0,'sys_admin',0,v_time,v_time);
VALUES(parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/get','{{.table.TableComment}}查询','','','{{.table.TableComment}}查询',2,0,1,0,'','','',0,'sys_admin',0,v_time,v_time);
INSERT INTO sys_auth_rule (pid,name,title,icon,condition,remark,menu_type,weigh,is_cached,is_hide,path,link_url,component,is_iframe,module_type,model_id,created_at,updated_at)
VALUES(parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/add','{{.table.FunctionName}}添加','','','{{.table.FunctionName}}添加',2,0,1,0,'','','',0,'sys_admin',0,v_time,v_time);
VALUES(parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/add','{{.table.TableComment}}添加','','','{{.table.TableComment}}添加',2,0,1,0,'','','',0,'sys_admin',0,v_time,v_time);
INSERT INTO sys_auth_rule (pid,name,title,icon,condition,remark,menu_type,weigh,is_cached,is_hide,path,link_url,component,is_iframe,module_type,model_id,created_at,updated_at)
VALUES(parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/edit','{{.table.FunctionName}}修改','','','{{.table.FunctionName}}修改',2,0,1,0,'','','',0,'sys_admin',0,v_time,v_time);
VALUES(parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/edit','{{.table.TableComment}}修改','','','{{.table.TableComment}}修改',2,0,1,0,'','','',0,'sys_admin',0,v_time,v_time);
INSERT INTO sys_auth_rule (pid,name,title,icon,condition,remark,menu_type,weigh,is_cached,is_hide,path,link_url,component,is_iframe,module_type,model_id,created_at,updated_at)
VALUES(parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/delete','{{.table.FunctionName}}删除','','','{{.table.FunctionName}}删除',2,0,1,0,'','','',0,'sys_admin',0,v_time,v_time);
VALUES(parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/delete','{{.table.TableComment}}删除','','','{{.table.TableComment}}删除',2,0,1,0,'','','',0,'sys_admin',0,v_time,v_time);
{{if .table.ExcelPort}}
INSERT INTO sys_auth_rule (pid,name,title,icon,condition,remark,menu_type,weigh,is_cached,is_hide,path,link_url,component,is_iframe,module_type,model_id,created_at,updated_at)
VALUES(parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/export','{{.table.FunctionName}}导出','','','{{.table.FunctionName}}导出',2,0,1,0,'','','',0,'sys_admin',0,v_time,v_time);
VALUES(parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/export','{{.table.TableComment}}导出','','','{{.table.TableComment}}导出',2,0,1,0,'','','',0,'sys_admin',0,v_time,v_time);
{{end}}
{{if .table.ExcelImp}}
INSERT INTO sys_auth_rule (pid,name,title,icon,condition,remark,menu_type,weigh,is_cached,is_hide,path,link_url,component,is_iframe,module_type,model_id,created_at,updated_at)
VALUES(parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/import','{{.table.FunctionName}}导入','','','{{.table.FunctionName}}导入',2,0,1,0,'','','',0,'sys_admin',0,v_time,v_time);
VALUES(parentId,'{{.apiVersion}}/{{.modulePath}}/{{.table.BusinessName | CaseCamelLower}}/import','{{.table.TableComment}}导入','','','{{.table.TableComment}}导入',2,0,1,0,'','','',0,'sys_admin',0,v_time,v_time);
{{end}}
{{range $index,$column:= .table.Columns}}
{{if and $column.IsStatus $column.IsList}}
INSERT INTO sys_auth_rule (pid,name,title,icon,condition,remark,menu_type,weigh,is_cached,is_hide,path,link_url,component,is_iframe,module_type,model_id,created_at,updated_at)
VALUES(parentId,'{{.apiVersion}}/{{.modulePath}}/{{$.table.BusinessName | CaseCamelLower}}/change{{$column.GoField}}','{{$.table.FunctionName}}{{$column.ColumnComment}}修改','','','{{$.table.FunctionName}}{{$column.ColumnComment}}修改',2,0,1,0,'','','',0,'sys_admin',0,v_time,v_time);
VALUES(parentId,'{{.apiVersion}}/{{.modulePath}}/{{$.table.BusinessName | CaseCamelLower}}/change{{$column.GoField}}','{{$.table.TableComment}}{{$column.ColumnComment}}修改','','','{{$.table.TableComment}}{{$column.ColumnComment}}修改',2,0,1,0,'','','',0,'sys_admin',0,v_time,v_time);
{{end}}
{{end}}
END;

View File

@ -1,5 +1,5 @@
<template>
<!-- {{.table.FunctionName}}详情抽屉 -->
<!-- {{.table.TableComment}}详情抽屉 -->
{{$lens := .table.Columns|len}}
{{$businessName := .table.BusinessName | CaseCamelLower}}
{{$treeParentCode := .table.TreeParentCode}}
@ -8,7 +8,7 @@
<div class="{{.table.ModuleName}}-{{.table.BusinessName|CaseCamelLower}}-detail">
<el-drawer v-model="isShowDialog" size="80%" direction="ltr">
<template #header>
<h4>{{.table.FunctionName}}详情</h4>
<h4>{{.table.TableComment}}详情</h4>
</template>
<el-form ref="formRef" :model="formData" label-width="100px">
{{ $hasRowEnd := true }}
@ -177,6 +177,11 @@
} from "/@/views/{{.modulePath}}/{{$businessName}}/list/component/model"
export default defineComponent({
name:"{{.apiVersion|replace "/" "_"|CaseCamel}}{{.modulePath|replace "/" "_"|CaseCamel}}{{.table.ClassName}}Detail",
{{$hascomponent := false}}
{{if or $imgsImp $tokenImp $fileImp}}
{{$hascomponent = true}}
{{end}}
{{if $hascomponent}}
components:{
{{if $editImp}}
GfUeditor,
@ -188,6 +193,19 @@
uploadFile,
{{end}}
},
{{end}}
{{$hasProps := false}}
{{if eq .table.TplCategory "tree"}}
{{$hasProps = true}}
{{end}}
{{if not $hasProps}}
{{range $index, $column := .table.Columns}}
{{if or (ne $column.DictType "") (ne $column.LinkTableName "") }}
{{$hasProps = true}}
{{end}}
{{end}}
{{end}}
{{if $hasProps}}
props:{
{{range $index, $column := .table.Columns}}
{{if ne $column.DictType ""}}
@ -207,13 +225,14 @@
{{end}}
{{end}}
{{if eq .table.TplCategory "tree"}}
// {{.table.FunctionName}}树选项
// {{.table.TableComment}}树选项
{{$businessName}}Options :{
type:Array,
default:()=>[]
},
{{end}}
},
{{end}}
setup(props,{emit}) {
{{if or $imgsImp $tokenImp $fileImp}}
const baseURL:string|undefined|boolean = import.meta.env.VITE_API_URL

View File

@ -5,10 +5,10 @@
{{$treeCode := .table.TreeCode}}
{{$treeName := .table.TreeName}}
<div class="{{.table.ModuleName}}-{{.table.BusinessName|CaseCamelLower}}-edit">
<!-- 添加或修改{{.table.FunctionName}}对话框 -->
<!-- 添加或修改{{.table.TableComment}}对话框 -->
<el-dialog v-model="isShowDialog" width="800px" :close-on-click-modal="false" :destroy-on-close="true">
<template #header>
<div v-drag="['.{{.table.ModuleName}}-{{.table.BusinessName|CaseCamelLower}}-edit .el-dialog', '.{{.table.ModuleName}}-{{.table.BusinessName|CaseCamelLower}}-edit .el-dialog__header']">{{"{{"}}(!formData.{{.table.PkColumn.HtmlField}} || formData.{{.table.PkColumn.HtmlField}}==0?'添加':'修改')+'{{.table.FunctionName}}'{{"}}"}}</div>
<div v-drag="['.{{.table.ModuleName}}-{{.table.BusinessName|CaseCamelLower}}-edit .el-dialog', '.{{.table.ModuleName}}-{{.table.BusinessName|CaseCamelLower}}-edit .el-dialog__header']">{{"{{"}}(!formData.{{.table.PkColumn.HtmlField}} || formData.{{.table.PkColumn.HtmlField}}==0?'添加':'修改')+'{{.table.TableComment}}'{{"}}"}}</div>
</template>
<el-form ref="formRef" :model="formData" :rules="rules" label-width="120px">
{{if .table.IsPkInsertable}}
@ -301,6 +301,11 @@ import {
} from "/@/views/{{.modulePath}}/{{$businessName}}/list/component/model"
export default defineComponent({
name:"{{.apiVersion|replace "/" "_"|CaseCamel}}{{.modulePath|replace "/" "_"|CaseCamel}}{{.table.ClassName}}Edit",
{{$hascomponent := false}}
{{if or $imgsImp $tokenImp $fileImp}}
{{$hascomponent = true}}
{{end}}
{{if $hascomponent}}
components:{
{{if $editImp}}
GfUeditor,
@ -312,6 +317,19 @@ export default defineComponent({
uploadFile,
{{end}}
},
{{end}}
{{$hasProps := false}}
{{if eq .table.TplCategory "tree"}}
{{$hasProps = true}}
{{end}}
{{if not $hasProps}}
{{range $index, $column := .table.Columns}}
{{if or (ne $column.DictType "") (ne $column.LinkTableName "") }}
{{$hasProps = true}}
{{end}}
{{end}}
{{end}}
{{if $hasProps}}
props:{
{{range $index, $column := .table.Columns}}
{{if ne $column.DictType ""}}
@ -331,13 +349,14 @@ export default defineComponent({
{{end}}
{{end}}
{{if eq .table.TplCategory "tree"}}
// {{.table.FunctionName}}树选项
// {{.table.TableComment}}树选项
{{$businessName}}Options :{
type:Array,
default:()=>[]
},
{{end}}
},
{{end}}
setup(props,{emit}) {
{{if or $imgsImp $tokenImp $fileImp}}
const baseURL:string|undefined|boolean = import.meta.env.VITE_API_URL

View File

@ -468,6 +468,11 @@ export default defineComponent({
})
{{end}}
{{end}}
if(list.length > 0 && typeof list[0].id == "undefined"){
list.map((item:any)=>{
item.id = item.categoryId
})
}
dataList.value = _.clone(res.data.list)
list = proxy.handleTree(res.data.list||[], "{{$treeCode}}", "{{$treeParentCode}}");
state.tableData.data = list;