This commit is contained in:
2025-07-07 20:11:59 +08:00
parent ab0fdbc447
commit 06e3aa2eb3
2009 changed files with 193082 additions and 0 deletions

View File

@ -0,0 +1,124 @@
// ==========================================================================
// GFast自动生成logic操作代码。
// 生成日期2023-08-07 11:17:55
// 生成路径: internal/app/wxApplet/logic/bus_construction_user_file.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/wxApplet/wxApplet"
"github.com/tiger1103/gfast/v3/internal/app/system/consts"
"github.com/tiger1103/gfast/v3/internal/app/wxApplet/dao"
"github.com/tiger1103/gfast/v3/internal/app/wxApplet/model"
"github.com/tiger1103/gfast/v3/internal/app/wxApplet/model/do"
"github.com/tiger1103/gfast/v3/internal/app/wxApplet/service"
"github.com/tiger1103/gfast/v3/library/liberr"
)
func init() {
service.RegisterBusConstructionUserFile(New())
}
func New() *sBusConstructionUserFile {
return &sBusConstructionUserFile{}
}
type sBusConstructionUserFile struct{}
func (s *sBusConstructionUserFile) List(ctx context.Context, req *wxApplet.BusConstructionUserFileSearchReq) (listRes *wxApplet.BusConstructionUserFileSearchRes, err error) {
listRes = new(wxApplet.BusConstructionUserFileSearchRes)
err = g.Try(ctx, func(ctx context.Context) {
m := dao.BusConstructionUserFile.Ctx(ctx).WithAll()
if req.Id != "" {
m = m.Where(dao.BusConstructionUserFile.Columns().Id+" = ?", req.Id)
}
if req.UserId != "" {
m = m.Where(dao.BusConstructionUserFile.Columns().UserId+" = ?", gconv.Int64(req.UserId))
}
if req.UserImgType != "" {
m = m.Where(dao.BusConstructionUserFile.Columns().UserImgType+" = ?", req.UserImgType)
}
if req.Path != "" {
m = m.Where(dao.BusConstructionUserFile.Columns().Path+" = ?", req.Path)
}
if len(req.DateRange) != 0 {
m = m.Where(dao.BusConstructionUserFile.Columns().CreatedAt+" >=? AND "+dao.BusConstructionUserFile.Columns().CreatedAt+" <=?", req.DateRange[0], req.DateRange[1])
}
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 desc"
if req.OrderBy != "" {
order = req.OrderBy
}
var res []*model.BusConstructionUserFileInfoRes
err = m.Fields(wxApplet.BusConstructionUserFileSearchRes{}).Page(req.PageNum, req.PageSize).Order(order).Scan(&res)
liberr.ErrIsNil(ctx, err, "获取数据失败")
listRes.List = make([]*model.BusConstructionUserFileListRes, len(res))
for k, v := range res {
listRes.List[k] = &model.BusConstructionUserFileListRes{
Id: v.Id,
UserId: v.UserId,
UserImgType: v.UserImgType,
Path: v.Path,
CreatedAt: v.CreatedAt,
}
}
})
return
}
func (s *sBusConstructionUserFile) GetById(ctx context.Context, id int64) (res *model.BusConstructionUserFileInfoRes, err error) {
err = g.Try(ctx, func(ctx context.Context) {
err = dao.BusConstructionUserFile.Ctx(ctx).WithAll().Where(dao.BusConstructionUserFile.Columns().Id, id).Scan(&res)
liberr.ErrIsNil(ctx, err, "获取信息失败")
})
return
}
func (s *sBusConstructionUserFile) Add(ctx context.Context, req *wxApplet.BusConstructionUserFileAddReq) (err error) {
err = g.Try(ctx, func(ctx context.Context) {
_, err = dao.BusConstructionUserFile.Ctx(ctx).Insert(do.BusConstructionUserFile{
UserId: req.UserId,
UserImgType: req.UserImgType,
Name: req.Name,
Path: req.Path,
})
liberr.ErrIsNil(ctx, err, "添加失败")
})
return
}
func (s *sBusConstructionUserFile) Edit(ctx context.Context, req *wxApplet.BusConstructionUserFileEditReq) (err error) {
err = g.Try(ctx, func(ctx context.Context) {
_, err = dao.BusConstructionUserFile.Ctx(ctx).WherePri(req.Id).Update(do.BusConstructionUserFile{
UserId: req.UserId,
UserImgType: req.UserImgType,
Name: req.Name,
Path: req.Path,
})
liberr.ErrIsNil(ctx, err, "修改失败")
})
return
}
func (s *sBusConstructionUserFile) Delete(ctx context.Context, ids []int64) (err error) {
err = g.Try(ctx, func(ctx context.Context) {
_, err = dao.BusConstructionUserFile.Ctx(ctx).Delete(dao.BusConstructionUserFile.Columns().Id+" in (?)", ids)
liberr.ErrIsNil(ctx, err, "删除失败")
})
return
}