This commit is contained in:
2025-07-07 20:11:59 +08:00
parent ab0fdbc447
commit 06e3aa2eb3
2009 changed files with 193082 additions and 0 deletions

View File

@ -0,0 +1,21 @@
/*
* @desc:缓存相关
* @company:云南奇讯科技有限公司
* @Author: yixiaohu
* @Date: 2022/3/9 11:25
*/
package consts
const (
CacheModelMem = "memory"
CacheModelRedis = "redis"
// CacheSysDict 字典缓存菜单KEY
CacheSysDict = "sysDict"
// CacheSysDictTag 字典缓存标签
CacheSysDictTag = "sysDictTag"
// CacheSysConfigTag 系统参数配置
CacheSysConfigTag = "sysConfigTag"
)

View File

@ -0,0 +1,8 @@
/*
* @desc:常量
* @company:云南奇讯科技有限公司
* @Author: yixiaohu<yxh669@qq.com>
* @Date: 2022/3/30 11:54
*/
package consts

View File

@ -0,0 +1,11 @@
package consts
const (
UploadPath = "upload_file"
ImgTypeKey = "sys.uploadFile.imageType"
ImgSizeKey = "sys.uploadFile.imageSize"
FileTypeKey = "sys.uploadFile.fileType"
FileSizeKey = "sys.uploadFile.fileSize"
CheckFileTypeImg = "img" // 文件类型(图片)
CheckFileTypeFile = "file" // 文件类型(任意)
)

View File

@ -0,0 +1,19 @@
/*
* @desc:
* @company:云南奇讯科技有限公司
* @Author: yixiaohu
* @Date: 2022/3/4 18:19
*/
package controller
import (
"github.com/gogf/gf/v2/net/ghttp"
)
type BaseController struct {
}
// Init 自动执行的初始化方法
func (c *BaseController) Init(r *ghttp.Request) {
}

View File

@ -0,0 +1,118 @@
package controller
import (
"context"
"regexp"
"strconv"
"strings"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
"github.com/tiger1103/gfast/v3/api/v1/common/coryCommon"
busFolderFile "github.com/tiger1103/gfast/v3/internal/app/system/logic/busFolderFile"
ct "github.com/tiger1103/gfast/v3/internal/app/system/logic/context"
"github.com/tiger1103/gfast/v3/internal/app/wxApplet/dao"
"github.com/tiger1103/gfast/v3/internal/app/wxApplet/model"
"github.com/tiger1103/gfast/v3/library/liberr"
)
// CommmonUpdateFile 修改施工人员图片/文件信息
func CommmonUpdateFile(ctx context.Context, filesListReq []*model.BusConstructionUserFileListRes, id int64, wxOrPc string, openid string, projectId int64) (err error) {
err = g.Try(ctx, func(ctx context.Context) {
// 4、批量修改身份证等图片数据
if filesListReq != nil && id != 0 {
listReq := filesListReq
for i := range listReq {
//根据id+图片类型插入数据,如果数据存在则修改
//if wxOrPc != "1" {
// var str = ""
// busfile := strings.Split(listReq[i].Path, ",")
// for _, imgData := range busfile {
// str = str + strings.Replace(imgData, "file", "wxfile", 1) + ","
// }
// listReq[i].Path = str[0 : len(str)-1]
//}
_, err = dao.BusConstructionUserFile.Ctx(ctx).WherePri(listReq[i].Id).Update(listReq[i])
// 5、将图片信息添加到图库中
pe := strings.Split(listReq[i].Path, ",")
zjId := strconv.FormatUint(ct.New().GetLoginUser(ctx).Id, 10)
if wxOrPc != "1" {
zjId = openid
for i, imgData := range pe {
pe[i] = strings.Replace(imgData, "file", "wxfile", 1)
}
}
// 判断是否是图片,不是就不允许进入图库
for i, imgData := range pe {
re := regexp.MustCompile(`(?i)\.(` + coryCommon.PictureSuffix + `)$`)
match := re.FindString(imgData)
if match != "" {
err = busFolderFile.New().AllPicture(
ctx,
pe,
3,
dao.BusConstructionUserFile.Table(),
listReq[i].Id,
wxOrPc,
zjId,
"",
projectId,
)
}
}
}
}
liberr.ErrIsNil(ctx, err)
})
return
}
// @Title BatchUpdateTheOpenidsOfIndividualTables 2024/4/26 15:07:00
// @Description 批量更新各个表的openid 原因是最开始账号的openid是微信开发生成的如果当前账号进入过了小程序那就根据小程序的微信openid来
// @Auth Cory
// @param openid ---> "openid"
// @Return error ---> "错误信息"
func BatchUpdateTheOpenidsOfIndividualTables(ctx context.Context, openid string) (err error) {
err = g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
err = g.Try(ctx, func(ctx context.Context) {
tableNmaes := []string{
"bus_attendance",
"bus_complaint_box",
"bus_constructiom_user_signature",
"bus_construction_blacklist",
"bus_question_offline",
"bus_question_save",
"bus_question_save_pdf",
"bus_reissue_a_card",
"bus_violation_record",
"sys_project_team_member",
"user_registration",
"bus_askforleave",
}
// 1、批量修改对应表字段
for i := range tableNmaes {
err = updateFunc(ctx, tableNmaes[i], openid)
if err != nil {
liberr.ErrIsNil(ctx, err)
return
}
}
// 2、站班会不一样单独写sql sys_project_team_squad
sql := `UPDATE sys_project_team_squad set participant_id = REPLACE(participant_id,participant_id,` + "'" + openid + "'" + `) WHERE participant_id like '%` + openid + `%'`
_, err = g.DB().Exec(ctx, sql)
liberr.ErrIsNil(ctx, err)
_, err = g.DB().Model("sys_project_team_squad").Ctx(ctx).Unscoped().Where("compere_id", openid).Update(g.Map{"compere_id": openid})
liberr.ErrIsNil(ctx, err)
return
})
return err
})
return
}
func updateFunc(ctx context.Context, tableName string, openid string) (err error) {
op := "openid"
_, err = g.DB().Model(tableName).Ctx(ctx).Unscoped().Where(op, openid).Update(g.Map{op: openid})
return
}

View File

@ -0,0 +1,32 @@
/*
* @desc:验证码获取
* @company:云南奇讯科技有限公司
* @Author: yixiaohu
* @Date: 2022/3/2 17:45
*/
package controller
import (
"context"
"github.com/tiger1103/gfast/v3/api/v1/common"
"github.com/tiger1103/gfast/v3/internal/app/common/service"
)
var Captcha = captchaController{}
type captchaController struct {
}
// Get 获取验证码
func (c *captchaController) Get(ctx context.Context, req *common.CaptchaReq) (res *common.CaptchaRes, err error) {
var (
idKeyC, base64stringC string
)
idKeyC, base64stringC, err = service.Captcha().GetVerifyImgString(ctx)
res = &common.CaptchaRes{
Key: idKeyC,
Img: base64stringC,
}
return
}

View File

@ -0,0 +1,26 @@
package controller
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"github.com/tiger1103/gfast/v3/internal/app/system/dao"
"github.com/tiger1103/gfast/v3/library/liberr"
)
// AuditEntityReq 审核请求参数
type AuditEntityReq struct {
TableName string `p:"table_name" dc:"表名"`
TableId string `p:"table_id" dc:"表ID"`
ProjectId int64 `p:"projectId"`
}
// AuditDataListCommon 设计审核列表
func AuditDataListCommon(ctx context.Context, audit *AuditEntityReq) (err error) {
err = g.Try(ctx, func(ctx context.Context) {
dao.DocumentCompletion.Ctx(ctx).Where("")
liberr.ErrIsNil(ctx, err)
})
return
}
// 根据当前数据的项目id递归推断出根目录id

View File

@ -0,0 +1,24 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package dao
import (
"github.com/tiger1103/gfast/v3/internal/app/common/dao/internal"
)
// casbinRuleDao is the data access object for table casbin_rule.
// You can define custom methods on it to extend its functionality as you wish.
type casbinRuleDao struct {
*internal.CasbinRuleDao
}
var (
// CasbinRule is globally public accessible object for table casbin_rule operations.
CasbinRule = casbinRuleDao{
internal.NewCasbinRuleDao(),
}
)
// Fill with you ideas below.

View File

