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,152 @@
// ==========================================================================
// GFast自动生成logic操作代码。
// 生成日期2023-08-07 10:17:41
// 生成路径: internal/app/system/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/v1/system"
"github.com/tiger1103/gfast/v3/internal/app/system/consts"
"github.com/tiger1103/gfast/v3/internal/app/system/dao"
logic "github.com/tiger1103/gfast/v3/internal/app/system/logic/busQuestionSave"
"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.RegisterBusConstructionUserFile(New())
}
func New() *sBusConstructionUserFile {
return &sBusConstructionUserFile{}
}
type sBusConstructionUserFile struct{}
func (s *sBusConstructionUserFile) List(ctx context.Context, req *system.BusConstructionUserFileSearchReq) (listRes *system.BusConstructionUserFileSearchRes, err error) {
listRes = new(system.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(system.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) GetBySafetyId(ctx context.Context, req *system.BusConstructionUserFileGetSafetyFileReq) (res *system.BusConstructionUserFileGetSafetyFileRes, err error) {
res = new(system.BusConstructionUserFileGetSafetyFileRes)
err = g.Try(ctx, func(ctx context.Context) {
//施工人员表 openid 和名字
var openidName *model.BusConstructionUserSafetyFileReq
dao.BusConstructionUser.Ctx(ctx).Fields("openid as openid,user_name as userName").Where("id = ?", req.Id).Scan(&openidName)
// 添加对openidName是否为空的判断
if openidName == nil {
return
}
var weChatPdf *system.WeChatPdfWoReq = new(system.WeChatPdfWoReq)
weChatPdf.ProjectId = req.ProjectId
weChatPdf.Name = openidName.UserName
slienWechatPdf, err := logic.WeChatPdfWo(context.TODO(), weChatPdf)
liberr.ErrIsNil(ctx, err, "查询pdf失败")
var BusWechatFileRes *model.BusWechatFileRes
for _, k := range slienWechatPdf {
k.Openid = openidName.Openid
BusWechatFileRes = &model.BusWechatFileRes{
Path: k.Path,
Type: k.Type,
}
}
res.List = BusWechatFileRes
liberr.ErrIsNil(ctx, err, "获取信息失败")
})
return
}
func (s *sBusConstructionUserFile) Add(ctx context.Context, req *system.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,
Path: req.Path,
})
liberr.ErrIsNil(ctx, err, "添加失败")
})
return
}
func (s *sBusConstructionUserFile) Edit(ctx context.Context, req *system.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,
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
}