mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-28 05:12:32 +08:00
发布v2.8.4版本,更新内容请查看:https://github.com/bufanyun/hotgo/tree/v2.0/docs/guide-zh-CN/addon-version-upgrade.md
This commit is contained in:
@@ -28,7 +28,7 @@ func init() {
|
||||
}
|
||||
|
||||
// List 获取列表
|
||||
func (s *sSysAddons) List(ctx context.Context, in sysin.AddonsListInp) (list []*sysin.AddonsListModel, totalCount int, err error) {
|
||||
func (s *sSysAddons) List(ctx context.Context, in *sysin.AddonsListInp) (list []*sysin.AddonsListModel, totalCount int, err error) {
|
||||
sks := addons.GetSkeletons()
|
||||
if len(sks) == 0 {
|
||||
return
|
||||
@@ -36,7 +36,7 @@ func (s *sSysAddons) List(ctx context.Context, in sysin.AddonsListInp) (list []*
|
||||
|
||||
var (
|
||||
i int
|
||||
_, perPage, offset = form.CalPage(ctx, in.Page, in.PerPage)
|
||||
_, perPage, offset = form.CalPage(in.Page, in.PerPage)
|
||||
)
|
||||
|
||||
for k, skeleton := range sks {
|
||||
@@ -94,7 +94,7 @@ func (s *sSysAddons) List(ctx context.Context, in sysin.AddonsListInp) (list []*
|
||||
}
|
||||
|
||||
// Selects 选项
|
||||
func (s *sSysAddons) Selects(ctx context.Context, in sysin.AddonsSelectsInp) (res *sysin.AddonsSelectsModel, err error) {
|
||||
func (s *sSysAddons) Selects(ctx context.Context, in *sysin.AddonsSelectsInp) (res *sysin.AddonsSelectsModel, err error) {
|
||||
res = new(sysin.AddonsSelectsModel)
|
||||
for k, v := range consts.AddonsGroupNameMap {
|
||||
res.GroupType = append(res.GroupType, &form.Select{
|
||||
@@ -118,7 +118,7 @@ func (s *sSysAddons) Selects(ctx context.Context, in sysin.AddonsSelectsInp) (re
|
||||
}
|
||||
|
||||
// Build 提交生成
|
||||
func (s *sSysAddons) Build(ctx context.Context, in sysin.AddonsBuildInp) (err error) {
|
||||
func (s *sSysAddons) Build(ctx context.Context, in *sysin.AddonsBuildInp) (err error) {
|
||||
genConfig, err := service.SysConfig().GetLoadGenerate(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
@@ -132,16 +132,16 @@ func (s *sSysAddons) Build(ctx context.Context, in sysin.AddonsBuildInp) (err er
|
||||
}
|
||||
|
||||
// Install 安装模块
|
||||
func (s *sSysAddons) Install(ctx context.Context, in sysin.AddonsInstallInp) (err error) {
|
||||
func (s *sSysAddons) Install(ctx context.Context, in *sysin.AddonsInstallInp) (err error) {
|
||||
return addons.Install(in.GetModule())
|
||||
}
|
||||
|
||||
// Upgrade 更新模块
|
||||
func (s *sSysAddons) Upgrade(ctx context.Context, in sysin.AddonsUpgradeInp) (err error) {
|
||||
func (s *sSysAddons) Upgrade(ctx context.Context, in *sysin.AddonsUpgradeInp) (err error) {
|
||||
return addons.Upgrade(in.GetModule())
|
||||
}
|
||||
|
||||
// UnInstall 卸载模块
|
||||
func (s *sSysAddons) UnInstall(ctx context.Context, in sysin.AddonsUnInstallInp) (err error) {
|
||||
func (s *sSysAddons) UnInstall(ctx context.Context, in *sysin.AddonsUnInstallInp) (err error) {
|
||||
return addons.UnInstall(in.GetModule())
|
||||
}
|
||||
|
@@ -32,7 +32,7 @@ func init() {
|
||||
}
|
||||
|
||||
// GetConfigByGroup 获取指定分组的配置
|
||||
func (s *sSysAddonsConfig) GetConfigByGroup(ctx context.Context, in sysin.GetAddonsConfigInp) (res *sysin.GetAddonsConfigModel, err error) {
|
||||
func (s *sSysAddonsConfig) GetConfigByGroup(ctx context.Context, in *sysin.GetAddonsConfigInp) (res *sysin.GetAddonsConfigModel, err error) {
|
||||
if in.AddonName == "" {
|
||||
err = gerror.New("插件名称不能为空")
|
||||
return
|
||||
@@ -84,7 +84,7 @@ func (s *sSysAddonsConfig) ConversionType(ctx context.Context, models *entity.Sy
|
||||
}
|
||||
|
||||
// UpdateConfigByGroup 更新指定分组的配置
|
||||
func (s *sSysAddonsConfig) UpdateConfigByGroup(ctx context.Context, in sysin.UpdateAddonsConfigInp) (err error) {
|
||||
func (s *sSysAddonsConfig) UpdateConfigByGroup(ctx context.Context, in *sysin.UpdateAddonsConfigInp) (err error) {
|
||||
if in.AddonName == "" {
|
||||
err = gerror.New("插件名称不能为空")
|
||||
return
|
||||
|
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"hotgo/internal/dao"
|
||||
"hotgo/internal/library/contexts"
|
||||
"hotgo/internal/library/hgorm/handler"
|
||||
"hotgo/internal/library/storager"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
@@ -33,7 +34,7 @@ func (s *sSysAttachment) Model(ctx context.Context, option ...*handler.Option) *
|
||||
}
|
||||
|
||||
// Delete 删除附件
|
||||
func (s *sSysAttachment) Delete(ctx context.Context, in sysin.AttachmentDeleteInp) (err error) {
|
||||
func (s *sSysAttachment) Delete(ctx context.Context, in *sysin.AttachmentDeleteInp) (err error) {
|
||||
if _, err = s.Model(ctx).WherePri(in.Id).Delete(); err != nil {
|
||||
err = gerror.Wrap(err, "删除附件失败,请稍后重试!")
|
||||
}
|
||||
@@ -41,7 +42,7 @@ func (s *sSysAttachment) Delete(ctx context.Context, in sysin.AttachmentDeleteIn
|
||||
}
|
||||
|
||||
// View 获取附件信息
|
||||
func (s *sSysAttachment) View(ctx context.Context, in sysin.AttachmentViewInp) (res *sysin.AttachmentViewModel, err error) {
|
||||
func (s *sSysAttachment) View(ctx context.Context, in *sysin.AttachmentViewInp) (res *sysin.AttachmentViewModel, err error) {
|
||||
if err = s.Model(ctx).WherePri(in.Id).Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, "获取附件信息失败,请稍后重试!")
|
||||
}
|
||||
@@ -49,21 +50,37 @@ func (s *sSysAttachment) View(ctx context.Context, in sysin.AttachmentViewInp) (
|
||||
}
|
||||
|
||||
// List 获取附件列表
|
||||
func (s *sSysAttachment) List(ctx context.Context, in sysin.AttachmentListInp) (list []*sysin.AttachmentListModel, totalCount int, err error) {
|
||||
func (s *sSysAttachment) List(ctx context.Context, in *sysin.AttachmentListInp) (list []*sysin.AttachmentListModel, totalCount int, err error) {
|
||||
mod := s.Model(ctx)
|
||||
memberId := contexts.GetUserId(ctx)
|
||||
|
||||
if in.MemberId > 0 {
|
||||
// 超管允许查看指定用户的附件
|
||||
if service.AdminMember().VerifySuperId(ctx, memberId) && in.MemberId > 0 {
|
||||
mod = mod.Where(dao.SysAttachment.Columns().MemberId, in.MemberId)
|
||||
} else {
|
||||
mod = mod.Where(dao.SysAttachment.Columns().MemberId, memberId)
|
||||
}
|
||||
|
||||
if in.Drive != "" {
|
||||
mod = mod.Where(dao.SysAttachment.Columns().Drive, in.Drive)
|
||||
}
|
||||
|
||||
if in.Name != "" {
|
||||
mod = mod.WhereLike(dao.SysAttachment.Columns().Name, "%"+in.Name+"%")
|
||||
}
|
||||
|
||||
if in.Status > 0 {
|
||||
mod = mod.Where(dao.SysAttachment.Columns().Status, in.Status)
|
||||
}
|
||||
|
||||
if len(in.UpdatedAt) == 2 {
|
||||
mod = mod.WhereBetween(dao.SysAttachment.Columns().UpdatedAt, in.UpdatedAt[0], in.UpdatedAt[1])
|
||||
}
|
||||
|
||||
if in.Kind != "" {
|
||||
mod = mod.Where(dao.SysAttachment.Columns().Kind, in.Kind)
|
||||
}
|
||||
|
||||
totalCount, err = mod.Count()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, "获取附件数据行失败!")
|
||||
@@ -85,3 +102,12 @@ func (s *sSysAttachment) List(ctx context.Context, in sysin.AttachmentListInp) (
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ClearKind 清空上传类型
|
||||
func (s *sSysAttachment) ClearKind(ctx context.Context, in *sysin.AttachmentClearKindInp) (err error) {
|
||||
memberId := contexts.GetUserId(ctx)
|
||||
if _, err = s.Model(ctx).Where(dao.SysAttachment.Columns().MemberId, memberId).Where(dao.SysAttachment.Columns().Kind, in.Kind).Delete(); err != nil {
|
||||
err = gerror.Wrap(err, "删除附件上传类型失败,请稍后重试!")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@@ -9,14 +9,13 @@ import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/dao"
|
||||
"hotgo/internal/global"
|
||||
"hotgo/internal/model/input/form"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
"hotgo/internal/service"
|
||||
"hotgo/utility/convert"
|
||||
"hotgo/utility/validate"
|
||||
"sync"
|
||||
)
|
||||
|
||||
@@ -33,14 +32,14 @@ func init() {
|
||||
}
|
||||
|
||||
// Delete 删除
|
||||
func (s *sSysBlacklist) Delete(ctx context.Context, in sysin.BlacklistDeleteInp) (err error) {
|
||||
func (s *sSysBlacklist) Delete(ctx context.Context, in *sysin.BlacklistDeleteInp) (err error) {
|
||||
defer s.VariableLoad(ctx, err)
|
||||
_, err = dao.SysBlacklist.Ctx(ctx).Where("id", in.Id).Delete()
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 修改/新增
|
||||
func (s *sSysBlacklist) Edit(ctx context.Context, in sysin.BlacklistEditInp) (err error) {
|
||||
func (s *sSysBlacklist) Edit(ctx context.Context, in *sysin.BlacklistEditInp) (err error) {
|
||||
defer s.VariableLoad(ctx, err)
|
||||
if in.Ip == "" {
|
||||
err = gerror.New("ip不能为空")
|
||||
@@ -59,62 +58,38 @@ func (s *sSysBlacklist) Edit(ctx context.Context, in sysin.BlacklistEditInp) (er
|
||||
}
|
||||
|
||||
// Status 更新部门状态
|
||||
func (s *sSysBlacklist) Status(ctx context.Context, in sysin.BlacklistStatusInp) (err error) {
|
||||
func (s *sSysBlacklist) Status(ctx context.Context, in *sysin.BlacklistStatusInp) (err error) {
|
||||
defer s.VariableLoad(ctx, err)
|
||||
if in.Id <= 0 {
|
||||
err = gerror.New("ID不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
if in.Status <= 0 {
|
||||
err = gerror.New("状态不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
if !validate.InSlice(consts.StatusSlice, in.Status) {
|
||||
err = gerror.New("状态不正确")
|
||||
return
|
||||
}
|
||||
|
||||
// 修改
|
||||
_, err = dao.SysBlacklist.Ctx(ctx).Where("id", in.Id).Data("status", in.Status).Update()
|
||||
return
|
||||
}
|
||||
|
||||
// MaxSort 最大排序
|
||||
func (s *sSysBlacklist) MaxSort(ctx context.Context, in sysin.BlacklistMaxSortInp) (res *sysin.BlacklistMaxSortModel, err error) {
|
||||
if in.Id > 0 {
|
||||
if err = dao.SysBlacklist.Ctx(ctx).Where("id", in.Id).Order("sort desc").Scan(&res); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if res == nil {
|
||||
res = new(sysin.BlacklistMaxSortModel)
|
||||
}
|
||||
|
||||
res.Sort = form.DefaultMaxSort(ctx, res.Sort)
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定字典类型信息
|
||||
func (s *sSysBlacklist) View(ctx context.Context, in sysin.BlacklistViewInp) (res *sysin.BlacklistViewModel, err error) {
|
||||
func (s *sSysBlacklist) View(ctx context.Context, in *sysin.BlacklistViewInp) (res *sysin.BlacklistViewModel, err error) {
|
||||
err = dao.SysBlacklist.Ctx(ctx).Where("id", in.Id).Scan(&res)
|
||||
return
|
||||
}
|
||||
|
||||
// List 获取列表
|
||||
func (s *sSysBlacklist) List(ctx context.Context, in sysin.BlacklistListInp) (list []*sysin.BlacklistListModel, totalCount int, err error) {
|
||||
func (s *sSysBlacklist) List(ctx context.Context, in *sysin.BlacklistListInp) (list []*sysin.BlacklistListModel, totalCount int, err error) {
|
||||
mod := dao.SysBlacklist.Ctx(ctx)
|
||||
cols := dao.SysBlacklist.Columns()
|
||||
|
||||
// 访问路径
|
||||
if in.Ip != "" {
|
||||
mod = mod.Where("ip", in.Ip)
|
||||
mod = mod.WhereLike(cols.Ip, "%"+in.Ip+"%")
|
||||
}
|
||||
|
||||
if in.Remark != "" {
|
||||
mod = mod.WhereLike(cols.Remark, "%"+in.Remark+"%")
|
||||
}
|
||||
|
||||
// 请求方式
|
||||
if in.Status > 0 {
|
||||
mod = mod.Where("status", in.Status)
|
||||
mod = mod.Where(cols.Status, in.Status)
|
||||
}
|
||||
|
||||
if len(in.CreatedAt) == 2 {
|
||||
mod = mod.WhereBetween(cols.CreatedAt, gtime.New(in.CreatedAt[0]), gtime.New(in.CreatedAt[1]))
|
||||
}
|
||||
|
||||
totalCount, err = mod.Count()
|
||||
|
@@ -16,6 +16,7 @@ import (
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/dao"
|
||||
"hotgo/internal/library/payment"
|
||||
"hotgo/internal/library/sms"
|
||||
"hotgo/internal/library/storager"
|
||||
"hotgo/internal/library/token"
|
||||
"hotgo/internal/library/wechat"
|
||||
@@ -56,6 +57,12 @@ func (s *sSysConfig) InitConfig(ctx context.Context) {
|
||||
}
|
||||
storager.SetConfig(upload)
|
||||
|
||||
sm, err := s.GetSms(ctx)
|
||||
if err != nil {
|
||||
g.Log().Fatalf(ctx, "init sms conifg fail:%+v", err)
|
||||
}
|
||||
sms.SetConfig(sm)
|
||||
|
||||
tk, err := s.GetLoadToken(ctx)
|
||||
if err != nil {
|
||||
g.Log().Fatalf(ctx, "init token conifg fail:%+v", err)
|
||||
@@ -65,7 +72,7 @@ func (s *sSysConfig) InitConfig(ctx context.Context) {
|
||||
|
||||
// GetLogin 获取登录配置
|
||||
func (s *sSysConfig) GetLogin(ctx context.Context) (conf *model.LoginConfig, err error) {
|
||||
models, err := s.GetConfigByGroup(ctx, sysin.GetConfigInp{Group: "login"})
|
||||
models, err := s.GetConfigByGroup(ctx, &sysin.GetConfigInp{Group: "login"})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -75,7 +82,7 @@ func (s *sSysConfig) GetLogin(ctx context.Context) (conf *model.LoginConfig, err
|
||||
|
||||
// GetWechat 获取微信配置
|
||||
func (s *sSysConfig) GetWechat(ctx context.Context) (conf *model.WechatConfig, err error) {
|
||||
models, err := s.GetConfigByGroup(ctx, sysin.GetConfigInp{Group: "wechat"})
|
||||
models, err := s.GetConfigByGroup(ctx, &sysin.GetConfigInp{Group: "wechat"})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -85,7 +92,7 @@ func (s *sSysConfig) GetWechat(ctx context.Context) (conf *model.WechatConfig, e
|
||||
|
||||
// GetPay 获取支付配置
|
||||
func (s *sSysConfig) GetPay(ctx context.Context) (conf *model.PayConfig, err error) {
|
||||
models, err := s.GetConfigByGroup(ctx, sysin.GetConfigInp{Group: "pay"})
|
||||
models, err := s.GetConfigByGroup(ctx, &sysin.GetConfigInp{Group: "pay"})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -95,7 +102,7 @@ func (s *sSysConfig) GetPay(ctx context.Context) (conf *model.PayConfig, err err
|
||||
|
||||
// GetSms 获取短信配置
|
||||
func (s *sSysConfig) GetSms(ctx context.Context) (conf *model.SmsConfig, err error) {
|
||||
models, err := s.GetConfigByGroup(ctx, sysin.GetConfigInp{Group: "sms"})
|
||||
models, err := s.GetConfigByGroup(ctx, &sysin.GetConfigInp{Group: "sms"})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -105,7 +112,7 @@ func (s *sSysConfig) GetSms(ctx context.Context) (conf *model.SmsConfig, err err
|
||||
|
||||
// GetGeo 获取地理配置
|
||||
func (s *sSysConfig) GetGeo(ctx context.Context) (conf *model.GeoConfig, err error) {
|
||||
models, err := s.GetConfigByGroup(ctx, sysin.GetConfigInp{Group: "geo"})
|
||||
models, err := s.GetConfigByGroup(ctx, &sysin.GetConfigInp{Group: "geo"})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -115,7 +122,7 @@ func (s *sSysConfig) GetGeo(ctx context.Context) (conf *model.GeoConfig, err err
|
||||
|
||||
// GetUpload 获取上传配置
|
||||
func (s *sSysConfig) GetUpload(ctx context.Context) (conf *model.UploadConfig, err error) {
|
||||
models, err := s.GetConfigByGroup(ctx, sysin.GetConfigInp{Group: "upload"})
|
||||
models, err := s.GetConfigByGroup(ctx, &sysin.GetConfigInp{Group: "upload"})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -125,7 +132,7 @@ func (s *sSysConfig) GetUpload(ctx context.Context) (conf *model.UploadConfig, e
|
||||
|
||||
// GetSmtp 获取邮件配置
|
||||
func (s *sSysConfig) GetSmtp(ctx context.Context) (conf *model.EmailConfig, err error) {
|
||||
models, err := s.GetConfigByGroup(ctx, sysin.GetConfigInp{Group: "smtp"})
|
||||
models, err := s.GetConfigByGroup(ctx, &sysin.GetConfigInp{Group: "smtp"})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -140,7 +147,7 @@ func (s *sSysConfig) GetSmtp(ctx context.Context) (conf *model.EmailConfig, err
|
||||
|
||||
// GetBasic 获取基础配置
|
||||
func (s *sSysConfig) GetBasic(ctx context.Context) (conf *model.BasicConfig, err error) {
|
||||
models, err := s.GetConfigByGroup(ctx, sysin.GetConfigInp{Group: "basic"})
|
||||
models, err := s.GetConfigByGroup(ctx, &sysin.GetConfigInp{Group: "basic"})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -185,7 +192,7 @@ func (s *sSysConfig) GetLoadServeLog(ctx context.Context) (conf *model.ServeLogC
|
||||
}
|
||||
|
||||
// GetConfigByGroup 获取指定分组的配置
|
||||
func (s *sSysConfig) GetConfigByGroup(ctx context.Context, in sysin.GetConfigInp) (res *sysin.GetConfigModel, err error) {
|
||||
func (s *sSysConfig) GetConfigByGroup(ctx context.Context, in *sysin.GetConfigInp) (res *sysin.GetConfigModel, err error) {
|
||||
if in.Group == "" {
|
||||
err = gerror.New("分组不能为空")
|
||||
return
|
||||
@@ -223,7 +230,7 @@ func (s *sSysConfig) ConversionType(ctx context.Context, models *entity.SysConfi
|
||||
}
|
||||
|
||||
// UpdateConfigByGroup 更新指定分组的配置
|
||||
func (s *sSysConfig) UpdateConfigByGroup(ctx context.Context, in sysin.UpdateConfigInp) (err error) {
|
||||
func (s *sSysConfig) UpdateConfigByGroup(ctx context.Context, in *sysin.UpdateConfigInp) (err error) {
|
||||
if in.Group == "" {
|
||||
err = gerror.New("分组不能为空")
|
||||
return
|
||||
@@ -285,7 +292,7 @@ func (s *sSysConfig) getConfigByKey(key string, models []*entity.SysConfig) *ent
|
||||
}
|
||||
|
||||
// syncUpdate 同步更新一些加载配置
|
||||
func (s *sSysConfig) syncUpdate(ctx context.Context, in sysin.UpdateConfigInp) (err error) {
|
||||
func (s *sSysConfig) syncUpdate(ctx context.Context, in *sysin.UpdateConfigInp) (err error) {
|
||||
switch in.Group {
|
||||
case "wechat":
|
||||
wx, err := s.GetWechat(ctx)
|
||||
@@ -302,6 +309,11 @@ func (s *sSysConfig) syncUpdate(ctx context.Context, in sysin.UpdateConfigInp) (
|
||||
if err == nil {
|
||||
storager.SetConfig(upload)
|
||||
}
|
||||
case "sms":
|
||||
sm, err := s.GetSms(ctx)
|
||||
if err == nil {
|
||||
sms.SetConfig(sm)
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
@@ -50,7 +50,7 @@ func (s *sSysCron) StartCron(ctx context.Context) {
|
||||
}
|
||||
|
||||
// Delete 删除
|
||||
func (s *sSysCron) Delete(ctx context.Context, in sysin.CronDeleteInp) (err error) {
|
||||
func (s *sSysCron) Delete(ctx context.Context, in *sysin.CronDeleteInp) (err error) {
|
||||
var models *entity.SysCron
|
||||
if err = dao.SysCron.Ctx(ctx).Where("id", in.Id).Scan(&models); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
@@ -72,7 +72,7 @@ func (s *sSysCron) Delete(ctx context.Context, in sysin.CronDeleteInp) (err erro
|
||||
}
|
||||
|
||||
// Edit 修改/新增
|
||||
func (s *sSysCron) Edit(ctx context.Context, in sysin.CronEditInp) (err error) {
|
||||
func (s *sSysCron) Edit(ctx context.Context, in *sysin.CronEditInp) (err error) {
|
||||
if in.Name == "" {
|
||||
err = gerror.New("标题不能为空")
|
||||
return
|
||||
@@ -95,7 +95,7 @@ func (s *sSysCron) Edit(ctx context.Context, in sysin.CronEditInp) (err error) {
|
||||
}
|
||||
|
||||
// Status 更新状态
|
||||
func (s *sSysCron) Status(ctx context.Context, in sysin.CronStatusInp) (err error) {
|
||||
func (s *sSysCron) Status(ctx context.Context, in *sysin.CronStatusInp) (err error) {
|
||||
if in.Id <= 0 {
|
||||
err = gerror.New("ID不能为空")
|
||||
return
|
||||
@@ -134,7 +134,7 @@ func (s *sSysCron) Status(ctx context.Context, in sysin.CronStatusInp) (err erro
|
||||
}
|
||||
|
||||
// MaxSort 最大排序
|
||||
func (s *sSysCron) MaxSort(ctx context.Context, in sysin.CronMaxSortInp) (res *sysin.CronMaxSortModel, err error) {
|
||||
func (s *sSysCron) MaxSort(ctx context.Context, in *sysin.CronMaxSortInp) (res *sysin.CronMaxSortModel, err error) {
|
||||
if err = dao.SysCron.Ctx(ctx).Where("id", in.Id).Order("sort desc").Scan(&res); err != nil {
|
||||
return
|
||||
}
|
||||
@@ -143,12 +143,12 @@ func (s *sSysCron) MaxSort(ctx context.Context, in sysin.CronMaxSortInp) (res *s
|
||||
res = new(sysin.CronMaxSortModel)
|
||||
}
|
||||
|
||||
res.Sort = form.DefaultMaxSort(ctx, res.Sort)
|
||||
res.Sort = form.DefaultMaxSort(res.Sort)
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定信息
|
||||
func (s *sSysCron) View(ctx context.Context, in sysin.CronViewInp) (res *sysin.CronViewModel, err error) {
|
||||
func (s *sSysCron) View(ctx context.Context, in *sysin.CronViewInp) (res *sysin.CronViewModel, err error) {
|
||||
if err = dao.SysCron.Ctx(ctx).Where("id", in.Id).Scan(&res); err != nil {
|
||||
return
|
||||
}
|
||||
@@ -156,7 +156,7 @@ func (s *sSysCron) View(ctx context.Context, in sysin.CronViewInp) (res *sysin.C
|
||||
}
|
||||
|
||||
// List 获取列表
|
||||
func (s *sSysCron) List(ctx context.Context, in sysin.CronListInp) (list []*sysin.CronListModel, totalCount int, err error) {
|
||||
func (s *sSysCron) List(ctx context.Context, in *sysin.CronListInp) (list []*sysin.CronListModel, totalCount int, err error) {
|
||||
mod := dao.SysCron.Ctx(ctx)
|
||||
|
||||
if in.Name != "" {
|
||||
@@ -189,7 +189,7 @@ func (s *sSysCron) List(ctx context.Context, in sysin.CronListInp) (list []*sysi
|
||||
}
|
||||
|
||||
// OnlineExec 在线执行
|
||||
func (s *sSysCron) OnlineExec(ctx context.Context, in sysin.OnlineExecInp) (err error) {
|
||||
func (s *sSysCron) OnlineExec(ctx context.Context, in *sysin.OnlineExecInp) (err error) {
|
||||
var data *entity.SysCron
|
||||
if err = dao.SysCron.Ctx(ctx).Where(dao.SysCron.Columns().Id, in.Id).Scan(&data); err != nil {
|
||||
return
|
||||
|
@@ -27,13 +27,13 @@ func init() {
|
||||
}
|
||||
|
||||
// Delete 删除
|
||||
func (s *sSysCronGroup) Delete(ctx context.Context, in sysin.CronGroupDeleteInp) (err error) {
|
||||
func (s *sSysCronGroup) Delete(ctx context.Context, in *sysin.CronGroupDeleteInp) (err error) {
|
||||
_, err = dao.SysCronGroup.Ctx(ctx).Where("id", in.Id).Delete()
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 修改/新增
|
||||
func (s *sSysCronGroup) Edit(ctx context.Context, in sysin.CronGroupEditInp) (err error) {
|
||||
func (s *sSysCronGroup) Edit(ctx context.Context, in *sysin.CronGroupEditInp) (err error) {
|
||||
// 修改
|
||||
if in.Id > 0 {
|
||||
if _, err = dao.SysCronGroup.Ctx(ctx).Fields(sysin.CronGroupUpdateFields{}).Where("id", in.Id).Data(in).Update(); err != nil {
|
||||
@@ -50,7 +50,7 @@ func (s *sSysCronGroup) Edit(ctx context.Context, in sysin.CronGroupEditInp) (er
|
||||
}
|
||||
|
||||
// Status 更新状态
|
||||
func (s *sSysCronGroup) Status(ctx context.Context, in sysin.CronGroupStatusInp) (err error) {
|
||||
func (s *sSysCronGroup) Status(ctx context.Context, in *sysin.CronGroupStatusInp) (err error) {
|
||||
if _, err = dao.SysCronGroup.Ctx(ctx).Where("id", in.Id).Data("status", in.Status).Update(); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func (s *sSysCronGroup) Status(ctx context.Context, in sysin.CronGroupStatusInp)
|
||||
}
|
||||
|
||||
// MaxSort 最大排序
|
||||
func (s *sSysCronGroup) MaxSort(ctx context.Context, in sysin.CronGroupMaxSortInp) (res *sysin.CronGroupMaxSortModel, err error) {
|
||||
func (s *sSysCronGroup) MaxSort(ctx context.Context, in *sysin.CronGroupMaxSortInp) (res *sysin.CronGroupMaxSortModel, err error) {
|
||||
if in.Id > 0 {
|
||||
if err = dao.SysCronGroup.Ctx(ctx).Where("id", in.Id).Order("sort desc").Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
@@ -70,12 +70,12 @@ func (s *sSysCronGroup) MaxSort(ctx context.Context, in sysin.CronGroupMaxSortIn
|
||||
res = new(sysin.CronGroupMaxSortModel)
|
||||
}
|
||||
|
||||
res.Sort = form.DefaultMaxSort(ctx, res.Sort)
|
||||
res.Sort = form.DefaultMaxSort(res.Sort)
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定信息
|
||||
func (s *sSysCronGroup) View(ctx context.Context, in sysin.CronGroupViewInp) (res *sysin.CronGroupViewModel, err error) {
|
||||
func (s *sSysCronGroup) View(ctx context.Context, in *sysin.CronGroupViewInp) (res *sysin.CronGroupViewModel, err error) {
|
||||
if err = dao.SysCronGroup.Ctx(ctx).Where("id", in.Id).Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
}
|
||||
@@ -83,7 +83,7 @@ func (s *sSysCronGroup) View(ctx context.Context, in sysin.CronGroupViewInp) (re
|
||||
}
|
||||
|
||||
// List 获取列表
|
||||
func (s *sSysCronGroup) List(ctx context.Context, in sysin.CronGroupListInp) (list []*sysin.CronGroupListModel, totalCount int, err error) {
|
||||
func (s *sSysCronGroup) List(ctx context.Context, in *sysin.CronGroupListInp) (list []*sysin.CronGroupListModel, totalCount int, err error) {
|
||||
mod := dao.SysCronGroup.Ctx(ctx)
|
||||
|
||||
if in.Name != "" {
|
||||
@@ -111,7 +111,7 @@ func (s *sSysCronGroup) List(ctx context.Context, in sysin.CronGroupListInp) (li
|
||||
}
|
||||
|
||||
// Select 选项
|
||||
func (s *sSysCronGroup) Select(ctx context.Context, in sysin.CronGroupSelectInp) (res *sysin.CronGroupSelectModel, err error) {
|
||||
func (s *sSysCronGroup) Select(ctx context.Context, in *sysin.CronGroupSelectInp) (res *sysin.CronGroupSelectModel, err error) {
|
||||
var (
|
||||
mod = dao.SysCronGroup.Ctx(ctx)
|
||||
models []*entity.SysCronGroup
|
||||
|
@@ -3,7 +3,7 @@
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
// @AutoGenerate Version 2.7.3
|
||||
// @AutoGenerate Version 2.7.6
|
||||
package sys
|
||||
|
||||
import (
|
||||
@@ -43,7 +43,7 @@ func (s *sSysCurdDemo) Model(ctx context.Context, option ...*handler.Option) *gd
|
||||
}
|
||||
|
||||
// List 获取生成演示列表
|
||||
func (s *sSysCurdDemo) List(ctx context.Context, in sysin.CurdDemoListInp) (list []*sysin.CurdDemoListModel, totalCount int, err error) {
|
||||
func (s *sSysCurdDemo) List(ctx context.Context, in *sysin.CurdDemoListInp) (list []*sysin.CurdDemoListModel, totalCount int, err error) {
|
||||
mod := s.Model(ctx)
|
||||
|
||||
// 查询ID
|
||||
@@ -88,6 +88,7 @@ func (s *sSysCurdDemo) List(ctx context.Context, in sysin.CurdDemoListInp) (list
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, "获取生成演示关联字段失败,请稍后重试!")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -99,7 +100,7 @@ func (s *sSysCurdDemo) List(ctx context.Context, in sysin.CurdDemoListInp) (list
|
||||
}
|
||||
|
||||
// Export 导出生成演示
|
||||
func (s *sSysCurdDemo) Export(ctx context.Context, in sysin.CurdDemoListInp) (err error) {
|
||||
func (s *sSysCurdDemo) Export(ctx context.Context, in *sysin.CurdDemoListInp) (err error) {
|
||||
list, totalCount, err := s.List(ctx, in)
|
||||
if err != nil {
|
||||
return
|
||||
@@ -126,27 +127,30 @@ func (s *sSysCurdDemo) Export(ctx context.Context, in sysin.CurdDemoListInp) (er
|
||||
}
|
||||
|
||||
// Edit 修改/新增生成演示
|
||||
func (s *sSysCurdDemo) Edit(ctx context.Context, in sysin.CurdDemoEditInp) (err error) {
|
||||
|
||||
func (s *sSysCurdDemo) Edit(ctx context.Context, in *sysin.CurdDemoEditInp) (err error) {
|
||||
// 修改
|
||||
if in.Id > 0 {
|
||||
in.UpdatedBy = contexts.GetUserId(ctx)
|
||||
_, err = s.Model(ctx).
|
||||
if _, err = s.Model(ctx).
|
||||
Fields(sysin.CurdDemoUpdateFields{}).
|
||||
WherePri(in.Id).Data(in).Update()
|
||||
WherePri(in.Id).Data(in).Update(); err != nil {
|
||||
err = gerror.Wrap(err, "修改生成演示失败,请稍后重试!")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 新增
|
||||
in.CreatedBy = contexts.GetUserId(ctx)
|
||||
_, err = s.Model(ctx, &handler.Option{FilterAuth: false}).
|
||||
if _, err = s.Model(ctx, &handler.Option{FilterAuth: false}).
|
||||
Fields(sysin.CurdDemoInsertFields{}).
|
||||
Data(in).Insert()
|
||||
Data(in).Insert(); err != nil {
|
||||
err = gerror.Wrap(err, "新增生成演示失败,请稍后重试!")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除生成演示
|
||||
func (s *sSysCurdDemo) Delete(ctx context.Context, in sysin.CurdDemoDeleteInp) (err error) {
|
||||
func (s *sSysCurdDemo) Delete(ctx context.Context, in *sysin.CurdDemoDeleteInp) (err error) {
|
||||
if _, err = s.Model(ctx).WherePri(in.Id).Delete(); err != nil {
|
||||
err = gerror.Wrap(err, "删除生成演示失败,请稍后重试!")
|
||||
return
|
||||
@@ -155,7 +159,7 @@ func (s *sSysCurdDemo) Delete(ctx context.Context, in sysin.CurdDemoDeleteInp) (
|
||||
}
|
||||
|
||||
// MaxSort 获取生成演示最大排序
|
||||
func (s *sSysCurdDemo) MaxSort(ctx context.Context, in sysin.CurdDemoMaxSortInp) (res *sysin.CurdDemoMaxSortModel, err error) {
|
||||
func (s *sSysCurdDemo) MaxSort(ctx context.Context, in *sysin.CurdDemoMaxSortInp) (res *sysin.CurdDemoMaxSortModel, err error) {
|
||||
if err = dao.SysGenCurdDemo.Ctx(ctx).Fields(dao.SysGenCurdDemo.Columns().Sort).OrderDesc(dao.SysGenCurdDemo.Columns().Sort).Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, "获取生成演示最大排序,请稍后重试!")
|
||||
return
|
||||
@@ -165,12 +169,12 @@ func (s *sSysCurdDemo) MaxSort(ctx context.Context, in sysin.CurdDemoMaxSortInp)
|
||||
res = new(sysin.CurdDemoMaxSortModel)
|
||||
}
|
||||
|
||||
res.Sort = form.DefaultMaxSort(ctx, res.Sort)
|
||||
res.Sort = form.DefaultMaxSort(res.Sort)
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取生成演示指定信息
|
||||
func (s *sSysCurdDemo) View(ctx context.Context, in sysin.CurdDemoViewInp) (res *sysin.CurdDemoViewModel, err error) {
|
||||
func (s *sSysCurdDemo) View(ctx context.Context, in *sysin.CurdDemoViewInp) (res *sysin.CurdDemoViewModel, err error) {
|
||||
if err = s.Model(ctx).WherePri(in.Id).Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, "获取生成演示信息,请稍后重试!")
|
||||
return
|
||||
@@ -179,7 +183,7 @@ func (s *sSysCurdDemo) View(ctx context.Context, in sysin.CurdDemoViewInp) (res
|
||||
}
|
||||
|
||||
// Status 更新生成演示状态
|
||||
func (s *sSysCurdDemo) Status(ctx context.Context, in sysin.CurdDemoStatusInp) (err error) {
|
||||
func (s *sSysCurdDemo) Status(ctx context.Context, in *sysin.CurdDemoStatusInp) (err error) {
|
||||
if _, err = s.Model(ctx).WherePri(in.Id).Data(g.Map{
|
||||
dao.SysGenCurdDemo.Columns().Status: in.Status,
|
||||
dao.SysGenCurdDemo.Columns().UpdatedBy: contexts.GetUserId(ctx),
|
||||
@@ -191,7 +195,7 @@ func (s *sSysCurdDemo) Status(ctx context.Context, in sysin.CurdDemoStatusInp) (
|
||||
}
|
||||
|
||||
// Switch 更新生成演示开关
|
||||
func (s *sSysCurdDemo) Switch(ctx context.Context, in sysin.CurdDemoSwitchInp) (err error) {
|
||||
func (s *sSysCurdDemo) Switch(ctx context.Context, in *sysin.CurdDemoSwitchInp) (err error) {
|
||||
var fields = []string{
|
||||
dao.SysGenCurdDemo.Columns().Switch,
|
||||
|
||||
|
@@ -25,7 +25,7 @@ func init() {
|
||||
}
|
||||
|
||||
// Delete 删除
|
||||
func (s *sSysDictData) Delete(ctx context.Context, in sysin.DictDataDeleteInp) error {
|
||||
func (s *sSysDictData) Delete(ctx context.Context, in *sysin.DictDataDeleteInp) error {
|
||||
_, err := dao.SysDictData.Ctx(ctx).Where("id", in.Id).Delete()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
@@ -35,7 +35,7 @@ func (s *sSysDictData) Delete(ctx context.Context, in sysin.DictDataDeleteInp) e
|
||||
}
|
||||
|
||||
// Edit 修改/新增
|
||||
func (s *sSysDictData) Edit(ctx context.Context, in sysin.DictDataEditInp) (err error) {
|
||||
func (s *sSysDictData) Edit(ctx context.Context, in *sysin.DictDataEditInp) (err error) {
|
||||
// 修改
|
||||
if in.Id > 0 {
|
||||
_, err = dao.SysDictData.Ctx(ctx).Fields(sysin.DictDataUpdateFields{}).WherePri(in.Id).Data(in).Update()
|
||||
@@ -66,7 +66,7 @@ func (s *sSysDictData) Edit(ctx context.Context, in sysin.DictDataEditInp) (err
|
||||
}
|
||||
|
||||
// List 获取列表
|
||||
func (s *sSysDictData) List(ctx context.Context, in sysin.DictDataListInp) (list []*sysin.DictDataListModel, totalCount int, err error) {
|
||||
func (s *sSysDictData) List(ctx context.Context, in *sysin.DictDataListInp) (list []*sysin.DictDataListModel, totalCount int, err error) {
|
||||
mod := dao.SysDictData.Ctx(ctx)
|
||||
// 类型ID
|
||||
if in.TypeID > 0 {
|
||||
@@ -113,7 +113,7 @@ func (s *sSysDictData) List(ctx context.Context, in sysin.DictDataListInp) (list
|
||||
}
|
||||
|
||||
// Select 获取列表
|
||||
func (s *sSysDictData) Select(ctx context.Context, in sysin.DataSelectInp) (list sysin.DataSelectModel, err error) {
|
||||
func (s *sSysDictData) Select(ctx context.Context, in *sysin.DataSelectInp) (list sysin.DataSelectModel, err error) {
|
||||
mod := dao.SysDictData.Ctx(ctx).Where("type", in.Type)
|
||||
if in.Type != "" {
|
||||
mod = mod.Where("type", in.Type)
|
||||
|
@@ -44,7 +44,7 @@ func (s *sSysDictType) Tree(ctx context.Context) (list []*sysin.DictTypeTree, er
|
||||
}
|
||||
|
||||
// Delete 删除
|
||||
func (s *sSysDictType) Delete(ctx context.Context, in sysin.DictTypeDeleteInp) (err error) {
|
||||
func (s *sSysDictType) Delete(ctx context.Context, in *sysin.DictTypeDeleteInp) (err error) {
|
||||
var models *entity.SysDictType
|
||||
if err = dao.SysDictType.Ctx(ctx).Where("id", in.Id).Scan(&models); err != nil {
|
||||
return
|
||||
@@ -81,7 +81,7 @@ func (s *sSysDictType) Delete(ctx context.Context, in sysin.DictTypeDeleteInp) (
|
||||
}
|
||||
|
||||
// Edit 修改/新增
|
||||
func (s *sSysDictType) Edit(ctx context.Context, in sysin.DictTypeEditInp) (err error) {
|
||||
func (s *sSysDictType) Edit(ctx context.Context, in *sysin.DictTypeEditInp) (err error) {
|
||||
if err = hgorm.IsUnique(ctx, &dao.SysDictType, g.Map{dao.SysDictType.Columns().Name: in.Name}, "名称已存在", in.Id); err != nil {
|
||||
return
|
||||
}
|
||||
@@ -102,7 +102,7 @@ func (s *sSysDictType) Edit(ctx context.Context, in sysin.DictTypeEditInp) (err
|
||||
}
|
||||
|
||||
// TreeSelect 获取类型关系树选项
|
||||
func (s *sSysDictType) TreeSelect(ctx context.Context, in sysin.DictTreeSelectInp) (list []*sysin.DictTypeTree, err error) {
|
||||
func (s *sSysDictType) TreeSelect(ctx context.Context, in *sysin.DictTreeSelectInp) (list []*sysin.DictTypeTree, err error) {
|
||||
var (
|
||||
mod = dao.SysDictType.Ctx(ctx)
|
||||
models []*entity.SysDictType
|
||||
|
@@ -42,13 +42,13 @@ func init() {
|
||||
}
|
||||
|
||||
// Delete 删除
|
||||
func (s *sSysEmsLog) Delete(ctx context.Context, in sysin.EmsLogDeleteInp) (err error) {
|
||||
func (s *sSysEmsLog) Delete(ctx context.Context, in *sysin.EmsLogDeleteInp) (err error) {
|
||||
_, err = dao.SysEmsLog.Ctx(ctx).Where("id", in.Id).Delete()
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 修改/新增
|
||||
func (s *sSysEmsLog) Edit(ctx context.Context, in sysin.EmsLogEditInp) (err error) {
|
||||
func (s *sSysEmsLog) Edit(ctx context.Context, in *sysin.EmsLogEditInp) (err error) {
|
||||
if in.Ip == "" {
|
||||
err = gerror.New("ip不能为空")
|
||||
return
|
||||
@@ -66,7 +66,7 @@ func (s *sSysEmsLog) Edit(ctx context.Context, in sysin.EmsLogEditInp) (err erro
|
||||
}
|
||||
|
||||
// Status 更新部门状态
|
||||
func (s *sSysEmsLog) Status(ctx context.Context, in sysin.EmsLogStatusInp) (err error) {
|
||||
func (s *sSysEmsLog) Status(ctx context.Context, in *sysin.EmsLogStatusInp) (err error) {
|
||||
if in.Id <= 0 {
|
||||
err = gerror.New("ID不能为空")
|
||||
return
|
||||
@@ -88,13 +88,13 @@ func (s *sSysEmsLog) Status(ctx context.Context, in sysin.EmsLogStatusInp) (err
|
||||
}
|
||||
|
||||
// View 获取指定字典类型信息
|
||||
func (s *sSysEmsLog) View(ctx context.Context, in sysin.EmsLogViewInp) (res *sysin.EmsLogViewModel, err error) {
|
||||
func (s *sSysEmsLog) View(ctx context.Context, in *sysin.EmsLogViewInp) (res *sysin.EmsLogViewModel, err error) {
|
||||
err = dao.SysEmsLog.Ctx(ctx).Where("id", in.Id).Scan(&res)
|
||||
return
|
||||
}
|
||||
|
||||
// List 获取列表
|
||||
func (s *sSysEmsLog) List(ctx context.Context, in sysin.EmsLogListInp) (list []*sysin.EmsLogListModel, totalCount int, err error) {
|
||||
func (s *sSysEmsLog) List(ctx context.Context, in *sysin.EmsLogListInp) (list []*sysin.EmsLogListModel, totalCount int, err error) {
|
||||
mod := dao.SysEmsLog.Ctx(ctx)
|
||||
|
||||
if in.Status > 0 {
|
||||
@@ -116,7 +116,7 @@ func (s *sSysEmsLog) List(ctx context.Context, in sysin.EmsLogListInp) (list []*
|
||||
}
|
||||
|
||||
// Send 发送邮件
|
||||
func (s *sSysEmsLog) Send(ctx context.Context, in sysin.SendEmsInp) (err error) {
|
||||
func (s *sSysEmsLog) Send(ctx context.Context, in *sysin.SendEmsInp) (err error) {
|
||||
var models *entity.SysEmsLog
|
||||
if err = dao.SysEmsLog.Ctx(ctx).Where("event", in.Event).Where("email", in.Email).Scan(&models); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
@@ -194,7 +194,7 @@ func (s *sSysEmsLog) Send(ctx context.Context, in sysin.SendEmsInp) (err error)
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sSysEmsLog) newView(ctx context.Context, in sysin.SendEmsInp, config *model.EmailConfig) (view *gview.View, err error) {
|
||||
func (s *sSysEmsLog) newView(ctx context.Context, in *sysin.SendEmsInp, config *model.EmailConfig) (view *gview.View, err error) {
|
||||
view = gview.New()
|
||||
err = view.SetConfig(gview.Config{
|
||||
Delimiters: g.Cfg().MustGet(ctx, "viewer.delimiters").Strings(),
|
||||
@@ -349,7 +349,7 @@ func (s *sSysEmsLog) AllowSend(ctx context.Context, models *entity.SysEmsLog, co
|
||||
}
|
||||
|
||||
// VerifyCode 效验验证码
|
||||
func (s *sSysEmsLog) VerifyCode(ctx context.Context, in sysin.VerifyEmsCodeInp) (err error) {
|
||||
func (s *sSysEmsLog) VerifyCode(ctx context.Context, in *sysin.VerifyEmsCodeInp) (err error) {
|
||||
if in.Event == "" {
|
||||
err = gerror.New("事件不能为空")
|
||||
return
|
||||
|
@@ -35,13 +35,13 @@ func init() {
|
||||
}
|
||||
|
||||
// Delete 删除
|
||||
func (s *sSysGenCodes) Delete(ctx context.Context, in sysin.GenCodesDeleteInp) (err error) {
|
||||
func (s *sSysGenCodes) Delete(ctx context.Context, in *sysin.GenCodesDeleteInp) (err error) {
|
||||
_, err = dao.SysGenCodes.Ctx(ctx).Where("id", in.Id).Delete()
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 修改/新增
|
||||
func (s *sSysGenCodes) Edit(ctx context.Context, in sysin.GenCodesEditInp) (res *sysin.GenCodesEditModel, err error) {
|
||||
func (s *sSysGenCodes) Edit(ctx context.Context, in *sysin.GenCodesEditInp) (res *sysin.GenCodesEditModel, err error) {
|
||||
if in.GenType == 0 {
|
||||
err = gerror.New("生成类型不能为空")
|
||||
return
|
||||
@@ -99,7 +99,7 @@ func (s *sSysGenCodes) Edit(ctx context.Context, in sysin.GenCodesEditInp) (res
|
||||
}
|
||||
|
||||
// Status 更新部门状态
|
||||
func (s *sSysGenCodes) Status(ctx context.Context, in sysin.GenCodesStatusInp) (err error) {
|
||||
func (s *sSysGenCodes) Status(ctx context.Context, in *sysin.GenCodesStatusInp) (err error) {
|
||||
if in.Id <= 0 {
|
||||
err = gerror.New("ID不能为空")
|
||||
return
|
||||
@@ -120,7 +120,7 @@ func (s *sSysGenCodes) Status(ctx context.Context, in sysin.GenCodesStatusInp) (
|
||||
}
|
||||
|
||||
// MaxSort 最大排序
|
||||
func (s *sSysGenCodes) MaxSort(ctx context.Context, in sysin.GenCodesMaxSortInp) (res *sysin.GenCodesMaxSortModel, err error) {
|
||||
func (s *sSysGenCodes) MaxSort(ctx context.Context, in *sysin.GenCodesMaxSortInp) (res *sysin.GenCodesMaxSortModel, err error) {
|
||||
if in.Id > 0 {
|
||||
if err = dao.SysGenCodes.Ctx(ctx).Where("id", in.Id).Order("sort desc").Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
@@ -132,18 +132,18 @@ func (s *sSysGenCodes) MaxSort(ctx context.Context, in sysin.GenCodesMaxSortInp)
|
||||
res = new(sysin.GenCodesMaxSortModel)
|
||||
}
|
||||
|
||||
res.Sort = form.DefaultMaxSort(ctx, res.Sort)
|
||||
res.Sort = form.DefaultMaxSort(res.Sort)
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定字典类型信息
|
||||
func (s *sSysGenCodes) View(ctx context.Context, in sysin.GenCodesViewInp) (res *sysin.GenCodesViewModel, err error) {
|
||||
func (s *sSysGenCodes) View(ctx context.Context, in *sysin.GenCodesViewInp) (res *sysin.GenCodesViewModel, err error) {
|
||||
err = dao.SysGenCodes.Ctx(ctx).Where("id", in.Id).Scan(&res)
|
||||
return
|
||||
}
|
||||
|
||||
// List 获取列表
|
||||
func (s *sSysGenCodes) List(ctx context.Context, in sysin.GenCodesListInp) (list []*sysin.GenCodesListModel, totalCount int, err error) {
|
||||
func (s *sSysGenCodes) List(ctx context.Context, in *sysin.GenCodesListInp) (list []*sysin.GenCodesListModel, totalCount int, err error) {
|
||||
mod := dao.SysGenCodes.Ctx(ctx)
|
||||
|
||||
if in.GenType > 0 {
|
||||
@@ -195,17 +195,16 @@ func (s *sSysGenCodes) List(ctx context.Context, in sysin.GenCodesListInp) (list
|
||||
v.GenTemplateGroup = getTpGroup(v)
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Selects 选项
|
||||
func (s *sSysGenCodes) Selects(ctx context.Context, in sysin.GenCodesSelectsInp) (res *sysin.GenCodesSelectsModel, err error) {
|
||||
func (s *sSysGenCodes) Selects(ctx context.Context, in *sysin.GenCodesSelectsInp) (res *sysin.GenCodesSelectsModel, err error) {
|
||||
return hggen.TableSelects(ctx, in)
|
||||
}
|
||||
|
||||
// TableSelect 表选项
|
||||
func (s *sSysGenCodes) TableSelect(ctx context.Context, in sysin.GenCodesTableSelectInp) (res []*sysin.GenCodesTableSelectModel, err error) {
|
||||
func (s *sSysGenCodes) TableSelect(ctx context.Context, in *sysin.GenCodesTableSelectInp) (res []*sysin.GenCodesTableSelectModel, err error) {
|
||||
var (
|
||||
sql = "SELECT TABLE_NAME as value, TABLE_COMMENT as label FROM information_schema.`TABLES` WHERE TABLE_SCHEMA = '%s'"
|
||||
config = g.DB(in.Name).GetConfig()
|
||||
@@ -248,14 +247,13 @@ func (s *sSysGenCodes) TableSelect(ctx context.Context, in sysin.GenCodesTableSe
|
||||
row.DefAlias = gstr.CaseCamelLower(newValue)
|
||||
row.Name = fmt.Sprintf("%s (%s)", v.Value, v.Label)
|
||||
row.Label = row.Name
|
||||
|
||||
res = append(res, row)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ColumnSelect 表字段选项
|
||||
func (s *sSysGenCodes) ColumnSelect(ctx context.Context, in sysin.GenCodesColumnSelectInp) (res []*sysin.GenCodesColumnSelectModel, err error) {
|
||||
func (s *sSysGenCodes) ColumnSelect(ctx context.Context, in *sysin.GenCodesColumnSelectInp) (res []*sysin.GenCodesColumnSelectModel, err error) {
|
||||
var (
|
||||
sql = "select COLUMN_NAME as value,COLUMN_COMMENT as label from information_schema.COLUMNS where TABLE_SCHEMA = '%s' and TABLE_NAME = '%s'"
|
||||
config = g.DB(in.Name).GetConfig()
|
||||
@@ -278,31 +276,31 @@ func (s *sSysGenCodes) ColumnSelect(ctx context.Context, in sysin.GenCodesColumn
|
||||
}
|
||||
|
||||
// ColumnList 表字段列表
|
||||
func (s *sSysGenCodes) ColumnList(ctx context.Context, in sysin.GenCodesColumnListInp) (res []*sysin.GenCodesColumnListModel, err error) {
|
||||
func (s *sSysGenCodes) ColumnList(ctx context.Context, in *sysin.GenCodesColumnListInp) (res []*sysin.GenCodesColumnListModel, err error) {
|
||||
return hggen.TableColumns(ctx, in)
|
||||
}
|
||||
|
||||
// Preview 生成预览
|
||||
func (s *sSysGenCodes) Preview(ctx context.Context, in sysin.GenCodesPreviewInp) (res *sysin.GenCodesPreviewModel, err error) {
|
||||
func (s *sSysGenCodes) Preview(ctx context.Context, in *sysin.GenCodesPreviewInp) (res *sysin.GenCodesPreviewModel, err error) {
|
||||
return hggen.Preview(ctx, in)
|
||||
}
|
||||
|
||||
// Build 提交生成
|
||||
func (s *sSysGenCodes) Build(ctx context.Context, in sysin.GenCodesBuildInp) (err error) {
|
||||
func (s *sSysGenCodes) Build(ctx context.Context, in *sysin.GenCodesBuildInp) (err error) {
|
||||
// 先保存配置
|
||||
ein := in.SysGenCodes
|
||||
if _, err = s.Edit(ctx, sysin.GenCodesEditInp{SysGenCodes: ein}); err != nil {
|
||||
if _, err = s.Edit(ctx, &sysin.GenCodesEditInp{SysGenCodes: ein}); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
if err = s.Status(ctx, sysin.GenCodesStatusInp{Id: in.Id, Status: consts.GenCodesStatusOk}); err != nil {
|
||||
if err = s.Status(ctx, &sysin.GenCodesStatusInp{Id: in.Id, Status: consts.GenCodesStatusOk}); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return err
|
||||
}
|
||||
|
||||
if err = hggen.Build(ctx, in); err != nil {
|
||||
_ = s.Status(ctx, sysin.GenCodesStatusInp{Id: in.Id, Status: consts.GenCodesStatusFail})
|
||||
_ = s.Status(ctx, &sysin.GenCodesStatusInp{Id: in.Id, Status: consts.GenCodesStatusFail})
|
||||
return err
|
||||
}
|
||||
return
|
||||
|
@@ -41,7 +41,7 @@ func init() {
|
||||
}
|
||||
|
||||
// Export 导出
|
||||
func (s *sSysLog) Export(ctx context.Context, in sysin.LogListInp) (err error) {
|
||||
func (s *sSysLog) Export(ctx context.Context, in *sysin.LogListInp) (err error) {
|
||||
// 导出格式
|
||||
type exportImage struct {
|
||||
Id int64 `json:"id" description:""`
|
||||
@@ -235,7 +235,7 @@ func (s *sSysLog) AnalysisLog(ctx context.Context) entity.SysLog {
|
||||
}
|
||||
|
||||
// View 获取指定字典类型信息
|
||||
func (s *sSysLog) View(ctx context.Context, in sysin.LogViewInp) (res *sysin.LogViewModel, err error) {
|
||||
func (s *sSysLog) View(ctx context.Context, in *sysin.LogViewInp) (res *sysin.LogViewModel, err error) {
|
||||
if err = dao.SysLog.Ctx(ctx).Hook(hook.CityLabel).Where("id", in.Id).Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return
|
||||
@@ -252,13 +252,13 @@ func (s *sSysLog) View(ctx context.Context, in sysin.LogViewInp) (res *sysin.Log
|
||||
}
|
||||
|
||||
// Delete 删除
|
||||
func (s *sSysLog) Delete(ctx context.Context, in sysin.LogDeleteInp) (err error) {
|
||||
func (s *sSysLog) Delete(ctx context.Context, in *sysin.LogDeleteInp) (err error) {
|
||||
_, err = dao.SysLog.Ctx(ctx).Where("id", in.Id).Delete()
|
||||
return
|
||||
}
|
||||
|
||||
// List 列表
|
||||
func (s *sSysLog) List(ctx context.Context, in sysin.LogListInp) (list []*sysin.LogListModel, totalCount int, err error) {
|
||||
func (s *sSysLog) List(ctx context.Context, in *sysin.LogListInp) (list []*sysin.LogListModel, totalCount int, err error) {
|
||||
mod := dao.SysLog.Ctx(ctx).FieldsEx("get_data", "header_data", "post_data")
|
||||
|
||||
// 访问路径
|
||||
@@ -287,13 +287,6 @@ func (s *sSysLog) List(ctx context.Context, in sysin.LogListInp) (list []*sysin.
|
||||
}
|
||||
|
||||
// 日期范围
|
||||
if in.StartTime != "" {
|
||||
mod = mod.WhereGTE("created_at", in.StartTime)
|
||||
}
|
||||
if in.EndTime != "" {
|
||||
mod = mod.WhereLTE("created_at", in.EndTime)
|
||||
}
|
||||
|
||||
if len(in.CreatedAt) == 2 {
|
||||
mod = mod.WhereBetween("created_at", gtime.New(in.CreatedAt[0]), gtime.New(in.CreatedAt[1]))
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@ func (s *sSysLoginLog) Model(ctx context.Context) *gdb.Model {
|
||||
}
|
||||
|
||||
// List 获取登录日志列表
|
||||
func (s *sSysLoginLog) List(ctx context.Context, in sysin.LoginLogListInp) (list []*sysin.LoginLogListModel, totalCount int, err error) {
|
||||
func (s *sSysLoginLog) List(ctx context.Context, in *sysin.LoginLogListInp) (list []*sysin.LoginLogListModel, totalCount int, err error) {
|
||||
mod := dao.SysLoginLog.Ctx(ctx)
|
||||
|
||||
// 查询状态
|
||||
@@ -111,7 +111,7 @@ func (s *sSysLoginLog) List(ctx context.Context, in sysin.LoginLogListInp) (list
|
||||
}
|
||||
|
||||
// Export 导出登录日志
|
||||
func (s *sSysLoginLog) Export(ctx context.Context, in sysin.LoginLogListInp) (err error) {
|
||||
func (s *sSysLoginLog) Export(ctx context.Context, in *sysin.LoginLogListInp) (err error) {
|
||||
list, totalCount, err := s.List(ctx, in)
|
||||
if err != nil {
|
||||
return
|
||||
@@ -138,19 +138,19 @@ func (s *sSysLoginLog) Export(ctx context.Context, in sysin.LoginLogListInp) (er
|
||||
}
|
||||
|
||||
// Delete 删除登录日志
|
||||
func (s *sSysLoginLog) Delete(ctx context.Context, in sysin.LoginLogDeleteInp) (err error) {
|
||||
func (s *sSysLoginLog) Delete(ctx context.Context, in *sysin.LoginLogDeleteInp) (err error) {
|
||||
_, err = dao.SysLoginLog.Ctx(ctx).Where(dao.SysLoginLog.Columns().Id, in.Id).Delete()
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取登录日志指定信息
|
||||
func (s *sSysLoginLog) View(ctx context.Context, in sysin.LoginLogViewInp) (res *sysin.LoginLogViewModel, err error) {
|
||||
func (s *sSysLoginLog) View(ctx context.Context, in *sysin.LoginLogViewInp) (res *sysin.LoginLogViewModel, err error) {
|
||||
err = dao.SysLoginLog.Ctx(ctx).Where(dao.SysLoginLog.Columns().Id, in.Id).Scan(&res)
|
||||
return
|
||||
}
|
||||
|
||||
// Push 推送登录日志
|
||||
func (s *sSysLoginLog) Push(ctx context.Context, in sysin.LoginLogPushInp) {
|
||||
func (s *sSysLoginLog) Push(ctx context.Context, in *sysin.LoginLogPushInp) {
|
||||
if in.Response == nil {
|
||||
in.Response = new(adminin.LoginModel)
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ func (s *sSysProvinces) Tree(ctx context.Context) (list []*sysin.ProvincesTree,
|
||||
}
|
||||
|
||||
// Delete 删除省市区数据
|
||||
func (s *sSysProvinces) Delete(ctx context.Context, in sysin.ProvincesDeleteInp) (err error) {
|
||||
func (s *sSysProvinces) Delete(ctx context.Context, in *sysin.ProvincesDeleteInp) (err error) {
|
||||
var models *entity.SysProvinces
|
||||
if err = dao.SysProvinces.Ctx(ctx).Where("id", in.Id).Scan(&models); err != nil {
|
||||
err = gerror.Wrap(err, "获取省市区数据失败!")
|
||||
@@ -71,14 +71,14 @@ func (s *sSysProvinces) Delete(ctx context.Context, in sysin.ProvincesDeleteInp)
|
||||
}
|
||||
|
||||
// Edit 修改/新增省市区数据
|
||||
func (s *sSysProvinces) Edit(ctx context.Context, in sysin.ProvincesEditInp) (err error) {
|
||||
func (s *sSysProvinces) Edit(ctx context.Context, in *sysin.ProvincesEditInp) (err error) {
|
||||
// 关系树
|
||||
in.Pid, in.Level, in.Tree, err = hgorm.GenSubTree(ctx, &dao.SysProvinces, in.Pid)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
models, err := s.View(ctx, sysin.ProvincesViewInp{Id: in.Id})
|
||||
models, err := s.View(ctx, &sysin.ProvincesViewInp{Id: in.Id})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -99,7 +99,7 @@ func (s *sSysProvinces) Edit(ctx context.Context, in sysin.ProvincesEditInp) (er
|
||||
}
|
||||
|
||||
// Status 更新省市区状态
|
||||
func (s *sSysProvinces) Status(ctx context.Context, in sysin.ProvincesStatusInp) (err error) {
|
||||
func (s *sSysProvinces) Status(ctx context.Context, in *sysin.ProvincesStatusInp) (err error) {
|
||||
if _, err = dao.SysProvinces.Ctx(ctx).Where("id", in.Id).Data("status", in.Status).Update(); err != nil {
|
||||
err = gerror.Wrap(err, "更新省市区状态失败!")
|
||||
}
|
||||
@@ -107,7 +107,7 @@ func (s *sSysProvinces) Status(ctx context.Context, in sysin.ProvincesStatusInp)
|
||||
}
|
||||
|
||||
// MaxSort 最大排序
|
||||
func (s *sSysProvinces) MaxSort(ctx context.Context, in sysin.ProvincesMaxSortInp) (res *sysin.ProvincesMaxSortModel, err error) {
|
||||
func (s *sSysProvinces) MaxSort(ctx context.Context, in *sysin.ProvincesMaxSortInp) (res *sysin.ProvincesMaxSortModel, err error) {
|
||||
if err = dao.SysProvinces.Ctx(ctx).Fields(dao.SysProvinces.Columns().Sort).OrderDesc(dao.SysProvinces.Columns().Sort).Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, "获取省市区最大排序失败!")
|
||||
return
|
||||
@@ -116,12 +116,12 @@ func (s *sSysProvinces) MaxSort(ctx context.Context, in sysin.ProvincesMaxSortIn
|
||||
if res == nil {
|
||||
res = new(sysin.ProvincesMaxSortModel)
|
||||
}
|
||||
res.Sort = form.DefaultMaxSort(ctx, res.Sort)
|
||||
res.Sort = form.DefaultMaxSort(res.Sort)
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取省市区信息
|
||||
func (s *sSysProvinces) View(ctx context.Context, in sysin.ProvincesViewInp) (res *sysin.ProvincesViewModel, err error) {
|
||||
func (s *sSysProvinces) View(ctx context.Context, in *sysin.ProvincesViewInp) (res *sysin.ProvincesViewModel, err error) {
|
||||
if err = dao.SysProvinces.Ctx(ctx).Where("id", in.Id).Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, "获取省市区信息失败!")
|
||||
}
|
||||
@@ -129,7 +129,7 @@ func (s *sSysProvinces) View(ctx context.Context, in sysin.ProvincesViewInp) (re
|
||||
}
|
||||
|
||||
// List 获取列表
|
||||
func (s *sSysProvinces) List(ctx context.Context, in sysin.ProvincesListInp) (list []*sysin.ProvincesListModel, totalCount int, err error) {
|
||||
func (s *sSysProvinces) List(ctx context.Context, in *sysin.ProvincesListInp) (list []*sysin.ProvincesListModel, totalCount int, err error) {
|
||||
mod := dao.SysProvinces.Ctx(ctx)
|
||||
|
||||
if in.Title != "" {
|
||||
@@ -157,7 +157,7 @@ func (s *sSysProvinces) List(ctx context.Context, in sysin.ProvincesListInp) (li
|
||||
}
|
||||
|
||||
// ChildrenList 获取省市区下级列表
|
||||
func (s *sSysProvinces) ChildrenList(ctx context.Context, in sysin.ProvincesChildrenListInp) (list []*sysin.ProvincesChildrenListModel, totalCount int, err error) {
|
||||
func (s *sSysProvinces) ChildrenList(ctx context.Context, in *sysin.ProvincesChildrenListInp) (list []*sysin.ProvincesChildrenListModel, totalCount int, err error) {
|
||||
mod := dao.SysProvinces.Ctx(ctx)
|
||||
|
||||
if in.Title != "" {
|
||||
@@ -189,7 +189,7 @@ func (s *sSysProvinces) ChildrenList(ctx context.Context, in sysin.ProvincesChil
|
||||
}
|
||||
|
||||
// UniqueId 获取省市区下级列表
|
||||
func (s *sSysProvinces) UniqueId(ctx context.Context, in sysin.ProvincesUniqueIdInp) (res *sysin.ProvincesUniqueIdModel, err error) {
|
||||
func (s *sSysProvinces) UniqueId(ctx context.Context, in *sysin.ProvincesUniqueIdInp) (res *sysin.ProvincesUniqueIdModel, err error) {
|
||||
res = new(sysin.ProvincesUniqueIdModel)
|
||||
res.IsUnique = true
|
||||
if in.NewId == 0 {
|
||||
@@ -204,7 +204,7 @@ func (s *sSysProvinces) UniqueId(ctx context.Context, in sysin.ProvincesUniqueId
|
||||
}
|
||||
|
||||
// Select 省市区选项
|
||||
func (s *sSysProvinces) Select(ctx context.Context, in sysin.ProvincesSelectInp) (res *sysin.ProvincesSelectModel, err error) {
|
||||
func (s *sSysProvinces) Select(ctx context.Context, in *sysin.ProvincesSelectInp) (res *sysin.ProvincesSelectModel, err error) {
|
||||
res = new(sysin.ProvincesSelectModel)
|
||||
mod := dao.SysProvinces.Ctx(ctx).Fields("id as value, title as label, level").Where("pid", in.Value)
|
||||
|
||||
|
193
server/internal/logic/sys/serve_license.go
Normal file
193
server/internal/logic/sys/serve_license.go
Normal file
@@ -0,0 +1,193 @@
|
||||
// Package sys
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
// @AutoGenerate Version 2.7.6
|
||||
package sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"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/os/gctx"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"hotgo/internal/dao"
|
||||
"hotgo/internal/library/hgorm"
|
||||
"hotgo/internal/library/hgorm/handler"
|
||||
"hotgo/internal/model/input/form"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
"hotgo/internal/service"
|
||||
"hotgo/utility/convert"
|
||||
"hotgo/utility/excel"
|
||||
)
|
||||
|
||||
type sSysServeLicense struct{}
|
||||
|
||||
func NewSysServeLicense() *sSysServeLicense {
|
||||
return &sSysServeLicense{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
service.RegisterSysServeLicense(NewSysServeLicense())
|
||||
}
|
||||
|
||||
// Model 服务许可证ORM模型
|
||||
func (s *sSysServeLicense) Model(ctx context.Context, option ...*handler.Option) *gdb.Model {
|
||||
return handler.Model(dao.SysServeLicense.Ctx(ctx), option...)
|
||||
}
|
||||
|
||||
// List 获取服务许可证列表
|
||||
func (s *sSysServeLicense) List(ctx context.Context, in *sysin.ServeLicenseListInp) (list []*sysin.ServeLicenseListModel, totalCount int, err error) {
|
||||
mod := s.Model(ctx)
|
||||
|
||||
// 查询许可ID
|
||||
if in.Id > 0 {
|
||||
mod = mod.Where(dao.SysServeLicense.Columns().Id, in.Id)
|
||||
}
|
||||
|
||||
// 查询分组
|
||||
if in.Group != "" {
|
||||
mod = mod.Where(dao.SysServeLicense.Columns().Group, in.Group)
|
||||
}
|
||||
|
||||
// 查询许可名称
|
||||
if in.Name != "" {
|
||||
mod = mod.WhereLike(dao.SysServeLicense.Columns().Name, "%"+in.Name+"%")
|
||||
}
|
||||
|
||||
// 查询应用ID
|
||||
if in.Appid != "" {
|
||||
mod = mod.Where(dao.SysServeLicense.Columns().Appid, in.Appid)
|
||||
}
|
||||
|
||||
// 查询授权结束时间
|
||||
if len(in.EndAt) == 2 {
|
||||
mod = mod.WhereBetween(dao.SysServeLicense.Columns().EndAt, in.EndAt[0], in.EndAt[1])
|
||||
}
|
||||
|
||||
// 查询状态
|
||||
if in.Status > 0 {
|
||||
mod = mod.Where(dao.SysServeLicense.Columns().Status, in.Status)
|
||||
}
|
||||
|
||||
// 查询创建时间
|
||||
if len(in.CreatedAt) == 2 {
|
||||
mod = mod.WhereBetween(dao.SysServeLicense.Columns().CreatedAt, in.CreatedAt[0], in.CreatedAt[1])
|
||||
}
|
||||
|
||||
totalCount, err = mod.Clone().Count()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, "获取服务许可证数据行失败,请稍后重试!")
|
||||
return
|
||||
}
|
||||
|
||||
if totalCount == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if err = mod.Fields(sysin.ServeLicenseListModel{}).Page(in.Page, in.PerPage).OrderDesc(dao.SysServeLicense.Columns().Id).Scan(&list); err != nil {
|
||||
err = gerror.Wrap(err, "获取服务许可证列表失败,请稍后重试!")
|
||||
return
|
||||
}
|
||||
|
||||
serv := service.TCPServer().Instance()
|
||||
for _, v := range list {
|
||||
v.Online = serv.GetAppIdOnline(v.Appid)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Export 导出服务许可证
|
||||
func (s *sSysServeLicense) Export(ctx context.Context, in *sysin.ServeLicenseListInp) (err error) {
|
||||
list, totalCount, err := s.List(ctx, in)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 字段的排序是依据tags的字段顺序,如果你不想使用默认的排序方式,可以直接定义 tags = []string{"字段名称", "字段名称2", ...}
|
||||
tags, err := convert.GetEntityDescTags(sysin.ServeLicenseExportModel{})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
var (
|
||||
fileName = "导出服务许可证-" + gctx.CtxId(ctx) + ".xlsx"
|
||||
sheetName = fmt.Sprintf("索引条件共%v行,共%v页,当前导出是第%v页,本页共%v行", totalCount, form.CalPageCount(totalCount, in.PerPage), in.Page, len(list))
|
||||
exports []sysin.ServeLicenseExportModel
|
||||
)
|
||||
|
||||
if err = gconv.Scan(list, &exports); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = excel.ExportByStructs(ctx, tags, exports, fileName, sheetName)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 修改/新增服务许可证
|
||||
func (s *sSysServeLicense) Edit(ctx context.Context, in *sysin.ServeLicenseEditInp) (err error) {
|
||||
// 验证'Appid'唯一
|
||||
if err = hgorm.IsUnique(ctx, &dao.SysServeLicense, g.Map{dao.SysServeLicense.Columns().Appid: in.Appid}, "应用ID已存在", in.Id); err != nil {
|
||||
return
|
||||
}
|
||||
// 修改
|
||||
if in.Id > 0 {
|
||||
if _, err = s.Model(ctx).Fields(sysin.ServeLicenseUpdateFields{}).WherePri(in.Id).Data(in).Update(); err != nil {
|
||||
err = gerror.Wrap(err, "修改服务许可证失败,请稍后重试!")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 新增
|
||||
if _, err = s.Model(ctx, &handler.Option{FilterAuth: false}).Fields(sysin.ServeLicenseInsertFields{}).Data(in).Insert(); err != nil {
|
||||
err = gerror.Wrap(err, "新增服务许可证失败,请稍后重试!")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除服务许可证
|
||||
func (s *sSysServeLicense) Delete(ctx context.Context, in *sysin.ServeLicenseDeleteInp) (err error) {
|
||||
if _, err = s.Model(ctx).WherePri(in.Id).Delete(); err != nil {
|
||||
err = gerror.Wrap(err, "删除服务许可证失败,请稍后重试!")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取服务许可证指定信息
|
||||
func (s *sSysServeLicense) View(ctx context.Context, in *sysin.ServeLicenseViewInp) (res *sysin.ServeLicenseViewModel, err error) {
|
||||
if err = s.Model(ctx).WherePri(in.Id).Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, "获取服务许可证信息,请稍后重试!")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Status 更新服务许可证状态
|
||||
func (s *sSysServeLicense) Status(ctx context.Context, in *sysin.ServeLicenseStatusInp) (err error) {
|
||||
update := g.Map{
|
||||
dao.SysServeLicense.Columns().Status: in.Status,
|
||||
}
|
||||
|
||||
if _, err = s.Model(ctx).WherePri(in.Id).Data(update).Update(); err != nil {
|
||||
err = gerror.Wrap(err, "更新服务许可证状态失败,请稍后重试!")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// AssignRouter 分配服务许可证路由
|
||||
func (s *sSysServeLicense) AssignRouter(ctx context.Context, in *sysin.ServeLicenseAssignRouterInp) (err error) {
|
||||
update := g.Map{
|
||||
dao.SysServeLicense.Columns().Routes: in.Routes,
|
||||
}
|
||||
|
||||
if _, err = s.Model(ctx).WherePri(in.Id).Data(update).Update(); err != nil {
|
||||
err = gerror.Wrap(err, "分配服务许可证路由失败,请稍后重试!")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
@@ -38,7 +38,7 @@ func (s *sSysServeLog) Model(ctx context.Context) *gdb.Model {
|
||||
}
|
||||
|
||||
// List 获取服务日志列表
|
||||
func (s *sSysServeLog) List(ctx context.Context, in sysin.ServeLogListInp) (list []*sysin.ServeLogListModel, totalCount int, err error) {
|
||||
func (s *sSysServeLog) List(ctx context.Context, in *sysin.ServeLogListInp) (list []*sysin.ServeLogListModel, totalCount int, err error) {
|
||||
mod := dao.SysServeLog.Ctx(ctx)
|
||||
|
||||
// 查询链路ID
|
||||
@@ -86,7 +86,7 @@ func (s *sSysServeLog) List(ctx context.Context, in sysin.ServeLogListInp) (list
|
||||
}
|
||||
|
||||
// Export 导出服务日志
|
||||
func (s *sSysServeLog) Export(ctx context.Context, in sysin.ServeLogListInp) (err error) {
|
||||
func (s *sSysServeLog) Export(ctx context.Context, in *sysin.ServeLogListInp) (err error) {
|
||||
list, totalCount, err := s.List(ctx, in)
|
||||
if err != nil {
|
||||
return
|
||||
@@ -113,13 +113,13 @@ func (s *sSysServeLog) Export(ctx context.Context, in sysin.ServeLogListInp) (er
|
||||
}
|
||||
|
||||
// Delete 删除服务日志
|
||||
func (s *sSysServeLog) Delete(ctx context.Context, in sysin.ServeLogDeleteInp) (err error) {
|
||||
func (s *sSysServeLog) Delete(ctx context.Context, in *sysin.ServeLogDeleteInp) (err error) {
|
||||
_, err = dao.SysServeLog.Ctx(ctx).Where(dao.SysServeLog.Columns().Id, in.Id).Delete()
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取服务日志指定信息
|
||||
func (s *sSysServeLog) View(ctx context.Context, in sysin.ServeLogViewInp) (res *sysin.ServeLogViewModel, err error) {
|
||||
func (s *sSysServeLog) View(ctx context.Context, in *sysin.ServeLogViewInp) (res *sysin.ServeLogViewModel, err error) {
|
||||
err = dao.SysServeLog.Ctx(ctx).Where(dao.SysServeLog.Columns().Id, in.Id).Scan(&res)
|
||||
return
|
||||
}
|
||||
|
@@ -18,7 +18,6 @@ import (
|
||||
"hotgo/internal/library/sms"
|
||||
"hotgo/internal/model"
|
||||
"hotgo/internal/model/entity"
|
||||
"hotgo/internal/model/input/form"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
"hotgo/internal/service"
|
||||
"hotgo/utility/validate"
|
||||
@@ -36,13 +35,13 @@ func init() {
|
||||
}
|
||||
|
||||
// Delete 删除
|
||||
func (s *sSysSmsLog) Delete(ctx context.Context, in sysin.SmsLogDeleteInp) (err error) {
|
||||
_, err = dao.SysSmsLog.Ctx(ctx).Where("id", in.Id).Delete()
|
||||
func (s *sSysSmsLog) Delete(ctx context.Context, in *sysin.SmsLogDeleteInp) (err error) {
|
||||
_, err = dao.SysSmsLog.Ctx(ctx).WherePri(in.Id).Delete()
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 修改/新增
|
||||
func (s *sSysSmsLog) Edit(ctx context.Context, in sysin.SmsLogEditInp) (err error) {
|
||||
func (s *sSysSmsLog) Edit(ctx context.Context, in *sysin.SmsLogEditInp) (err error) {
|
||||
if in.Ip == "" {
|
||||
err = gerror.New("ip不能为空")
|
||||
return
|
||||
@@ -50,7 +49,7 @@ func (s *sSysSmsLog) Edit(ctx context.Context, in sysin.SmsLogEditInp) (err erro
|
||||
|
||||
// 修改
|
||||
if in.Id > 0 {
|
||||
_, err = dao.SysSmsLog.Ctx(ctx).Where("id", in.Id).Data(in).Update()
|
||||
_, err = dao.SysSmsLog.Ctx(ctx).WherePri(in.Id).Data(in).Update()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -59,8 +58,8 @@ func (s *sSysSmsLog) Edit(ctx context.Context, in sysin.SmsLogEditInp) (err erro
|
||||
return
|
||||
}
|
||||
|
||||
// Status 更新部门状态
|
||||
func (s *sSysSmsLog) Status(ctx context.Context, in sysin.SmsLogStatusInp) (err error) {
|
||||
// Status 更新短信状态
|
||||
func (s *sSysSmsLog) Status(ctx context.Context, in *sysin.SmsLogStatusInp) (err error) {
|
||||
if in.Id <= 0 {
|
||||
err = gerror.New("ID不能为空")
|
||||
return
|
||||
@@ -77,30 +76,13 @@ func (s *sSysSmsLog) Status(ctx context.Context, in sysin.SmsLogStatusInp) (err
|
||||
}
|
||||
|
||||
// 修改
|
||||
_, err = dao.SysSmsLog.Ctx(ctx).Where("id", in.Id).Data("status", in.Status).Update()
|
||||
return
|
||||
}
|
||||
|
||||
// MaxSort 最大排序
|
||||
func (s *sSysSmsLog) MaxSort(ctx context.Context, in sysin.SmsLogMaxSortInp) (res *sysin.SmsLogMaxSortModel, err error) {
|
||||
if in.Id > 0 {
|
||||
if err = dao.SysSmsLog.Ctx(ctx).Where("id", in.Id).Order("sort desc").Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if res == nil {
|
||||
res = new(sysin.SmsLogMaxSortModel)
|
||||
}
|
||||
|
||||
res.Sort = form.DefaultMaxSort(ctx, res.Sort)
|
||||
_, err = dao.SysSmsLog.Ctx(ctx).WherePri(in.Id).Data(dao.SysSmsLog.Columns().Status, in.Status).Update()
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定字典类型信息
|
||||
func (s *sSysSmsLog) View(ctx context.Context, in sysin.SmsLogViewInp) (res *sysin.SmsLogViewModel, err error) {
|
||||
if err = dao.SysSmsLog.Ctx(ctx).Where("id", in.Id).Scan(&res); err != nil {
|
||||
func (s *sSysSmsLog) View(ctx context.Context, in *sysin.SmsLogViewInp) (res *sysin.SmsLogViewModel, err error) {
|
||||
if err = dao.SysSmsLog.Ctx(ctx).WherePri(in.Id).Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return
|
||||
}
|
||||
@@ -108,44 +90,49 @@ func (s *sSysSmsLog) View(ctx context.Context, in sysin.SmsLogViewInp) (res *sys
|
||||
}
|
||||
|
||||
// List 获取列表
|
||||
func (s *sSysSmsLog) List(ctx context.Context, in sysin.SmsLogListInp) (list []*sysin.SmsLogListModel, totalCount int, err error) {
|
||||
func (s *sSysSmsLog) List(ctx context.Context, in *sysin.SmsLogListInp) (list []*sysin.SmsLogListModel, totalCount int, err error) {
|
||||
mod := dao.SysSmsLog.Ctx(ctx)
|
||||
cols := dao.SysSmsLog.Columns()
|
||||
|
||||
if in.Mobile != "" {
|
||||
mod = mod.WhereLike("mobile", "%"+in.Mobile+"%")
|
||||
mod = mod.WhereLike(cols.Mobile, "%"+in.Mobile+"%")
|
||||
}
|
||||
|
||||
if in.Ip != "" {
|
||||
mod = mod.Where("ip", in.Ip)
|
||||
mod = mod.Where(cols.Ip, in.Ip)
|
||||
}
|
||||
|
||||
if in.Event != "" {
|
||||
mod = mod.Where("event", in.Event)
|
||||
mod = mod.Where(cols.Event, in.Event)
|
||||
}
|
||||
|
||||
if in.Status > 0 {
|
||||
mod = mod.Where("status", in.Status)
|
||||
mod = mod.Where(cols.Status, in.Status)
|
||||
}
|
||||
|
||||
if len(in.CreatedAt) == 2 {
|
||||
mod = mod.WhereBetween(cols.CreatedAt, in.CreatedAt[0], in.CreatedAt[1])
|
||||
}
|
||||
|
||||
totalCount, err = mod.Count()
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, totalCount, err
|
||||
return
|
||||
}
|
||||
|
||||
if totalCount == 0 {
|
||||
return list, totalCount, nil
|
||||
return
|
||||
}
|
||||
|
||||
if err = mod.Page(in.Page, in.PerPage).Order("id desc").Scan(&list); err != nil {
|
||||
if err = mod.Page(in.Page, in.PerPage).OrderDesc(cols.Id).Scan(&list); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return list, totalCount, err
|
||||
return
|
||||
}
|
||||
return list, totalCount, err
|
||||
return
|
||||
}
|
||||
|
||||
// SendCode 发送验证码
|
||||
func (s *sSysSmsLog) SendCode(ctx context.Context, in sysin.SendCodeInp) (err error) {
|
||||
func (s *sSysSmsLog) SendCode(ctx context.Context, in *sysin.SendCodeInp) (err error) {
|
||||
if in.Event == "" {
|
||||
err = gerror.New("事件不能为空")
|
||||
return
|
||||
@@ -157,7 +144,7 @@ func (s *sSysSmsLog) SendCode(ctx context.Context, in sysin.SendCodeInp) (err er
|
||||
}
|
||||
|
||||
var models *entity.SysSmsLog
|
||||
if err = dao.SysSmsLog.Ctx(ctx).Where("event", in.Event).Where("mobile", in.Mobile).Scan(&models); err != nil {
|
||||
if err = dao.SysSmsLog.Ctx(ctx).Where(dao.SysSmsLog.Columns().Event, in.Event).Where(dao.SysSmsLog.Columns().Mobile, in.Mobile).Scan(&models); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return
|
||||
}
|
||||
@@ -179,7 +166,7 @@ func (s *sSysSmsLog) SendCode(ctx context.Context, in sysin.SendCodeInp) (err er
|
||||
in.Code = grand.Digits(4)
|
||||
}
|
||||
|
||||
if err = sms.New(config.SmsDrive).SendCode(ctx, in, config); err != nil {
|
||||
if err = sms.New(config.SmsDrive).SendCode(ctx, in); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -272,7 +259,7 @@ func (s *sSysSmsLog) AllowSend(ctx context.Context, models *entity.SysSmsLog, co
|
||||
}
|
||||
|
||||
// VerifyCode 效验验证码
|
||||
func (s *sSysSmsLog) VerifyCode(ctx context.Context, in sysin.VerifyCodeInp) (err error) {
|
||||
func (s *sSysSmsLog) VerifyCode(ctx context.Context, in *sysin.VerifyCodeInp) (err error) {
|
||||
if in.Event == "" {
|
||||
err = gerror.New("事件不能为空")
|
||||
return
|
||||
@@ -289,7 +276,8 @@ func (s *sSysSmsLog) VerifyCode(ctx context.Context, in sysin.VerifyCodeInp) (er
|
||||
}
|
||||
|
||||
var models *entity.SysSmsLog
|
||||
if err = dao.SysSmsLog.Ctx(ctx).Where("event", in.Event).Where("mobile", in.Mobile).Order("id desc").Scan(&models); err != nil {
|
||||
cols := dao.SysSmsLog.Columns()
|
||||
if err = dao.SysSmsLog.Ctx(ctx).Where(cols.Event, in.Event).Where(cols.Mobile, in.Mobile).OrderDesc(cols.Id).Scan(&models); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
return
|
||||
}
|
||||
@@ -317,15 +305,15 @@ func (s *sSysSmsLog) VerifyCode(ctx context.Context, in sysin.VerifyCodeInp) (er
|
||||
}
|
||||
|
||||
if models.Code != in.Code {
|
||||
_, _ = dao.SysSmsLog.Ctx(ctx).Where("id", models.Id).Increment("times", 1)
|
||||
_, _ = dao.SysSmsLog.Ctx(ctx).WherePri(models.Id).Increment(cols.Times, 1)
|
||||
err = gerror.New("验证码错误!")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = dao.SysSmsLog.Ctx(ctx).Where("id", models.Id).Data(g.Map{
|
||||
"times": models.Times + 1,
|
||||
"status": consts.SmsStatusUsed,
|
||||
"updated_at": gtime.Now(),
|
||||
_, err = dao.SysSmsLog.Ctx(ctx).WherePri(models.Id).Data(g.Map{
|
||||
cols.Times: models.Times + 1,
|
||||
cols.Status: consts.SmsStatusUsed,
|
||||
cols.UpdatedAt: gtime.Now(),
|
||||
}).Update()
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user