@ -0,0 +1,84 @@
// ==========================================================================
// 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"
)
// CasbinRuleDao is the data access object for table casbin_rule.
type CasbinRuleDao 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 CasbinRuleColumns // columns contains all the column names of Table for convenient usage.
}
// CasbinRuleColumns defines and stores column names for table casbin_rule.
type CasbinRuleColumns struct {
Ptype string //
V0 string //
V1 string //
V2 string //
V3 string //
V4 string //
V5 string //
}
// casbinRuleColumns holds the columns for table casbin_rule.
var casbinRuleColumns = CasbinRuleColumns{
Ptype: "ptype",
V0: "v0",
V1: "v1",
V2: "v2",
V3: "v3",
V4: "v4",
V5: "v5",
}
// NewCasbinRuleDao creates and returns a new DAO object for table data access.
func NewCasbinRuleDao() *CasbinRuleDao {
return &CasbinRuleDao{
group: "default",
table: "casbin_rule",
columns: casbinRuleColumns,
}
}
// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *CasbinRuleDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of current dao.
func (dao *CasbinRuleDao) Table() string {
return dao.table
}
// Columns returns all column names of current dao.
func (dao *CasbinRuleDao) Columns() CasbinRuleColumns {
return dao.columns
}
// Group returns the configuration group name of database of current dao.
func (dao *CasbinRuleDao) Group() string {
return dao.group
}
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *CasbinRuleDao) 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 *CasbinRuleDao) 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,90 @@
// ==========================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-04-18 21:09:17
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// SysConfigDao is the data access object for table sys_config.
type SysConfigDao 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 SysConfigColumns // columns contains all the column names of Table for convenient usage.
}
// SysConfigColumns defines and stores column names for table sys_config.
type SysConfigColumns struct {
ConfigId string // 参数主键
ConfigName string // 参数名称
ConfigKey string // 参数键名
ConfigValue string // 参数键值
ConfigType string // 系统内置Y是 N否
CreateBy string // 创建者
UpdateBy string // 更新者
Remark string // 备注
CreatedAt string // 创建时间
UpdatedAt string // 修改时间
}
// sysConfigColumns holds the columns for table sys_config.
var sysConfigColumns = SysConfigColumns{
ConfigId: "config_id",
ConfigName: "config_name",
ConfigKey: "config_key",
ConfigValue: "config_value",
ConfigType: "config_type",
CreateBy: "create_by",
UpdateBy: "update_by",
Remark: "remark",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
}
// NewSysConfigDao creates and returns a new DAO object for table data access.
func NewSysConfigDao() *SysConfigDao {
return &SysConfigDao{
group: "default",
table: "sys_config",
columns: sysConfigColumns,
}
}
// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *SysConfigDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of current dao.
func (dao *SysConfigDao) Table() string {
return dao.table
}
// Columns returns all column names of current dao.
func (dao *SysConfigDao) Columns() SysConfigColumns {
return dao.columns
}
// Group returns the configuration group name of database of current dao.
func (dao *SysConfigDao) Group() string {
return dao.group
}
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *SysConfigDao) 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 *SysConfigDao) 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,98 @@
// ==========================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-04-16 16:32:52
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// SysDictDataDao is the data access object for table sys_dict_data.
type SysDictDataDao 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 SysDictDataColumns // columns contains all the column names of Table for convenient usage.
}
// SysDictDataColumns defines and stores column names for table sys_dict_data.
type SysDictDataColumns struct {
DictCode string // 字典编码
DictSort string // 字典排序
DictLabel string // 字典标签
DictValue string // 字典键值
DictType string // 字典类型
CssClass string // 样式属性(其他样式扩展)
ListClass string // 表格回显样式
IsDefault string // 是否默认1是 0否
Status string // 状态0正常 1停用
CreateBy string // 创建者
UpdateBy string // 更新者
Remark string // 备注
CreatedAt string // 创建时间
UpdatedAt string // 修改时间
}
// sysDictDataColumns holds the columns for table sys_dict_data.
var sysDictDataColumns = SysDictDataColumns{
DictCode: "dict_code",
DictSort: "dict_sort",
DictLabel: "dict_label",
DictValue: "dict_value",
DictType: "dict_type",
CssClass: "css_class",
ListClass: "list_class",
IsDefault: "is_default",
Status: "status",
CreateBy: "create_by",
UpdateBy: "update_by",
Remark: "remark",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
}
// NewSysDictDataDao creates and returns a new DAO object for table data access.
func NewSysDictDataDao() *SysDictDataDao {
return &SysDictDataDao{
group: "default",
table: "sys_dict_data",
columns: sysDictDataColumns,
}
}
// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *SysDictDataDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of current dao.
func (dao *SysDictDataDao) Table() string {
return dao.table
}
// Columns returns all column names of current dao.
func (dao *SysDictDataDao) Columns() SysDictDataColumns {
return dao.columns
}
// Group returns the configuration group name of database of current dao.
func (dao *SysDictDataDao) Group() string {
return dao.group
}
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *SysDictDataDao) 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 *SysDictDataDao) 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,88 @@
// ==========================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-04-16 16:32:52
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// SysDictTypeDao is the data access object for table sys_dict_type.
type SysDictTypeDao 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 SysDictTypeColumns // columns contains all the column names of Table for convenient usage.
}
// SysDictTypeColumns defines and stores column names for table sys_dict_type.
type SysDictTypeColumns struct {
DictId string // 字典主键
DictName string // 字典名称
DictType string // 字典类型
Status string // 状态0正常 1停用
CreateBy string // 创建者
UpdateBy string // 更新者
Remark string // 备注
CreatedAt string // 创建日期
UpdatedAt string // 修改日期
}
// sysDictTypeColumns holds the columns for table sys_dict_type.
var sysDictTypeColumns = SysDictTypeColumns{
DictId: "dict_id",
DictName: "dict_name",
DictType: "dict_type",
Status: "status",
CreateBy: "create_by",
UpdateBy: "update_by",
Remark: "remark",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
}
// NewSysDictTypeDao creates and returns a new DAO object for table data access.
func NewSysDictTypeDao() *SysDictTypeDao {
return &SysDictTypeDao{
group: "default",
table: "sys_dict_type",
columns: sysDictTypeColumns,
}
}
// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *SysDictTypeDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of current dao.
func (dao *SysDictTypeDao) Table() string {
return dao.table
}
// Columns returns all column names of current dao.
func (dao *SysDictTypeDao) Columns() SysDictTypeColumns {
return dao.columns
}
// Group returns the configuration group name of database of current dao.
func (dao *SysDictTypeDao) Group() string {
return dao.group
}
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *SysDictTypeDao) 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 *SysDictTypeDao) 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,24 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package dao
import (
"github.com/tiger1103/gfast/v3/internal/app/common/dao/internal"
)
// sysConfigDao is the data access object for table sys_config.
// You can define custom methods on it to extend its functionality as you wish.
type sysConfigDao struct {
*internal.SysConfigDao
}
var (
// SysConfig is globally public accessible object for table sys_config operations.
SysConfig = sysConfigDao{
internal.NewSysConfigDao(),
}
)
// Fill with you ideas below.

View File

@ -0,0 +1,24 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package dao
import (
"github.com/tiger1103/gfast/v3/internal/app/common/dao/internal"
)
// sysDictDataDao is the data access object for table sys_dict_data.
// You can define custom methods on it to extend its functionality as you wish.
type sysDictDataDao struct {
*internal.SysDictDataDao
}
var (
// SysDictData is globally public accessible object for table sys_dict_data operations.
SysDictData = sysDictDataDao{
internal.NewSysDictDataDao(),
}
)
// Fill with you ideas below.

View File

@ -0,0 +1,24 @@
// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================
package dao
import (
"github.com/tiger1103/gfast/v3/internal/app/common/dao/internal"
)
// sysDictTypeDao is the data access object for table sys_dict_type.
// You can define custom methods on it to extend its functionality as you wish.
type sysDictTypeDao struct {
*internal.SysDictTypeDao
}
var (
// SysDictType is globally public accessible object for table sys_dict_type operations.
SysDictType = sysDictTypeDao{
internal.NewSysDictTypeDao(),
}
)
// Fill with you ideas below.

View File

@ -0,0 +1,71 @@
/*
* @desc:大文件上传
* @company:云南奇讯科技有限公司
* @Author: yixiaohu<yxh669@qq.com>
* @Date: 2022/9/27 16:25
*/
package bigUpload
import (
"context"
"github.com/tiger1103/gfast/v3/api/v1/system"
"github.com/tiger1103/gfast/v3/internal/app/common/service"
"github.com/tiger1103/gfast/v3/library/upload_chunk"
)
func init() {
service.RegisterBigUpload(New())
}
func New() *sBigUpload {
return &sBigUpload{}
}
type sBigUpload struct{}
// Upload 上传分片文件
func (s *sBigUpload) Upload(ctx context.Context, req *system.BigUploadReq) (res *system.BigUploadRes, err error) {
uploadChunk := &upload_chunk.UploadChunk{}
result, err := uploadChunk.Upload(req.UploadReq)
if err != nil {
return
}
res = new(system.BigUploadRes)
res.UpLoadRes = *result
return
}
// UploadCheck 上传文件检查
func (s *sBigUpload) UploadCheck(ctx context.Context, req *system.BigUploadCheckReq) (res *system.BigUploadCheckRes, err error) {
uploadChunk := &upload_chunk.UploadChunk{}
result, err := uploadChunk.CheckChunk(req.UploadReq)
if err != nil {
return
}
res = &system.BigUploadCheckRes{
CheckRes: *result,
Identifier: req.Identifier,
TotalChunks: req.TotalChunks,
}
return
}
// UploadMerge 上传文件合并
func (s *sBigUpload) UploadMerge(ctx context.Context, req *system.BigUploadMergeReq) (res *system.BigUploadRes, err error) {
uploadChunk := &upload_chunk.UploadChunk{}
result, err := uploadChunk.MergeChunk(req.UploadReq)
if err != nil {
return nil, err
}
res = &system.BigUploadRes{
UpLoadRes: upload_chunk.UpLoadRes{
BaseRes: result.BaseRes,
NeedMerge: false,
Identifier: req.Identifier,
TotalChunks: req.TotalChunks,
},
}
return
}

