59eb34976a
iotlcm-admin-svr:管理后台服务。 - Go module:iotlcm → git.5iot.com/iotlcm-public/iotlcm-admin-svr(729 文件) - 凭据与地址脱敏:JWT signingKey(含代码里的 MustGet 默认值)、 MySQL DSN、Redis 口令、告警邮件发件人邮箱全部改为占位; 私网 IP → 文档地址段;库名 xiujie_admin → iotlcm - 真实手机号/邮箱 → 合法 11 位编造号 / example.com - 移除内部资产:CI 触发器、过时 DDL(sql/db_iotlcm.sql)、 私有依赖 go get 行、明文 registry 登录口令 - 启动 banner 统一 IOTLCM 方块字 + 社区惯例署名 - Dockerfile 改用公共基础镜像 - 拼错的 RADEME.md → README.md,README 重写 - 需要真实数据库的用例改为可用 IOTLCM_TEST_WITH_DB=1 显式启用 - 补 Apache-2.0 LICENSE,LF 行尾 + .gitattributes 数据库 schema 不随本仓发布(生产 DDL 已过时),README 已说明。
207 lines
7.1 KiB
Go
207 lines
7.1 KiB
Go
// Package gen
|
|
// @Link https://github.com/xiujiecn/xiu-admin
|
|
// @Copyright Copyright (c) 2026 LiXiujie
|
|
// @Author Lxj <li@xiujie.cn>
|
|
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
|
// @AutoGenerate Version
|
|
package system
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/dao"
|
|
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/library/contexts"
|
|
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/library/xgorm"
|
|
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/library/xgorm/handler"
|
|
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/library/xgorm/hook"
|
|
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/model"
|
|
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/service"
|
|
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/utility/convert"
|
|
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/utility/excel"
|
|
|
|
"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/os/gtime"
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
)
|
|
|
|
type sSysTTplatformSetting struct{}
|
|
|
|
func NewSysTTplatformSetting() *sSysTTplatformSetting {
|
|
return &sSysTTplatformSetting{}
|
|
}
|
|
|
|
func init() {
|
|
service.RegisterSysTTplatformSetting(NewSysTTplatformSetting())
|
|
}
|
|
|
|
// Model 二级域名站点个性化配置表ORM模型
|
|
func (s *sSysTTplatformSetting) Model(ctx context.Context, option ...*handler.Option) *gdb.Model {
|
|
if len(option) == 0 {
|
|
option = append(option, &handler.Option{
|
|
FilterTenant: true,
|
|
FilterAuth: true,
|
|
})
|
|
}
|
|
return handler.Model(dao.TTplatformSetting.Ctx(ctx), option...)
|
|
}
|
|
|
|
// List 获取二级域名站点个性化配置表列表
|
|
func (s *sSysTTplatformSetting) List(ctx context.Context, in *model.TTplatformSettingListParam) (list []*model.TTplatformSettingListModel, totalCount int, err error) {
|
|
mod := s.Model(ctx)
|
|
|
|
// 字段过滤
|
|
mod = mod.Fields(model.TTplatformSettingListModel{})
|
|
|
|
// 查询主键ID
|
|
if in.Id > 0 {
|
|
mod = mod.Where(dao.TTplatformSetting.Columns().Id, in.Id)
|
|
}
|
|
|
|
// 查询状态 0启用 1禁用
|
|
if in.Status > 0 {
|
|
mod = mod.Where(dao.TTplatformSetting.Columns().Status, in.Status)
|
|
}
|
|
|
|
// 查询创建时间
|
|
if len(in.CreatedAt) == 2 {
|
|
in.CreatedAt[1] = in.CreatedAt[1].EndOfDay()
|
|
}
|
|
if len(in.CreatedAt) == 2 {
|
|
mod = mod.WhereBetween(dao.TTplatformSetting.Columns().CreatedAt, in.CreatedAt[0], in.CreatedAt[1])
|
|
}
|
|
|
|
// 分页
|
|
mod = mod.Page(in.Page, in.PageSize)
|
|
|
|
// 排序
|
|
mod = mod.OrderAsc(dao.TTplatformSetting.Columns().Sort).OrderDesc(dao.TTplatformSetting.Columns().Id)
|
|
|
|
// 操作人摘要信息
|
|
mod = mod.Hook(hook.MemberSummary)
|
|
|
|
// 查询数据
|
|
if err = mod.ScanAndCount(&list, &totalCount, false); err != nil {
|
|
err = gerror.Wrap(err, "获取二级域名站点个性化配置表列表失败,请稍后重试!")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
// Export 导出二级域名站点个性化配置表
|
|
func (s *sSysTTplatformSetting) Export(ctx context.Context, in *model.TTplatformSettingListParam) (err error) {
|
|
list, totalCount, err := s.List(ctx, in)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
// 字段的排序是依据tags的字段顺序,如果你不想使用默认的排序方式,可以直接定义 tags = []string{"字段名称", "字段名称2", ...}
|
|
tags, err := convert.GetEntityDescTags(model.TTplatformSettingExportModel{})
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
var (
|
|
fileName = "导出二级域名站点个性化配置表-" + gctx.CtxId(ctx)
|
|
sheetName = fmt.Sprintf("索引条件共%v行,共%v页,当前导出是第%v页,本页共%v行", totalCount, (totalCount+in.PageSize-1)/in.PageSize, in.Page, len(list))
|
|
exports []model.TTplatformSettingExportModel
|
|
)
|
|
|
|
if err = gconv.Scan(list, &exports); err != nil {
|
|
return
|
|
}
|
|
|
|
err = excel.ExportByStructs(ctx, tags, exports, fileName, sheetName)
|
|
return
|
|
}
|
|
|
|
// Edit 修改/新增二级域名站点个性化配置表
|
|
func (s *sSysTTplatformSetting) Edit(ctx context.Context, in *model.TTplatformSettingEditParam) (err error) {
|
|
// 验证'FullDomain'唯一
|
|
if err = xgorm.IsUnique(ctx, &dao.TTplatformSetting, g.Map{dao.TTplatformSetting.Columns().FullDomain: in.FullDomain}, "完整域名已存在", in.Id); err != nil {
|
|
return
|
|
}
|
|
return g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
|
|
|
|
// 修改
|
|
if in.Id > 0 {
|
|
updatedBy := contexts.GetUserId(ctx)
|
|
in.UpdatedBy = &updatedBy
|
|
in.UpdatedAt = gtime.Now()
|
|
tenantId := contexts.GetTenantId(ctx)
|
|
in.TenantId = &tenantId
|
|
if _, err = s.Model(ctx).
|
|
Fields(model.TTplatformSettingUpdateFields{}).
|
|
WherePri(in.Id).Data(in).Update(); err != nil {
|
|
err = gerror.Wrap(err, "修改二级域名站点个性化配置表失败,请稍后重试!")
|
|
}
|
|
return
|
|
}
|
|
|
|
// 新增
|
|
tenantId := contexts.GetTenantId(ctx)
|
|
in.TenantId = &tenantId
|
|
createdDept := contexts.GetDeptId(ctx)
|
|
in.CreatedDept = &createdDept
|
|
createdBy := contexts.GetUserId(ctx)
|
|
in.CreatedBy = &createdBy
|
|
in.CreatedAt = gtime.Now()
|
|
if _, err = s.Model(ctx).
|
|
Fields(model.TTplatformSettingInsertFields{}).
|
|
Data(in).Insert(); err != nil {
|
|
err = gerror.Wrap(err, "新增二级域名站点个性化配置表失败,请稍后重试!")
|
|
}
|
|
return
|
|
})
|
|
}
|
|
|
|
// Delete 删除二级域名站点个性化配置表
|
|
func (s *sSysTTplatformSetting) Delete(ctx context.Context, in *model.TTplatformSettingDeleteParam) (err error) {
|
|
|
|
if _, err = s.Model(ctx).WherePri(in.Id).Unscoped().Delete(); err != nil {
|
|
err = gerror.Wrap(err, "删除二级域名站点个性化配置表失败,请稍后重试!")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
// MaxSort 获取二级域名站点个性化配置表最大排序
|
|
func (s *sSysTTplatformSetting) MaxSort(ctx context.Context, in *model.TTplatformSettingMaxSortParam) (res *model.TTplatformSettingMaxSortModel, err error) {
|
|
if err = dao.TTplatformSetting.Ctx(ctx).Fields(dao.TTplatformSetting.Columns().Sort).OrderDesc(dao.TTplatformSetting.Columns().Sort).Scan(&res); err != nil {
|
|
err = gerror.Wrap(err, "获取二级域名站点个性化配置表最大排序,请稍后重试!")
|
|
return
|
|
}
|
|
|
|
if res == nil {
|
|
res = new(model.TTplatformSettingMaxSortModel)
|
|
}
|
|
|
|
res.Sort = res.Sort + 1
|
|
return
|
|
}
|
|
|
|
// View 获取二级域名站点个性化配置表指定信息
|
|
func (s *sSysTTplatformSetting) View(ctx context.Context, in *model.TTplatformSettingViewParam) (res *model.TTplatformSettingViewModel, err error) {
|
|
g.Log().Info(ctx, "sSysTTplatformSetting.View:", in)
|
|
|
|
if err = dao.TTplatformSetting.Ctx(ctx).Where(dao.TTplatformSetting.Columns().FullDomain, in.FullDomain).Hook(hook.MemberSummary).Scan(&res); err != nil {
|
|
err = gerror.Wrap(err, "获取二级域名站点个性化配置表信息,请稍后重试!")
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
// Status 更新二级域名站点个性化配置表状态
|
|
func (s *sSysTTplatformSetting) Status(ctx context.Context, in *model.TTplatformSettingStatusParam) (err error) {
|
|
if _, err = s.Model(ctx).WherePri(in.Id).Data(g.Map{
|
|
dao.TTplatformSetting.Columns().Status: in.Status,
|
|
dao.TTplatformSetting.Columns().UpdatedBy: contexts.GetUserId(ctx),
|
|
}).Update(); err != nil {
|
|
err = gerror.Wrap(err, "更新二级域名站点个性化配置表状态失败,请稍后重试!")
|
|
return
|
|
}
|
|
return
|
|
}
|