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,113 @@
|
||||
// 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/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/request"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/service"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
type sSysUserOnline struct {
|
||||
}
|
||||
|
||||
func NewSysUserOnline() *sSysUserOnline {
|
||||
return &sSysUserOnline{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
service.RegisterSysUserOnline(NewSysUserOnline())
|
||||
}
|
||||
|
||||
func (s *sSysUserOnline) 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.SysUserOnline.Ctx(ctx), option...)
|
||||
}
|
||||
|
||||
func (s *sSysUserOnline) Add(ctx context.Context, userOnline *model.SysUserOnlineAddModel) (err error) {
|
||||
data := do.SysUserOnline{}
|
||||
gconv.Struct(userOnline, &data)
|
||||
_, err = s.Model(ctx).Data(data).OmitEmpty().Save()
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sSysUserOnline) List(ctx context.Context, query *model.SysUserOnlineListParam, page *request.PageInfo) (items []*model.SysUserOnlineListModel, total int, err error) {
|
||||
tenantId := contexts.GetTenantId(ctx)
|
||||
db := s.Model(ctx).Where(dao.SysUserOnline.Columns().TenantId, tenantId)
|
||||
if query.UserName != "" {
|
||||
db = db.Where(dao.SysUserOnline.Columns().UserName, query.UserName)
|
||||
}
|
||||
if query.ClientKey != "" {
|
||||
db = db.WhereLike(dao.SysUserOnline.Columns().ClientKey, "%"+query.ClientKey+"%")
|
||||
}
|
||||
if query.DeviceType != "" {
|
||||
db = db.Where(dao.SysUserOnline.Columns().DeviceType, query.DeviceType)
|
||||
}
|
||||
if query.Ipaddr != "" {
|
||||
db = db.Where(dao.SysUserOnline.Columns().Ipaddr, query.Ipaddr)
|
||||
}
|
||||
if len(query.LoginTime) == 2 {
|
||||
startTime := gtime.NewFromStr(query.LoginTime[0])
|
||||
endTime := gtime.NewFromStr(query.LoginTime[1])
|
||||
db = db.WhereBetween(dao.SysUserOnline.Columns().LoginTime, startTime, endTime.EndOfDay())
|
||||
}
|
||||
if query.Token != "" {
|
||||
db = db.Where(dao.SysUserOnline.Columns().Token, query.Token)
|
||||
}
|
||||
total, err = db.Count()
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
err = db.Page(page.Page, page.PageSize).Order(dao.SysUserOnline.Columns().LoginTime, "desc").Scan(&items)
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sSysUserOnline) Delete(ctx context.Context, ids []int64) (err error) {
|
||||
if len(ids) == 0 {
|
||||
return errors.New("ids不能为空")
|
||||
}
|
||||
var data = make([]*model.SysUserOnlineViewModel, 0)
|
||||
err = s.Model(ctx).WhereIn(dao.SysUserOnline.Columns().OnlineId, ids).Scan(&data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, v := range data {
|
||||
service.SysAuth().DeleteToken(ctx, v.Token)
|
||||
}
|
||||
_, err = s.Model(ctx).WhereIn(dao.SysUserOnline.Columns().OnlineId, ids).Delete()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sSysUserOnline) DeleteByToken(ctx context.Context, token string) (err error) {
|
||||
var data *model.SysUserOnlineViewModel
|
||||
err = s.Model(ctx).Where(dao.SysUserOnline.Columns().Token, token).Scan(&data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if data != nil && data.Token != "" {
|
||||
service.SysAuth().DeleteToken(ctx, data.Token)
|
||||
}
|
||||
_, err = s.Model(ctx).Where(dao.SysUserOnline.Columns().Token, token).Delete()
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user