View File

@ -0,0 +1,45 @@
/*
* @desc:缓存处理
* @company:云南奇讯科技有限公司
* @Author: yixiaohu<yxh669@qq.com>
* @Date: 2022/9/27 16:33
*/
package cache
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gctx"
"github.com/tiger1103/gfast-cache/cache"
"github.com/tiger1103/gfast/v3/internal/app/common/consts"
"github.com/tiger1103/gfast/v3/internal/app/common/service"
)
func init() {
service.RegisterCache(New())
}
func New() *sCache {
var (
ctx = gctx.New()
cacheContainer *cache.GfCache
)
prefix := g.Cfg().MustGet(ctx, "system.cache.prefix").String()
model := g.Cfg().MustGet(ctx, "system.cache.model").String()
if model == consts.CacheModelRedis {
// redis
cacheContainer = cache.NewRedis(prefix)
} else {
// memory
cacheContainer = cache.New(prefix)
}
return &sCache{
GfCache: cacheContainer,
prefix: prefix,
}
}
type sCache struct {
*cache.GfCache
prefix string
}

View File

@ -0,0 +1,76 @@
/*
* @desc:验证码处理
* @company:云南奇讯科技有限公司
* @Author: yixiaohu<yxh669@qq.com>
* @Date: 2022/9/28 9:01
*/
package captcha
import (
"context"
"github.com/gogf/gf/v2/text/gstr"
"github.com/mojocn/base64Captcha"
"github.com/tiger1103/gfast/v3/internal/app/common/service"
)
func init() {
service.RegisterCaptcha(New())
}
func New() *sCaptcha {
return &sCaptcha{
driver: &base64Captcha.DriverString{
//Height: 80,
//Width: 240,
Height: 100,
Width: 260,
NoiseCount: 50,
ShowLineOptions: 20,
Length: 4,
Source: "0123456789",
//Length: 4,
//Source: "abcdefghjkmnpqrstuvwxyz23456789",
Fonts: []string{"chromohv.ttf"},
},
store: base64Captcha.DefaultMemStore,
}
}
type sCaptcha struct {
driver *base64Captcha.DriverString
store base64Captcha.Store
}
var (
captcha = sCaptcha{
driver: &base64Captcha.DriverString{
Height: 100,
Width: 260,
NoiseCount: 50,
ShowLineOptions: 20,
Length: 4,
Source: "0123456789",
//Length: 4,
//Source: "abcdefghjkmnpqrstuvwxyz23456789",
Fonts: []string{"chromohv.ttf"},
},
store: base64Captcha.DefaultMemStore,
}
)
// GetVerifyImgString 获取字母数字混合验证码
func (s *sCaptcha) GetVerifyImgString(ctx context.Context) (idKeyC string, base64stringC string, err error) {
driver := s.driver.ConvertFonts()
c := base64Captcha.NewCaptcha(driver, s.store)
//idKeyC, base64stringC, _, err = c.Generate()
idKeyC, base64stringC, err = c.Generate()
return
}
// VerifyString 验证输入的验证码是否正确
func (s *sCaptcha) VerifyString(id, answer string) bool {
c := base64Captcha.NewCaptcha(s.driver, s.store)
answer = gstr.ToLower(answer)
return c.Verify(id, answer, true)
}

View File

@ -0,0 +1,16 @@
// ==========================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package logic
import (
_ "github.com/tiger1103/gfast/v3/internal/app/common/logic/bigUpload"
_ "github.com/tiger1103/gfast/v3/internal/app/common/logic/cache"
_ "github.com/tiger1103/gfast/v3/internal/app/common/logic/captcha"
_ "github.com/tiger1103/gfast/v3/internal/app/common/logic/middleware"
_ "github.com/tiger1103/gfast/v3/internal/app/common/logic/sysConfig"
_ "github.com/tiger1103/gfast/v3/internal/app/common/logic/sysDictData"
_ "github.com/tiger1103/gfast/v3/internal/app/common/logic/sysDictType"
_ "github.com/tiger1103/gfast/v3/internal/app/common/logic/upload"
)

View File

@ -0,0 +1,31 @@
/*
* @desc:中间件处理
* @company:云南奇讯科技有限公司
* @Author: yixiaohu<yxh669@qq.com>
* @Date: 2022/9/28 9:08
*/
package middleware
import (
"github.com/gogf/gf/v2/net/ghttp"
"github.com/tiger1103/gfast/v3/internal/app/common/service"
)
func init() {
service.RegisterMiddleware(New())
}
func New() *sMiddleware {
return &sMiddleware{}
}
type sMiddleware struct{}
func (s *sMiddleware) MiddlewareCORS(r *ghttp.Request) {
corsOptions := r.Response.DefaultCORSOptions()
// you can set options
//corsOptions.AllowDomain = []string{"goframe.org", "baidu.com"}
r.Response.CORS(corsOptions)
r.Middleware.Next()
}

View File

@ -0,0 +1,178 @@
/*
* @desc:配置参数管理
* @company:云南奇讯科技有限公司
* @Author: yixiaohu<yxh669@qq.com>
* @Date: 2022/9/28 9:13
*/
package sysConfig
import (
"context"
"errors"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/util/gconv"
"github.com/tiger1103/gfast/v3/api/v1/system"
"github.com/tiger1103/gfast/v3/internal/app/common/consts"
"github.com/tiger1103/gfast/v3/internal/app/common/dao"
"github.com/tiger1103/gfast/v3/internal/app/common/model/do"
"github.com/tiger1103/gfast/v3/internal/app/common/model/entity"
"github.com/tiger1103/gfast/v3/internal/app/common/service"
systemConsts "github.com/tiger1103/gfast/v3/internal/app/system/consts"
"github.com/tiger1103/gfast/v3/library/liberr"
)
func init() {
service.RegisterSysConfig(New())
}
func New() *sSysConfig {
return &sSysConfig{}
}
type sSysConfig struct {
}
// List 系统参数列表
func (s *sSysConfig) List(ctx context.Context, req *system.ConfigSearchReq) (res *system.ConfigSearchRes, err error) {
res = new(system.ConfigSearchRes)
err = g.Try(ctx, func(ctx context.Context) {
m := dao.SysConfig.Ctx(ctx)
if req != nil {
if req.ConfigName != "" {
m = m.Where("config_name like ?", "%"+req.ConfigName+"%")
}
if req.ConfigType != "" {
m = m.Where("config_type = ", gconv.Int(req.ConfigType))
}
if req.ConfigKey != "" {
m = m.Where("config_key like ?", "%"+req.ConfigKey+"%")
}
if len(req.DateRange) > 0 {
m = m.Where("created_at >= ? AND created_at<=?", req.DateRange[0], req.DateRange[1])
}
}
res.Total, err = m.Count()
liberr.ErrIsNil(ctx, err, "获取数据失败")
if req.PageNum == 0 {
req.PageNum = 1
}
res.CurrentPage = req.PageNum
if req.PageSize == 0 {
req.PageSize = systemConsts.PageSize
}
err = m.Page(req.PageNum, req.PageSize).Order("config_id asc").Scan(&res.List)
liberr.ErrIsNil(ctx, err, "获取数据失败")
})
return
}
func (s *sSysConfig) Add(ctx context.Context, req *system.ConfigAddReq, userId uint64) (err error) {
err = g.Try(ctx, func(ctx context.Context) {
err = s.CheckConfigKeyUnique(ctx, req.ConfigKey)
liberr.ErrIsNil(ctx, err)
_, err = dao.SysConfig.Ctx(ctx).Insert(do.SysConfig{
ConfigName: req.ConfigName,
ConfigKey: req.ConfigKey,
ConfigValue: req.ConfigValue,
ConfigType: req.ConfigType,
CreateBy: userId,
Remark: req.Remark,
})
liberr.ErrIsNil(ctx, err, "添加系统参数失败")
//清除缓存
service.Cache().RemoveByTag(ctx, consts.CacheSysConfigTag)
})
return
}
// CheckConfigKeyUnique 验证参数键名是否存在
func (s *sSysConfig) CheckConfigKeyUnique(ctx context.Context, configKey string, configId ...int64) (err error) {
err = g.Try(ctx, func(ctx context.Context) {
data := (*entity.SysConfig)(nil)
m := dao.SysConfig.Ctx(ctx).Fields(dao.SysConfig.Columns().ConfigId).Where(dao.SysConfig.Columns().ConfigKey, configKey)
if len(configId) > 0 {
m = m.Where(dao.SysConfig.Columns().ConfigId+" != ?", configId[0])
}
err = m.Scan(&data)
liberr.ErrIsNil(ctx, err, "校验失败")
if data != nil {
liberr.ErrIsNil(ctx, errors.New("参数键名重复"))
}
})
return
}
// Get 获取系统参数
func (s *sSysConfig) Get(ctx context.Context, id int) (res *system.ConfigGetRes, err error) {
res = new(system.ConfigGetRes)
err = g.Try(ctx, func(ctx context.Context) {
err = dao.SysConfig.Ctx(ctx).WherePri(id).Scan(&res.Data)
liberr.ErrIsNil(ctx, err, "获取系统参数失败")
})
return
}
// Edit 修改系统参数
func (s *sSysConfig) Edit(ctx context.Context, req *system.ConfigEditReq, userId uint64) (err error) {
err = g.Try(ctx, func(ctx context.Context) {
err = s.CheckConfigKeyUnique(ctx, req.ConfigKey, req.ConfigId)
liberr.ErrIsNil(ctx, err)
_, err = dao.SysConfig.Ctx(ctx).WherePri(req.ConfigId).Update(do.SysConfig{
ConfigName: req.ConfigName,
ConfigKey: req.ConfigKey,
ConfigValue: req.ConfigValue,
ConfigType: req.ConfigType,
UpdateBy: userId,
Remark: req.Remark,
})
liberr.ErrIsNil(ctx, err, "修改系统参数失败")
//清除缓存
service.Cache().RemoveByTag(ctx, consts.CacheSysConfigTag)
})
return
}
// Delete 删除系统参数
func (s *sSysConfig) Delete(ctx context.Context, ids []int) (err error) {
err = g.Try(ctx, func(ctx context.Context) {
_, err = dao.SysConfig.Ctx(ctx).Delete(dao.SysConfig.Columns().ConfigId+" in (?)", ids)
liberr.ErrIsNil(ctx, err, "删除失败")
//清除缓存
service.Cache().RemoveByTag(ctx, consts.CacheSysConfigTag)
})
return
}
// GetConfigByKey 通过key获取参数从缓存获取
func (s *sSysConfig) GetConfigByKey(ctx context.Context, key string) (config *entity.SysConfig, err error) {
if key == "" {
err = gerror.New("参数key不能为空")
return
}
cache := service.Cache()
cf := cache.Get(ctx, consts.CacheSysConfigTag+key)
if cf != nil && !cf.IsEmpty() {
err = gconv.Struct(cf, &config)
return
}
config, err = s.GetByKey(ctx, key)
if err != nil {
return
}
if config != nil {
cache.Set(ctx, consts.CacheSysConfigTag+key, config, 0, consts.CacheSysConfigTag)
}
return
}
// GetByKey 通过key获取参数从数据库获取
func (s *sSysConfig) GetByKey(ctx context.Context, key string) (config *entity.SysConfig, err error) {
err = dao.SysConfig.Ctx(ctx).Where("config_key", key).Scan(&config)
if err != nil {
g.Log().Error(ctx, err)
err = gerror.New("获取配置失败")
}
return
}

