chore: 初始开源发布
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 已说明。
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
// 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"
|
||||
"errors"
|
||||
"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/model"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/model/do"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/service"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/utility/uuid32"
|
||||
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
type sSysClient struct {
|
||||
}
|
||||
|
||||
func NewSysClient() *sSysClient {
|
||||
return &sSysClient{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
service.RegisterSysClient(NewSysClient())
|
||||
}
|
||||
|
||||
func (s *sSysClient) List(ctx context.Context, query *model.SysClientListParam) (items []*model.SysClientListModel, total int, err error) {
|
||||
|
||||
db := dao.SysClient.Ctx(ctx)
|
||||
if query.ClientId != "" {
|
||||
db = db.Where(dao.SysClient.Columns().ClientId, query.ClientId)
|
||||
}
|
||||
|
||||
if query.ClientKey != "" {
|
||||
db = db.Where(dao.SysClient.Columns().ClientKey, query.ClientKey)
|
||||
}
|
||||
|
||||
if query.ClientSecret != "" {
|
||||
db = db.Where(dao.SysClient.Columns().ClientSecret, query.ClientSecret)
|
||||
}
|
||||
|
||||
if query.Status != "" {
|
||||
db = db.Where(dao.SysClient.Columns().Status, query.Status)
|
||||
}
|
||||
|
||||
total, err = db.Count()
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
err = db.Page(query.Page, query.PageSize).OrderAsc(dao.SysClient.Columns().Id).Scan(&items)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
return items, total, nil
|
||||
}
|
||||
func (s *sSysClient) View(ctx context.Context, param *model.SysClientViewParam) (item *model.SysClientViewModel, err error) {
|
||||
db := dao.SysClient.Ctx(ctx)
|
||||
if param.Id != 0 {
|
||||
db = db.Where(dao.SysClient.Columns().Id, param.Id)
|
||||
} else if param.ClientId != "" {
|
||||
db = db.Where(dao.SysClient.Columns().ClientId, param.ClientId)
|
||||
} else {
|
||||
return nil, errors.New("未填写查询条件")
|
||||
}
|
||||
err = db.Scan(&item)
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sSysClient) Add(ctx context.Context, param *model.SysClientAddParam) (output *model.SysClientAddModel, err error) {
|
||||
data := &do.SysClient{}
|
||||
gconv.Struct(param, data)
|
||||
data.ClientId = uuid32.S()
|
||||
data.CreatedAt = gtime.Now()
|
||||
data.CreatedBy = contexts.GetUserId(ctx)
|
||||
data.CreatedDept = contexts.GetDeptId(ctx)
|
||||
|
||||
db := dao.SysClient.Ctx(ctx)
|
||||
id, err := db.Data(data).OmitNil().InsertAndGetId()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
output = &model.SysClientAddModel{
|
||||
Id: id,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sSysClient) Edit(ctx context.Context, param *model.SysClientEditParam) (output *model.SysClientEditModel, err error) {
|
||||
data := &do.SysClient{}
|
||||
gconv.Struct(param, data)
|
||||
data.ClientId = nil
|
||||
data.UpdatedAt = gtime.Now()
|
||||
data.UpdatedBy = contexts.GetUserId(ctx)
|
||||
|
||||
db := dao.SysClient.Ctx(ctx)
|
||||
_, err = db.Data(data).OmitNil().Where(dao.SysClient.Columns().Id, param.Id).Update()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
output = &model.SysClientEditModel{
|
||||
Id: param.Id,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sSysClient) Delete(ctx context.Context, param *model.SysClientDeleteParam) (output *model.SysClientDeleteModel, err error) {
|
||||
db := dao.SysClient.Ctx(ctx)
|
||||
data := &do.SysClient{}
|
||||
data.DeletedAt = gtime.Now()
|
||||
data.DeletedBy = contexts.GetUserId(ctx)
|
||||
_, err = db.Data(data).OmitNil().Where(dao.SysClient.Columns().Id, param.Ids).Update()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
output = &model.SysClientDeleteModel{
|
||||
Ids: param.Ids,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sSysClient) Status(ctx context.Context, param *model.SysClientStatusParam) (output *model.SysClientStatusModel, err error) {
|
||||
db := dao.SysClient.Ctx(ctx)
|
||||
_, err = db.Data(param).OmitNil().Where(dao.SysClient.Columns().Id, param.Id).Update()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
output = &model.SysClientStatusModel{
|
||||
Id: param.Id,
|
||||
}
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user