chore: 初始开源发布
iotlcm-app:小程序端 + 用户端服务。 - app/:uni-app 小程序前端(基于 unibest,MIT) - 微信 AppID → YOUR_WX_APPID,uni-app AppID → __UNI__YOURAPPID - 内网后端地址 → admin.iotlcm.example.com - 应用标题与 unibest 模板 README 重写(保留上游致谢与 MIT 声明) - server/:GoFrame 用户端服务(基于 XiuAdmin,Apache-2.0) - module xiuadmin → git.5iot.com/iotlcm-public/iotlcm-app(360 文件) - 支付回调地址 → app.iotlcm.example.com,商户名与应用名泛化 - 真实手机号 → 合法 11 位编造号(保留号段前 3 位 + 后 4 位) - 依赖号码尾部的断言同步更新 - 补 server/LICENSE(Apache-2.0) - 移除内部资产:CI 触发器 - 补根 README,LF 行尾 + .gitattributes 已知:TestSysDept_RefreshDeptAncestors 在源仓同一提交上同样失败,属既有缺陷。
This commit is contained in:
@@ -0,0 +1,168 @@
|
||||
// package system
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/dao"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/contexts"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/xgorm/handler"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/model"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/model/do"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/model/entity"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/service"
|
||||
|
||||
"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/gtime"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
type sSysOssConfig struct {
|
||||
}
|
||||
|
||||
func NewSysOssConfig() *sSysOssConfig {
|
||||
return &sSysOssConfig{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
service.RegisterSysOssConfig(NewSysOssConfig())
|
||||
}
|
||||
|
||||
func (s *sSysOssConfig) 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.SysOssConfig.Ctx(ctx), option...)
|
||||
}
|
||||
|
||||
func (s *sSysOssConfig) List(ctx context.Context, param *model.SysOssConfigListParam) (items []*model.SysOssConfigListModel, total int, err error) {
|
||||
|
||||
db := s.Model(ctx)
|
||||
|
||||
if param.ConfigKey != "" {
|
||||
db = db.WhereLike(dao.SysOssConfig.Columns().ConfigKey, "%"+param.ConfigKey+"%")
|
||||
}
|
||||
|
||||
if param.BucketName != "" {
|
||||
db = db.WhereLike(dao.SysOssConfig.Columns().BucketName, "%"+param.BucketName+"%")
|
||||
}
|
||||
if param.Status != "" {
|
||||
db = db.Where(dao.SysOssConfig.Columns().Status, param.Status)
|
||||
}
|
||||
|
||||
total, err = db.Count()
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
err = db.Page(param.Page, param.PageSize).OrderAsc(dao.SysOssConfig.Columns().OssConfigId).Scan(&items)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sSysOssConfig) View(ctx context.Context, param *model.SysOssConfigViewParam) (item *model.SysOssConfigViewModel, err error) {
|
||||
db := s.Model(ctx)
|
||||
if param.OssConfigId > 0 {
|
||||
db = db.Where(dao.SysOssConfig.Columns().OssConfigId, param.OssConfigId)
|
||||
} else if param.ConfigKey != "" {
|
||||
db = db.Where(dao.SysOssConfig.Columns().ConfigKey, param.ConfigKey)
|
||||
} else {
|
||||
g.Log().Errorf(ctx, "sSysOssConfig View 参数错误: %+v", param)
|
||||
return nil, gerror.New("参数错误")
|
||||
}
|
||||
err = db.Scan(&item)
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sSysOssConfig) Add(ctx context.Context, param *model.SysOssConfigAddParam) (item *model.SysOssConfigAddModel, err error) {
|
||||
db := s.Model(ctx)
|
||||
data := &do.SysOssConfig{}
|
||||
gconv.Struct(param, data)
|
||||
data.CreatedAt = gtime.Now()
|
||||
data.CreatedBy = contexts.GetUserId(ctx)
|
||||
data.CreatedDept = contexts.GetDeptId(ctx)
|
||||
data.TenantId = contexts.GetTenantId(ctx)
|
||||
if len(param.Status) == 0 {
|
||||
data.Status = "1"
|
||||
}
|
||||
|
||||
id, err := db.Data(data).OmitNil().InsertAndGetId()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
item = &model.SysOssConfigAddModel{
|
||||
OssConfigId: id,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sSysOssConfig) Edit(ctx context.Context, param *model.SysOssConfigEditParam) (item *model.SysOssConfigEditModel, err error) {
|
||||
item = &model.SysOssConfigEditModel{
|
||||
OssConfigId: param.OssConfigId,
|
||||
}
|
||||
db := s.Model(ctx)
|
||||
data := &do.SysOssConfig{}
|
||||
gconv.Struct(param, data)
|
||||
data.OssConfigId = nil
|
||||
data.UpdatedAt = gtime.Now()
|
||||
data.UpdatedBy = contexts.GetUserId(ctx)
|
||||
if param.Status == nil || *param.Status == "" {
|
||||
data.Status = nil
|
||||
}
|
||||
|
||||
_, err = db.Data(data).OmitNil().Where(dao.SysOssConfig.Columns().OssConfigId, param.OssConfigId).Update()
|
||||
if err != nil {
|
||||
return item, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sSysOssConfig) Delete(ctx context.Context, param *model.SysOssConfigDeleteParam) (item *model.SysOssConfigDeleteModel, err error) {
|
||||
item = &model.SysOssConfigDeleteModel{
|
||||
OssConfigIds: param.OssConfigIds,
|
||||
}
|
||||
db := s.Model(ctx)
|
||||
_, err = db.WhereIn(dao.SysOssConfig.Columns().OssConfigId, param.OssConfigIds).Delete()
|
||||
if err != nil {
|
||||
return item, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sSysOssConfig) GetAllUrlByService(ctx context.Context, path string, tenantId string, ossService string) (allUrl string, err error) {
|
||||
ossConfig := &entity.SysOssConfig{}
|
||||
db := s.Model(ctx)
|
||||
db = db.Where(dao.SysOssConfig.Columns().ConfigKey, ossService)
|
||||
db = db.Where(dao.SysOssConfig.Columns().TenantId, tenantId)
|
||||
err = db.Scan(&ossConfig)
|
||||
if err != nil {
|
||||
g.Log().Errorf(ctx, "sSysOss GetAllUrlByService error: %+v, url: %s ,service: %s", err, path, ossService)
|
||||
return "", err
|
||||
}
|
||||
if ossConfig == nil {
|
||||
g.Log().Errorf(ctx, "sSysOss GetAllUrlByService error: ossConfig is empty, url: %s ,service: %s", path, ossService)
|
||||
err = gerror.New("ossConfig is empty")
|
||||
return
|
||||
}
|
||||
domain := ossConfig.Endpoint
|
||||
if ossConfig.Domain != "" {
|
||||
domain = ossConfig.Domain
|
||||
}
|
||||
if ossConfig.IsHttps == "Y" {
|
||||
allUrl = "https://" + domain + path
|
||||
} else {
|
||||
allUrl = "http://" + domain + path
|
||||
}
|
||||
g.Log().Infof(ctx, "sSysOss GetAllUrlByService success: %s, url: %s, ossConfig: %+v", ossService, allUrl, ossConfig)
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user