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,141 @@
|
||||
// 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-app/internal/dao"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/contexts"
|
||||
"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/service"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/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)
|
||||
data := &do.SysClient{}
|
||||
gconv.Struct(param, data)
|
||||
data.Id = nil
|
||||
_, err = db.Data(data).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