初始
This commit is contained in:
@ -0,0 +1,125 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成logic操作代码。
|
||||
// 生成日期:2025-03-03 10:33:17
|
||||
// 生成路径: internal/app/system/logic/bus_attendance_machine_user.go
|
||||
// 生成人:gfast
|
||||
// desc:考勤机用户列
|
||||
// company:云南奇讯科技有限公司
|
||||
// ==========================================================================
|
||||
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"github.com/tiger1103/gfast/v3/api/v1/system"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/system/consts"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/system/dao"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/system/model"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/system/model/do"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/system/service"
|
||||
"github.com/tiger1103/gfast/v3/library/liberr"
|
||||
)
|
||||
|
||||
func init() {
|
||||
service.RegisterBusAttendanceMachineUser(New())
|
||||
}
|
||||
|
||||
func New() *sBusAttendanceMachineUser {
|
||||
return &sBusAttendanceMachineUser{}
|
||||
}
|
||||
|
||||
type sBusAttendanceMachineUser struct{}
|
||||
|
||||
func (s *sBusAttendanceMachineUser) List(ctx context.Context, req *system.BusAttendanceMachineUserSearchReq) (listRes *system.BusAttendanceMachineUserSearchRes, err error) {
|
||||
listRes = new(system.BusAttendanceMachineUserSearchRes)
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
m := dao.BusAttendanceMachineUser.Ctx(ctx).WithAll()
|
||||
if req.Id != "" {
|
||||
m = m.Where(dao.BusAttendanceMachineUser.Columns().Id+" = ?", req.Id)
|
||||
}
|
||||
if req.MachineId != "" {
|
||||
m = m.Where(dao.BusAttendanceMachineUser.Columns().MachineId+" = ?", gconv.Int64(req.MachineId))
|
||||
}
|
||||
if req.TeamId != "" {
|
||||
m = m.Where(dao.BusAttendanceMachineUser.Columns().TeamId+" = ?", gconv.Int64(req.TeamId))
|
||||
}
|
||||
if req.UserId != "" {
|
||||
m = m.Where(dao.BusAttendanceMachineUser.Columns().UserId+" = ?", gconv.Int64(req.UserId))
|
||||
}
|
||||
if req.Identifying != "" {
|
||||
m = m.Where(dao.BusAttendanceMachineUser.Columns().Identifying+" = ?", gconv.Int(req.Identifying))
|
||||
}
|
||||
listRes.Total, err = m.Count()
|
||||
liberr.ErrIsNil(ctx, err, "获取总行数失败")
|
||||
if req.PageNum == 0 {
|
||||
req.PageNum = 1
|
||||
}
|
||||
listRes.CurrentPage = req.PageNum
|
||||
if req.PageSize == 0 {
|
||||
req.PageSize = consts.PageSize
|
||||
}
|
||||
order := "id asc"
|
||||
if req.OrderBy != "" {
|
||||
order = req.OrderBy
|
||||
}
|
||||
var res []*model.BusAttendanceMachineUserInfoRes
|
||||
err = m.Fields(system.BusAttendanceMachineUserSearchRes{}).Page(req.PageNum, req.PageSize).Order(order).Scan(&res)
|
||||
liberr.ErrIsNil(ctx, err, "获取数据失败")
|
||||
listRes.List = make([]*model.BusAttendanceMachineUserListRes, len(res))
|
||||
for k, v := range res {
|
||||
listRes.List[k] = &model.BusAttendanceMachineUserListRes{
|
||||
Id: v.Id,
|
||||
MachineId: v.MachineId,
|
||||
TeamId: v.TeamId,
|
||||
UserId: v.UserId,
|
||||
Identifying: v.Identifying,
|
||||
}
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sBusAttendanceMachineUser) GetById(ctx context.Context, id int64) (res *model.BusAttendanceMachineUserInfoRes, err error) {
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
err = dao.BusAttendanceMachineUser.Ctx(ctx).WithAll().Where(dao.BusAttendanceMachineUser.Columns().Id, id).Scan(&res)
|
||||
liberr.ErrIsNil(ctx, err, "获取信息失败")
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sBusAttendanceMachineUser) Add(ctx context.Context, req *system.BusAttendanceMachineUserAddReq) (err error) {
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
_, err = dao.BusAttendanceMachineUser.Ctx(ctx).Insert(do.BusAttendanceMachineUser{
|
||||
Id: req.Id,
|
||||
MachineId: req.MachineId,
|
||||
TeamId: req.TeamId,
|
||||
UserId: req.UserId,
|
||||
Identifying: req.Identifying,
|
||||
})
|
||||
liberr.ErrIsNil(ctx, err, "添加失败")
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sBusAttendanceMachineUser) Edit(ctx context.Context, req *system.BusAttendanceMachineUserEditReq) (err error) {
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
_, err = dao.BusAttendanceMachineUser.Ctx(ctx).WherePri(req.Id).Update(do.BusAttendanceMachineUser{
|
||||
MachineId: req.MachineId,
|
||||
TeamId: req.TeamId,
|
||||
UserId: req.UserId,
|
||||
Identifying: req.Identifying,
|
||||
})
|
||||
liberr.ErrIsNil(ctx, err, "修改失败")
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sBusAttendanceMachineUser) Delete(ctx context.Context, ids []int64) (err error) {
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
_, err = dao.BusAttendanceMachineUser.Ctx(ctx).Delete(dao.BusAttendanceMachineUser.Columns().Id+" in (?)", ids)
|
||||
liberr.ErrIsNil(ctx, err, "删除失败")
|
||||
})
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user