View File

@ -0,0 +1,173 @@
/*
* @desc:字典数据管理
* @company:云南奇讯科技有限公司
* @Author: yixiaohu<yxh669@qq.com>
* @Date: 2022/9/28 9:22
*/
package sysDictData
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"
"github.com/tiger1103/gfast/v3/api/v1/system"
"github.com/tiger1103/gfast/v3/internal/app/common/consts"
"github.com/tiger1103/gfast/v3/internal/app/common/dao"
"github.com/tiger1103/gfast/v3/internal/app/common/model"
"github.com/tiger1103/gfast/v3/internal/app/common/model/do"
"github.com/tiger1103/gfast/v3/internal/app/common/service"
systemConsts "github.com/tiger1103/gfast/v3/internal/app/system/consts"
"github.com/tiger1103/gfast/v3/library/liberr"
)
func init() {
service.RegisterSysDictData(New())
}
func New() *sSysDictData {
return &sSysDictData{}
}
type sSysDictData struct {
}
// GetDictWithDataByType 通过字典键类型获取选项
func (s *sSysDictData) GetDictWithDataByType(ctx context.Context, req *system.GetDictReq) (dict *system.GetDictRes,
err error) {
cache := service.Cache()
cacheKey := consts.CacheSysDict + "_" + req.DictType
//从缓存获取
iDict := cache.GetOrSetFuncLock(ctx, cacheKey, func(ctx context.Context) (value interface{}, err error) {
err = g.Try(ctx, func(ctx context.Context) {
//从数据库获取
dict = &system.GetDictRes{}
//获取类型数据
err = dao.SysDictType.Ctx(ctx).Where(dao.SysDictType.Columns().DictType, req.DictType).
Where(dao.SysDictType.Columns().Status, 1).Fields(model.DictTypeRes{}).Scan(&dict.Info)
liberr.ErrIsNil(ctx, err, "获取字典类型失败")
err = dao.SysDictData.Ctx(ctx).Fields(model.DictDataRes{}).
Where(dao.SysDictData.Columns().DictType, req.DictType).
Order(dao.SysDictData.Columns().DictSort + " asc," +
dao.SysDictData.Columns().DictCode + " asc").
Scan(&dict.Values)
liberr.ErrIsNil(ctx, err, "获取字典数据失败")
})
value = dict
return
}, 0, consts.CacheSysDictTag)
if iDict != nil {
err = gconv.Struct(iDict, &dict)
if err != nil {
return
}
}
//设置给定的默认值
for _, v := range dict.Values {
if req.DefaultValue != "" {
if gstr.Equal(req.DefaultValue, v.DictValue) {
v.IsDefault = 1
} else {
v.IsDefault = 0
}
}
}
return
}
// List 获取字典数据
func (s *sSysDictData) List(ctx context.Context, req *system.DictDataSearchReq) (res *system.DictDataSearchRes, err error) {
res = new(system.DictDataSearchRes)
err = g.Try(ctx, func(ctx context.Context) {
m := dao.SysDictData.Ctx(ctx)
if req != nil {
if req.DictLabel != "" {
m = m.Where(dao.SysDictData.Columns().DictLabel+" like ?", "%"+req.DictLabel+"%")
}
if req.Status != "" {
m = m.Where(dao.SysDictData.Columns().Status+" = ", gconv.Int(req.Status))
}
if req.DictType != "" {
m = m.Where(dao.SysDictData.Columns().DictType+" = ?", req.DictType)
}
res.Total, err = m.Count()
liberr.ErrIsNil(ctx, err, "获取字典数据失败")
if req.PageNum == 0 {
req.PageNum = 1
}
res.CurrentPage = req.PageNum
}
if req.PageSize == 0 {
req.PageSize = systemConsts.PageSize
}
err = m.Page(req.PageNum, req.PageSize).Order(dao.SysDictData.Columns().DictSort + " asc," +
dao.SysDictData.Columns().DictCode + " asc").Scan(&res.List)
liberr.ErrIsNil(ctx, err, "获取字典数据失败")
})
return
}
func (s *sSysDictData) Add(ctx context.Context, req *system.DictDataAddReq, userId uint64) (err error) {
err = g.Try(ctx, func(ctx context.Context) {
_, err = dao.SysDictData.Ctx(ctx).Insert(do.SysDictData{
DictSort: req.DictSort,
DictLabel: req.DictLabel,
DictValue: req.DictValue,
DictType: req.DictType,
CssClass: req.CssClass,
ListClass: req.ListClass,
IsDefault: req.IsDefault,
Status: req.Status,
CreateBy: userId,
Remark: req.Remark,
})
liberr.ErrIsNil(ctx, err, "添加字典数据失败")
//清除缓存
service.Cache().RemoveByTag(ctx, consts.CacheSysDictTag)
})
return
}
// Get 获取字典数据
func (s *sSysDictData) Get(ctx context.Context, dictCode uint) (res *system.DictDataGetRes, err error) {
res = new(system.DictDataGetRes)
err = g.Try(ctx, func(ctx context.Context) {
err = dao.SysDictData.Ctx(ctx).WherePri(dictCode).Scan(&res.Dict)
liberr.ErrIsNil(ctx, err, "获取字典数据失败")
})
return
}
// Edit 修改字典数据
func (s *sSysDictData) Edit(ctx context.Context, req *system.DictDataEditReq, userId uint64) (err error) {
err = g.Try(ctx, func(ctx context.Context) {
_, err = dao.SysDictData.Ctx(ctx).WherePri(req.DictCode).Update(do.SysDictData{
DictSort: req.DictSort,
DictLabel: req.DictLabel,
DictValue: req.DictValue,
DictType: req.DictType,
CssClass: req.CssClass,
ListClass: req.ListClass,
IsDefault: req.IsDefault,
Status: req.Status,
UpdateBy: userId,
Remark: req.Remark,
})
liberr.ErrIsNil(ctx, err, "修改字典数据失败")
//清除缓存
service.Cache().RemoveByTag(ctx, consts.CacheSysDictTag)
})
return
}
// Delete 删除字典数据
func (s *sSysDictData) Delete(ctx context.Context, ids []int) (err error) {
err = g.Try(ctx, func(ctx context.Context) {
_, err = dao.SysDictData.Ctx(ctx).Where(dao.SysDictData.Columns().DictCode+" in(?)", ids).Delete()
liberr.ErrIsNil(ctx, err, "删除字典数据失败")
//清除缓存
service.Cache().RemoveByTag(ctx, consts.CacheSysDictTag)
})
return
}

View File

@ -0,0 +1,186 @@
/*
* @desc:字典类型管理
* @company:云南奇讯科技有限公司
* @Author: yixiaohu<yxh669@qq.com>
* @Date: 2022/9/28 9:26
*/
package sysDictType
import (
"context"
"github.com/gogf/gf/v2/container/garray"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/util/gconv"
"github.com/tiger1103/gfast/v3/api/v1/system"
"github.com/tiger1103/gfast/v3/internal/app/common/consts"
"github.com/tiger1103/gfast/v3/internal/app/common/dao"
"github.com/tiger1103/gfast/v3/internal/app/common/model"
"github.com/tiger1103/gfast/v3/internal/app/common/model/do"
"github.com/tiger1103/gfast/v3/internal/app/common/model/entity"
"github.com/tiger1103/gfast/v3/internal/app/common/service"
systemConsts "github.com/tiger1103/gfast/v3/internal/app/system/consts"
"github.com/tiger1103/gfast/v3/library/liberr"
)
func init() {
service.RegisterSysDictType(New())
}
func New() *sSysDictType {
return &sSysDictType{}
}
type sSysDictType struct {
}
// List 字典类型列表
func (s *sSysDictType) List(ctx context.Context, req *system.DictTypeSearchReq) (res *system.DictTypeSearchRes, err error) {
res = new(system.DictTypeSearchRes)
err = g.Try(ctx, func(ctx context.Context) {
m := dao.SysDictType.Ctx(ctx)
if req.DictName != "" {
m = m.Where(dao.SysDictType.Columns().DictName+" like ?", "%"+req.DictName+"%")
}
if req.DictType != "" {
m = m.Where(dao.SysDictType.Columns().DictType+" like ?", "%"+req.DictType+"%")
}
if req.Status != "" {
m = m.Where(dao.SysDictType.Columns().Status+" = ", gconv.Int(req.Status))
}
res.Total, err = m.Count()
liberr.ErrIsNil(ctx, err, "获取字典类型失败")
if req.PageNum == 0 {
req.PageNum = 1
}
res.CurrentPage = req.PageNum
if req.PageSize == 0 {
req.PageSize = systemConsts.PageSize
}
err = m.Fields(model.SysDictTypeInfoRes{}).Page(req.PageNum, req.PageSize).
Order(dao.SysDictType.Columns().DictId + " asc").Scan(&res.DictTypeList)
liberr.ErrIsNil(ctx, err, "获取字典类型失败")
})
return
}
// Add 添加字典类型
func (s *sSysDictType) Add(ctx context.Context, req *system.DictTypeAddReq, userId uint64) (err error) {
err = g.Try(ctx, func(ctx context.Context) {
err = s.ExistsDictType(ctx, req.DictType)
liberr.ErrIsNil(ctx, err)
_, err = dao.SysDictType.Ctx(ctx).Insert(do.SysDictType{
DictName: req.DictName,
DictType: req.DictType,
Status: req.Status,
CreateBy: userId,
Remark: req.Remark,
})
liberr.ErrIsNil(ctx, err, "添加字典类型失败")
//清除缓存
service.Cache().RemoveByTag(ctx, consts.CacheSysDictTag)
})
return
}
// Edit 修改字典类型
func (s *sSysDictType) Edit(ctx context.Context, req *system.DictTypeEditReq, userId uint64) (err error) {
err = g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
err = g.Try(ctx, func(ctx context.Context) {
err = s.ExistsDictType(ctx, req.DictType, req.DictId)
liberr.ErrIsNil(ctx, err)
dictType := (*entity.SysDictType)(nil)
e := dao.SysDictType.Ctx(ctx).Fields(dao.SysDictType.Columns().DictType).WherePri(req.DictId).Scan(&dictType)
liberr.ErrIsNil(ctx, e, "获取字典类型失败")
liberr.ValueIsNil(dictType, "字典类型不存在")
//修改字典类型
_, e = dao.SysDictType.Ctx(ctx).TX(tx).WherePri(req.DictId).Update(do.SysDictType{
DictName: req.DictName,
DictType: req.DictType,
Status: req.Status,
UpdateBy: userId,
Remark: req.Remark,
})
liberr.ErrIsNil(ctx, e, "修改字典类型失败")
//修改字典数据
_, e = dao.SysDictData.Ctx(ctx).TX(tx).Data(do.SysDictData{DictType: req.DictType}).
Where(dao.SysDictData.Columns().DictType, dictType.DictType).Update()
liberr.ErrIsNil(ctx, e, "修改字典数据失败")
//清除缓存
service.Cache().RemoveByTag(ctx, consts.CacheSysDictTag)
})
return err
})
return
}
func (s *sSysDictType) Get(ctx context.Context, req *system.DictTypeGetReq) (dictType *entity.SysDictType, err error) {
err = g.Try(ctx, func(ctx context.Context) {
err = dao.SysDictType.Ctx(ctx).Where(dao.SysDictType.Columns().DictId, req.DictId).Scan(&dictType)
liberr.ErrIsNil(ctx, err, "获取字典类型失败")
})
return
}
// ExistsDictType 检查类型是否已经存在
func (s *sSysDictType) ExistsDictType(ctx context.Context, dictType string, dictId ...int64) (err error) {
err = g.Try(ctx, func(ctx context.Context) {
m := dao.SysDictType.Ctx(ctx).Fields(dao.SysDictType.Columns().DictId).
Where(dao.SysDictType.Columns().DictType, dictType)
if len(dictId) > 0 {
m = m.Where(dao.SysDictType.Columns().DictId+" !=? ", dictId[0])
}
res, e := m.One()
liberr.ErrIsNil(ctx, e, "sql err")
if !res.IsEmpty() {
liberr.ErrIsNil(ctx, gerror.New("字典类型已存在"))
}
})
return
}
// Delete 删除字典类型
func (s *sSysDictType) Delete(ctx context.Context, dictIds []int) (err error) {
err = g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
err = g.Try(ctx, func(ctx context.Context) {
discs := ([]*entity.SysDictType)(nil)
err = dao.SysDictType.Ctx(ctx).Fields(dao.SysDictType.Columns().DictType).
Where(dao.SysDictType.Columns().DictId+" in (?) ", dictIds).Scan(&discs)
liberr.ErrIsNil(ctx, err, "删除失败")
types := garray.NewStrArray()
for _, dt := range discs {
types.Append(dt.DictType)
}
if types.Len() > 0 {
_, err = dao.SysDictType.Ctx(ctx).TX(tx).Delete(dao.SysDictType.Columns().DictId+" in (?) ", dictIds)
liberr.ErrIsNil(ctx, err, "删除类型失败")
_, err = dao.SysDictData.Ctx(ctx).TX(tx).Delete(dao.SysDictData.Columns().DictType+" in (?) ", types.Slice())
liberr.ErrIsNil(ctx, err, "删除字典数据失败")
}
//清除缓存
service.Cache().RemoveByTag(ctx, consts.CacheSysDictTag)
})
return err
})
return
}
// GetAllDictType 获取所有正常状态下的字典类型
func (s *sSysDictType) GetAllDictType(ctx context.Context) (list []*entity.SysDictType, err error) {
cache := service.Cache()
//从缓存获取
data := cache.Get(ctx, consts.CacheSysDict+"_dict_type_all")
if !data.IsNil() {
err = data.Structs(&list)
return
}
err = g.Try(ctx, func(ctx context.Context) {
err = dao.SysDictType.Ctx(ctx).Where("status", 1).Order("dict_id ASC").Scan(&list)
liberr.ErrIsNil(ctx, err, "获取字典类型数据出错")
//缓存
cache.Set(ctx, consts.CacheSysDict+"_dict_type_all", list, 0, consts.CacheSysDictTag)
})
return
}

View File

@ -0,0 +1,201 @@
/*
* @desc:上传处理
* @company:云南奇讯科技有限公司
* @Author: yixiaohu<yxh669@qq.com>
* @Date: 2022/9/28 9:37
*/
package upload
import (
"context"
"errors"
"fmt"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
"github.com/gogf/gf/v2/text/gregex"
"github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"
"github.com/tiger1103/gfast/v3/api/v1/system"
"github.com/tiger1103/gfast/v3/internal/app/common/consts"
"github.com/tiger1103/gfast/v3/internal/app/common/model/entity"
"github.com/tiger1103/gfast/v3/internal/app/common/service"
"github.com/tiger1103/gfast/v3/library/upload"
)
func init() {
service.RegisterUpload(New())
}
func New() *sUpload {
return &sUpload{}
}
type sUpload struct{}
// UploadFiles 上传多文件
func (s *sUpload) UploadFiles(ctx context.Context, files []*ghttp.UploadFile, checkFileType string, source int) (result system.UploadMultipleRes, err error) {
for _, item := range files {
f, e := s.UploadFile(ctx, item, checkFileType, source)
if e != nil {
return
}
result = append(result, &f)
}
return
}
// UploadFile 上传单文件
func (s *sUpload) UploadFile(ctx context.Context, file *ghttp.UploadFile, checkFileType string, source int) (result system.UploadResponse, err error) {
// 检查文件类型
err = s.CheckType(ctx, checkFileType, file)
if err != nil {
return
}
// 检查文件大小
err = s.CheckSize(ctx, checkFileType, file)
if err != nil {
return
}
uploader := upload.GetUploader(upload.UploaderType(source))
if uploader == nil {
err = errors.New("没有找到上传适配器")
return
}
return uploader.Upload(ctx, file)
}
// CheckSize 检查上传文件大小
func (s *sUpload) CheckSize(ctx context.Context, checkFileType string, file *ghttp.UploadFile) (err error) {
var (
configSize *entity.SysConfig
)
if checkFileType == consts.CheckFileTypeFile {
//获取上传大小配置
configSize, err = s.getUpConfig(ctx, consts.FileSizeKey)
if err != nil {
return
}
} else if checkFileType == consts.CheckFileTypeImg {
//获取上传大小配置
configSize, err = s.getUpConfig(ctx, consts.ImgSizeKey)
if err != nil {
return
}
} else {
return errors.New(fmt.Sprintf("文件检查类型错误:%s|%s", consts.CheckFileTypeFile, consts.CheckFileTypeImg))
}
var rightSize bool
rightSize, err = s.checkSize(configSize.ConfigValue, file.Size)
if err != nil {
return
}
if !rightSize {
err = gerror.New("上传文件超过最大尺寸:" + configSize.ConfigValue)
return
}
return
}
// CheckType 检查上传文件类型
func (s *sUpload) CheckType(ctx context.Context, checkFileType string, file *ghttp.UploadFile) (err error) {
var (
configType *entity.SysConfig
)
if checkFileType == consts.CheckFileTypeFile {
//获取上传类型配置
configType, err = s.getUpConfig(ctx, consts.FileTypeKey)
if err != nil {
return
}
} else if checkFileType == consts.CheckFileTypeImg {
//获取上传类型配置
configType, err = s.getUpConfig(ctx, consts.ImgTypeKey)
if err != nil {
return
}
} else {
return errors.New(fmt.Sprintf("文件检查类型错误:%s|%s", consts.CheckFileTypeFile, consts.CheckFileTypeImg))
}
rightType := s.checkFileType(file.Filename, configType.ConfigValue)
if !rightType {
err = gerror.New("上传文件类型错误,只能包含后缀为:" + configType.ConfigValue + "的文件。")
return
}
return
}
// 获取上传配置
func (s *sUpload) getUpConfig(ctx context.Context, key string) (config *entity.SysConfig, err error) {
config, err = service.SysConfig().GetConfigByKey(ctx, key)
if err != nil {
return
}
if config == nil {
err = gerror.New("上传文件类型未设置,请在后台配置")
return
}
return
}
// 判断上传文件类型是否合法
func (s *sUpload) checkFileType(fileName, typeString string) bool {
suffix := gstr.SubStrRune(fileName, gstr.PosRRune(fileName, ".")+1, gstr.LenRune(fileName)-1)
imageType := gstr.Split(typeString, ",")
rightType := false
for _, v := range imageType {
if gstr.Equal(suffix, v) {
rightType = true
break
}
}
return rightType
}
// 检查文件大小是否合法
func (s *sUpload) checkSize(configSize string, fileSize int64) (bool, error) {
match, err := gregex.MatchString(`^([0-9]+)(?i:([a-z]*))$`, configSize)
if err != nil {
return false, err
}
if len(match) == 0 {
err = gerror.New("上传文件大小未设置请在后台配置格式为30M,30k,30MB")
return false, err
}
var cfSize int64
switch gstr.ToUpper(match[2]) {
case "MB", "M":
cfSize = gconv.Int64(match[1]) * 1024 * 1024
case "KB", "K":
cfSize = gconv.Int64(match[1]) * 1024
case "":
cfSize = gconv.Int64(match[1])
}
if cfSize == 0 {
err = gerror.New("上传文件大小未设置请在后台配置格式为30M,30k,30MB最大单位为MB")
return false, err
}
return cfSize >= fileSize, nil
}
// 静态文件夹目录
func (s *sUpload) getStaticPath(ctx context.Context) string {
value, _ := g.Cfg().Get(ctx, "server.serverRoot")
if !value.IsEmpty() {
return value.String()
}
return ""
}

View File

@ -0,0 +1,21 @@
// =================================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
)
// CasbinRule is the golang structure of table casbin_rule for DAO operations like Where/Data.
type CasbinRule struct {
g.Meta `orm:"table:casbin_rule, do:true"`
Ptype interface{} //
V0 interface{} //
V1 interface{} //
V2 interface{} //
V3 interface{} //
V4 interface{} //
V5 interface{} //
}

View File

@ -0,0 +1,25 @@
// =================================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-04-18 21:09:17
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// SysConfig is the golang structure of table sys_config for DAO operations like Where/Data.
type SysConfig struct {
g.Meta `orm:"table:sys_config, do:true"`
ConfigId interface{} // 参数主键
ConfigName interface{} // 参数名称
ConfigKey interface{} // 参数键名
ConfigValue interface{} // 参数键值
ConfigType interface{} // 系统内置Y是 N否
CreateBy interface{} // 创建者
UpdateBy interface{} // 更新者
Remark interface{} // 备注
CreatedAt *gtime.Time // 创建时间
UpdatedAt *gtime.Time // 修改时间
}

View File

@ -0,0 +1,29 @@
// =================================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-04-16 16:32:52
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// SysDictData is the golang structure of table sys_dict_data for DAO operations like Where/Data.
type SysDictData struct {
g.Meta `orm:"table:sys_dict_data, do:true"`
DictCode interface{} // 字典编码
DictSort interface{} // 字典排序
DictLabel interface{} // 字典标签
DictValue interface{} // 字典键值
DictType interface{} // 字典类型
CssClass interface{} // 样式属性(其他样式扩展)
ListClass interface{} // 表格回显样式
IsDefault interface{} // 是否默认1是 0否
Status interface{} // 状态0正常 1停用
CreateBy interface{} // 创建者
UpdateBy interface{} // 更新者
Remark interface{} // 备注
CreatedAt *gtime.Time // 创建时间
UpdatedAt *gtime.Time // 修改时间
}

View File

@ -0,0 +1,24 @@
// =================================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-04-16 16:32:52
// =================================================================================
package do
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// SysDictType is the golang structure of table sys_dict_type for DAO operations like Where/Data.
type SysDictType struct {
g.Meta `orm:"table:sys_dict_type, do:true"`
DictId interface{} // 字典主键
DictName interface{} // 字典名称
DictType interface{} // 字典类型
Status interface{} // 状态0正常 1停用
CreateBy interface{} // 创建者
UpdateBy interface{} // 更新者
Remark interface{} // 备注
CreatedAt *gtime.Time // 创建日期
UpdatedAt *gtime.Time // 修改日期
}

View File

@ -0,0 +1,16 @@
// =================================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT.
// =================================================================================
package entity
// CasbinRule is the golang structure for table casbin_rule.
type CasbinRule struct {
Ptype string `json:"ptype" description:""`
V0 string `json:"v0" description:""`
V1 string `json:"v1" description:""`
V2 string `json:"v2" description:""`
V3 string `json:"v3" description:""`
V4 string `json:"v4" description:""`
V5 string `json:"v5" description:""`
}

View File

@ -0,0 +1,23 @@
// =================================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-04-18 21:09:17
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/os/gtime"
)
// SysConfig is the golang structure for table sys_config.
type SysConfig struct {
ConfigId uint `json:"configId" description:"参数主键"`
ConfigName string `json:"configName" description:"参数名称"`
ConfigKey string `json:"configKey" description:"参数键名"`
ConfigValue string `json:"configValue" description:"参数键值"`
ConfigType int `json:"configType" description:"系统内置Y是 N否"`
CreateBy uint `json:"createBy" description:"创建者"`
UpdateBy uint `json:"updateBy" description:"更新者"`
Remark string `json:"remark" description:"备注"`
CreatedAt *gtime.Time `json:"createdAt" description:"创建时间"`
UpdatedAt *gtime.Time `json:"updatedAt" description:"修改时间"`
}

View File

@ -0,0 +1,27 @@
// =================================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-04-16 16:32:52
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/os/gtime"
)
// SysDictData is the golang structure for table sys_dict_data.
type SysDictData struct {
DictCode int64 `json:"dictCode" description:"字典编码"`
DictSort int `json:"dictSort" description:"字典排序"`
DictLabel string `json:"dictLabel" description:"字典标签"`
DictValue string `json:"dictValue" description:"字典键值"`
DictType string `json:"dictType" description:"字典类型"`
CssClass string `json:"cssClass" description:"样式属性(其他样式扩展)"`
ListClass string `json:"listClass" description:"表格回显样式"`
IsDefault int `json:"isDefault" description:"是否默认1是 0否"`
Status int `json:"status" description:"状态0正常 1停用"`
CreateBy uint64 `json:"createBy" description:"创建者"`
UpdateBy uint64 `json:"updateBy" description:"更新者"`
Remark string `json:"remark" description:"备注"`
CreatedAt *gtime.Time `json:"createdAt" description:"创建时间"`
UpdatedAt *gtime.Time `json:"updatedAt" description:"修改时间"`
}

View File

@ -0,0 +1,22 @@
// =================================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-04-16 16:32:52
// =================================================================================
package entity
import (
"github.com/gogf/gf/v2/os/gtime"
)
// SysDictType is the golang structure for table sys_dict_type.
type SysDictType struct {
DictId uint64 `json:"dictId" description:"字典主键"`
DictName string `json:"dictName" description:"字典名称"`
DictType string `json:"dictType" description:"字典类型"`
Status uint `json:"status" description:"状态0正常 1停用"`
CreateBy uint `json:"createBy" description:"创建者"`
UpdateBy uint `json:"updateBy" description:"更新者"`
Remark string `json:"remark" description:"备注"`
CreatedAt *gtime.Time `json:"createdAt" description:"创建日期"`
UpdatedAt *gtime.Time `json:"updatedAt" description:"修改日期"`
}

View File

@ -0,0 +1,8 @@
/*
* @desc:xxxx功能描述
* @company:云南奇讯科技有限公司
* @Author: yixiaohu<yxh669@qq.com>
* @Date: 2022/3/18 11:56
*/
package model

View File

@ -0,0 +1,21 @@
/*
* @desc:字典数据
* @company:云南奇讯科技有限公司
* @Author: yixiaohu<yxh669@qq.com>
* @Date: 2022/3/18 11:56
*/
package model
type DictTypeRes struct {
DictName string `json:"name"`
Remark string `json:"remark"`
}
// DictDataRes 字典数据
type DictDataRes struct {
DictValue string `json:"key"`
DictLabel string `json:"value"`
IsDefault int `json:"isDefault"`
Remark string `json:"remark"`
}

View File

@ -0,0 +1,19 @@
/*
* @desc:字典类型
* @company:云南奇讯科技有限公司
* @Author: yixiaohu<yxh669@qq.com>
* @Date: 2022/3/18 11:56
*/
package model
import "github.com/gogf/gf/v2/os/gtime"
type SysDictTypeInfoRes struct {
DictId uint64 `orm:"dict_id,primary" json:"dictId"` // 字典主键
DictName string `orm:"dict_name" json:"dictName"` // 字典名称
DictType string `orm:"dict_type,unique" json:"dictType"` // 字典类型
Status uint `orm:"status" json:"status"` // 状态0正常 1停用
Remark string `orm:"remark" json:"remark"` // 备注
CreatedAt *gtime.Time `orm:"created_at" json:"createdAt"` // 创建日期
}

View File

@ -0,0 +1,32 @@
/*
* @desc:token options
* @company:云南奇讯科技有限公司
* @Author: yixiaohu
* @Date: 2022/3/8 16:02
*/
package model
import (
"github.com/gogf/gf/v2/frame/g"
)
type TokenOptions struct {
// server name
ServerName string `json:"serverName"`
// 缓存key (每创建一个实例CacheKey必须不相同)
CacheKey string `json:"cacheKey"`
// 超时时间 默认10天
Timeout int64 `json:"timeout"`
// 缓存刷新时间 默认5天
// 处理携带token的请求时当前时间大于超时时间并小于缓存刷新时间时token将自动刷新即重置token存活时间
// MaxRefresh值为0时,token将不会自动刷新
MaxRefresh int64 `json:"maxRefresh"`
// 是否允许多点登录
MultiLogin bool `json:"multiLogin"`
// Token加密key 32位
EncryptKey []byte `json:"encryptKey"`
// 拦截排除地址
ExcludePaths g.SliceStr `json:"excludePaths"`
CacheModel string `json:"cacheModel"`
}

View File

@ -0,0 +1,15 @@
/*
* @desc:上传文件model
* @company:云南奇讯科技有限公司
* @Author: yixiaohu<yxh669@qq.com>
* @Date: 2022/12/6 15:29
*/
package model
type UpFile struct {
Name string `json:"name"`
Url string `json:"url"`
FileType string `json:"fileType"`
Size uint64 `json:"size"`
}

View File

@ -0,0 +1,28 @@
/*
* @desc:后台路由
* @company:云南奇讯科技有限公司
* @Author: yixiaohu
* @Date: 2022/2/18 17:34
*/
package router
import (
"context"
"github.com/gogf/gf/v2/net/ghttp"
"github.com/tiger1103/gfast/v3/internal/app/common/controller"
)
var R = new(Router)
type Router struct{}
func (router *Router) BindController(ctx context.Context, group *ghttp.RouterGroup) {
group.Group("/pub", func(group *ghttp.RouterGroup) {
group.Group("/captcha", func(group *ghttp.RouterGroup) {
group.Bind(
controller.Captcha,
)
})
})
}

View File

@ -0,0 +1,30 @@
// ================================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT.
// You can delete these comments if you wish manually maintain this interface file.
// ================================================================================
package service
import (
"context"
"github.com/tiger1103/gfast/v3/api/v1/system"
)
type IBigUpload interface {
Upload(ctx context.Context, req *system.BigUploadReq) (res *system.BigUploadRes, err error)
UploadCheck(ctx context.Context, req *system.BigUploadCheckReq) (res *system.BigUploadCheckRes, err error)
UploadMerge(ctx context.Context, req *system.BigUploadMergeReq) (res *system.BigUploadRes, err error)
}
var localBigUpload IBigUpload
func BigUpload() IBigUpload {
if localBigUpload == nil {
panic("implement not found for interface IBigUpload, forgot register?")
}
return localBigUpload
}
func RegisterBigUpload(i IBigUpload) {
localBigUpload = i
}

View File

@ -0,0 +1,29 @@
/*
* @desc:缓存处理
* @company:云南奇讯科技有限公司
* @Author: yixiaohu
* @Date: 2022/3/9 11:15
*/
package service
import (
"github.com/tiger1103/gfast-cache/cache"
)
type ICache interface {
cache.IGCache
}
var c ICache
func Cache() ICache {
if c == nil {
panic("implement not found for interface ICache, forgot register?")
}
return c
}
func RegisterCache(che ICache) {
c = che
}

View File

@ -0,0 +1,28 @@
// ================================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT.
// You can delete these comments if you wish manually maintain this interface file.
// ================================================================================
package service
import (
"context"
)
type ICaptcha interface {
GetVerifyImgString(ctx context.Context) (idKeyC string, base64stringC string, err error)
VerifyString(id, answer string) bool
}
var localCaptcha ICaptcha
func Captcha() ICaptcha {
if localCaptcha == nil {
panic("implement not found for interface ICaptcha, forgot register?")
}
return localCaptcha
}
func RegisterCaptcha(i ICaptcha) {
localCaptcha = i
}

View File

@ -0,0 +1,218 @@
package service
import (
"context"
"github.com/casbin/casbin/v2"
"github.com/casbin/casbin/v2/model"
"github.com/casbin/casbin/v2/persist"
"github.com/gogf/gf/v2/frame/g"
"github.com/tiger1103/gfast/v3/internal/app/common/dao"
"github.com/tiger1103/gfast/v3/internal/app/common/model/entity"
)
type cabinImpl struct{}
type adapterCasbin struct {
Enforcer *casbin.SyncedEnforcer
EnforcerErr error
ctx context.Context
}
var (
cb = cabinImpl{}
ac *adapterCasbin
)
// CasbinEnforcer 获取adapter单例对象
func CasbinEnforcer(ctx context.Context) (enforcer *casbin.SyncedEnforcer, err error) {
ac = cb.newAdapter(ctx)
enforcer = ac.Enforcer
err = ac.EnforcerErr
return
}
// 初始化adapter操作
func (s *cabinImpl) newAdapter(ctx context.Context) (a *adapterCasbin) {
a = new(adapterCasbin)
a.initPolicy(ctx)
a.ctx = ctx
return
}
func (a *adapterCasbin) initPolicy(ctx context.Context) {
// Because the DB is empty at first,
// so we need to load the policy from the file adapter (.CSV) first.
e, err := casbin.NewSyncedEnforcer(g.Cfg().MustGet(ctx, "casbin.modelFile").String(), a)
if err != nil {
a.EnforcerErr = err
return
}
a.Enforcer = e
}
// SavePolicy saves policy to database.
func (a *adapterCasbin) SavePolicy(model model.Model) (err error) {
err = a.dropTable()
if err != nil {
return
}
err = a.createTable()
if err != nil {
return
}
for ptype, ast := range model["p"] {
for _, rule := range ast.Policy {
line := savePolicyLine(ptype, rule)
_, err := dao.CasbinRule.Ctx(a.ctx).Data(line).Insert()
if err != nil {
return err
}
}
}
for ptype, ast := range model["g"] {
for _, rule := range ast.Policy {
line := savePolicyLine(ptype, rule)
_, err := dao.CasbinRule.Ctx(a.ctx).Data(line).Insert()
if err != nil {
return err
}
}
}
return
}
func (a *adapterCasbin) dropTable() (err error) {
return
}
func (a *adapterCasbin) createTable() (err error) {
return
}
// LoadPolicy loads policy from database.
func (a *adapterCasbin) LoadPolicy(model model.Model) error {
var lines []*entity.CasbinRule
if err := dao.CasbinRule.Ctx(a.ctx).Scan(&lines); err != nil {
return err
}
for _, line := range lines {
loadPolicyLine(line, model)
}
return nil
}
// AddPolicy adds a policy rule to the storage.
func (a *adapterCasbin) AddPolicy(sec string, ptype string, rule []string) error {
line := savePolicyLine(ptype, rule)
_, err := dao.CasbinRule.Ctx(a.ctx).Data(line).Insert()
return err
}
// RemovePolicy removes a policy rule from the storage.
func (a *adapterCasbin) RemovePolicy(sec string, ptype string, rule []string) error {
line := savePolicyLine(ptype, rule)
err := rawDelete(a, line)
return err
}
// RemoveFilteredPolicy removes policy rules that match the filter from the storage.
func (a *adapterCasbin) RemoveFilteredPolicy(sec string, ptype string,
fieldIndex int, fieldValues ...string,
) error {
line := &entity.CasbinRule{}
line.Ptype = ptype
if fieldIndex <= 0 && 0 < fieldIndex+len(fieldValues) {
line.V0 = fieldValues[0-fieldIndex]
}
if fieldIndex <= 1 && 1 < fieldIndex+len(fieldValues) {
line.V1 = fieldValues[1-fieldIndex]
}
if fieldIndex <= 2 && 2 < fieldIndex+len(fieldValues) {
line.V2 = fieldValues[2-fieldIndex]
}
if fieldIndex <= 3 && 3 < fieldIndex+len(fieldValues) {
line.V3 = fieldValues[3-fieldIndex]
}
if fieldIndex <= 4 && 4 < fieldIndex+len(fieldValues) {
line.V4 = fieldValues[4-fieldIndex]
}
if fieldIndex <= 5 && 5 < fieldIndex+len(fieldValues) {
line.V5 = fieldValues[5-fieldIndex]
}
err := rawDelete(a, line)
return err
}
func loadPolicyLine(line *entity.CasbinRule, model model.Model) {
lineText := line.Ptype
if line.V0 != "" {
lineText += ", " + line.V0
}
if line.V1 != "" {
lineText += ", " + line.V1
}
if line.V2 != "" {
lineText += ", " + line.V2
}
if line.V3 != "" {
lineText += ", " + line.V3
}
if line.V4 != "" {
lineText += ", " + line.V4
}
if line.V5 != "" {
lineText += ", " + line.V5
}
persist.LoadPolicyLine(lineText, model)
}
func savePolicyLine(ptype string, rule []string) *entity.CasbinRule {
line := &entity.CasbinRule{}
line.Ptype = ptype
if len(rule) > 0 {
line.V0 = rule[0]
}
if len(rule) > 1 {
line.V1 = rule[1]
}
if len(rule) > 2 {
line.V2 = rule[2]
}
if len(rule) > 3 {
line.V3 = rule[3]
}
if len(rule) > 4 {
line.V4 = rule[4]
}
if len(rule) > 5 {
line.V5 = rule[5]
}
return line
}
func rawDelete(a *adapterCasbin, line *entity.CasbinRule) error {
db := dao.CasbinRule.Ctx(a.ctx).Where("ptype = ?", line.Ptype)
if line.V0 != "" {
db = db.Where("v0 = ?", line.V0)
}
if line.V1 != "" {
db = db.Where("v1 = ?", line.V1)
}
if line.V2 != "" {
db = db.Where("v2 = ?", line.V2)
}
if line.V3 != "" {
db = db.Where("v3 = ?", line.V3)
}
if line.V4 != "" {
db = db.Where("v4 = ?", line.V4)
}
if line.V5 != "" {
db = db.Where("v5 = ?", line.V5)
}
_, err := db.Delete()
return err
}

View File

@ -0,0 +1,27 @@
// ================================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT.
// You can delete these comments if you wish manually maintain this interface file.
// ================================================================================
package service
import (
"github.com/gogf/gf/v2/net/ghttp"
)
type IMiddleware interface {
MiddlewareCORS(r *ghttp.Request)
}
var localMiddleware IMiddleware
func Middleware() IMiddleware {
if localMiddleware == nil {
panic("implement not found for interface IMiddleware, forgot register?")
}
return localMiddleware
}
func RegisterMiddleware(i IMiddleware) {
localMiddleware = i
}

View File

@ -0,0 +1,37 @@
// ================================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT.
// You can delete these comments if you wish manually maintain this interface file.
// ================================================================================
package service
import (
"context"
"github.com/tiger1103/gfast/v3/api/v1/system"
"github.com/tiger1103/gfast/v3/internal/app/common/model/entity"
)
type ISysConfig interface {
List(ctx context.Context, req *system.ConfigSearchReq) (res *system.ConfigSearchRes, err error)
Add(ctx context.Context, req *system.ConfigAddReq, userId uint64) (err error)
CheckConfigKeyUnique(ctx context.Context, configKey string, configId ...int64) (err error)
Get(ctx context.Context, id int) (res *system.ConfigGetRes, err error)
Edit(ctx context.Context, req *system.ConfigEditReq, userId uint64) (err error)
Delete(ctx context.Context, ids []int) (err error)
GetConfigByKey(ctx context.Context, key string) (config *entity.SysConfig, err error)
GetByKey(ctx context.Context, key string) (config *entity.SysConfig, err error)
}
var localSysConfig ISysConfig
func SysConfig() ISysConfig {
if localSysConfig == nil {
panic("implement not found for interface ISysConfig, forgot register?")
}
return localSysConfig
}
func RegisterSysConfig(i ISysConfig) {
localSysConfig = i
}

View File

@ -0,0 +1,34 @@
// ================================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT.
// You can delete these comments if you wish manually maintain this interface file.
// ================================================================================
package service
import (
"context"
"github.com/tiger1103/gfast/v3/api/v1/system"
)
type ISysDictData interface {
GetDictWithDataByType(ctx context.Context, req *system.GetDictReq) (dict *system.GetDictRes, err error)
List(ctx context.Context, req *system.DictDataSearchReq) (res *system.DictDataSearchRes, err error)
Add(ctx context.Context, req *system.DictDataAddReq, userId uint64) (err error)
Get(ctx context.Context, dictCode uint) (res *system.DictDataGetRes, err error)
Edit(ctx context.Context, req *system.DictDataEditReq, userId uint64) (err error)
Delete(ctx context.Context, ids []int) (err error)
}
var localSysDictData ISysDictData
func SysDictData() ISysDictData {
if localSysDictData == nil {
panic("implement not found for interface ISysDictData, forgot register?")
}
return localSysDictData
}
func RegisterSysDictData(i ISysDictData) {
localSysDictData = i
}

View File

@ -0,0 +1,36 @@
// ================================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT.
// You can delete these comments if you wish manually maintain this interface file.
// ================================================================================
package service
import (
"context"
"github.com/tiger1103/gfast/v3/api/v1/system"
"github.com/tiger1103/gfast/v3/internal/app/common/model/entity"
)
type ISysDictType interface {
List(ctx context.Context, req *system.DictTypeSearchReq) (res *system.DictTypeSearchRes, err error)
Add(ctx context.Context, req *system.DictTypeAddReq, userId uint64) (err error)
Edit(ctx context.Context, req *system.DictTypeEditReq, userId uint64) (err error)
Get(ctx context.Context, req *system.DictTypeGetReq) (dictType *entity.SysDictType, err error)
ExistsDictType(ctx context.Context, dictType string, dictId ...int64) (err error)
Delete(ctx context.Context, dictIds []int) (err error)
GetAllDictType(ctx context.Context) (list []*entity.SysDictType, err error)
}
var localSysDictType ISysDictType
func SysDictType() ISysDictType {
if localSysDictType == nil {
panic("implement not found for interface ISysDictType, forgot register?")
}
return localSysDictType
}
func RegisterSysDictType(i ISysDictType) {
localSysDictType = i
}

View File

@ -0,0 +1,33 @@
// ================================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT.
// You can delete these comments if you wish manually maintain this interface file.
// ================================================================================
package service
import (
"context"
"github.com/tiger1103/gfast/v3/api/v1/system"
"github.com/gogf/gf/v2/net/ghttp"
)
type IUpload interface {
UploadFiles(ctx context.Context, files []*ghttp.UploadFile, checkFileType string, source int) (result system.UploadMultipleRes, err error)
UploadFile(ctx context.Context, file *ghttp.UploadFile, checkFileType string, source int) (result system.UploadResponse, err error)
CheckSize(ctx context.Context, checkFileType string, file *ghttp.UploadFile) (err error)
CheckType(ctx context.Context, checkFileType string, file *ghttp.UploadFile) (err error)
}
var localUpload IUpload
func Upload() IUpload {
if localUpload == nil {
panic("implement not found for interface IUpload, forgot register?")
}
return localUpload
}
func RegisterUpload(i IUpload) {
localUpload = i
}