初始
This commit is contained in:
@ -0,0 +1,176 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成logic操作代码。
|
||||
// 生成日期:2023-07-29 09:31:22
|
||||
// 生成路径: internal/app/system/logic/bus_engineering_quality.go
|
||||
// 生成人:gfast
|
||||
// desc:工程质量列
|
||||
// company:云南奇讯科技有限公司
|
||||
// ==========================================================================
|
||||
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/tiger1103/gfast/v3/api/v1/common/coryCommon"
|
||||
ct "github.com/tiger1103/gfast/v3/internal/app/system/logic/context"
|
||||
|
||||
"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/libUtils"
|
||||
"github.com/tiger1103/gfast/v3/library/liberr"
|
||||
)
|
||||
|
||||
func init() {
|
||||
service.RegisterBusEngineeringQuality(New())
|
||||
}
|
||||
|
||||
func New() *sBusEngineeringQuality {
|
||||
return &sBusEngineeringQuality{}
|
||||
}
|
||||
|
||||
type sBusEngineeringQuality struct{}
|
||||
|
||||
// BusEngineeringQualityUploading 文件上传 单文件
|
||||
func (s *sBusEngineeringQuality) BusEngineeringQualityUploading(ctx context.Context, req *system.BusEngineeringQualityUploadingReq) (err error) {
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
name := ct.New().GetLoginUser(ctx).Id
|
||||
for _, obj := range req.FileUrl {
|
||||
obj.Url, err = libUtils.GetFilesPath(ctx, obj.Url)
|
||||
liberr.ErrIsNil(ctx, err)
|
||||
}
|
||||
_, err = dao.BusEngineeringQuality.Ctx(ctx).WherePri(req.Id).Update(do.BusEngineeringQuality{
|
||||
FileUrl: req.FileUrl,
|
||||
UpdateBy: name,
|
||||
})
|
||||
liberr.ErrIsNil(ctx, err, "修改失败")
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sBusEngineeringQuality) List(ctx context.Context, req *system.BusEngineeringQualitySearchReq) (listRes *system.BusEngineeringQualitySearchRes, err error) {
|
||||
listRes = new(system.BusEngineeringQualitySearchRes)
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
m := dao.BusEngineeringQuality.Ctx(ctx).WithAll()
|
||||
if req.UnitName1 != "" {
|
||||
m = m.Where(dao.BusEngineeringQuality.Columns().UnitName1+" = ?", req.UnitName1)
|
||||
}
|
||||
if req.UnitName2 != "" {
|
||||
m = m.Where(dao.BusEngineeringQuality.Columns().UnitName2+" = ?", req.UnitName2)
|
||||
}
|
||||
if req.UnitName3 != "" {
|
||||
m = m.Where(dao.BusEngineeringQuality.Columns().UnitName3+" = ?", req.UnitName3)
|
||||
}
|
||||
if req.UnitName4 != "" {
|
||||
m = m.Where(dao.BusEngineeringQuality.Columns().UnitName4+" = ?", req.UnitName4)
|
||||
}
|
||||
if req.UnitName5 != "" {
|
||||
m = m.Where(dao.BusEngineeringQuality.Columns().UnitName5+" = ?", req.UnitName5)
|
||||
}
|
||||
if req.UnitName6 != "" {
|
||||
m = m.Where(dao.BusEngineeringQuality.Columns().UnitName6+" = ?", req.UnitName6)
|
||||
}
|
||||
if req.QualityName != "" {
|
||||
m = m.Where(dao.BusEngineeringQuality.Columns().QualityName+" like ?", "%"+req.QualityName+"%")
|
||||
}
|
||||
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.BusEngineeringQualityInfoRes
|
||||
err = m.Fields(system.BusEngineeringQualitySearchRes{}).Page(req.PageNum, req.PageSize).Order(order).Scan(&res)
|
||||
liberr.ErrIsNil(ctx, err, "获取数据失败")
|
||||
listRes.List = make([]*model.BusEngineeringQualityListRes, len(res))
|
||||
for k, v := range res {
|
||||
//fileUrl := ([]*comModel.UpFile)(nil)
|
||||
//err = gjson.DecodeTo(v.FileUrl, &fileUrl)
|
||||
//liberr.ErrIsNil(ctx, err)
|
||||
listRes.List[k] = &model.BusEngineeringQualityListRes{
|
||||
Id: v.Id,
|
||||
UnitName1: v.UnitName1,
|
||||
UnitName2: v.UnitName2,
|
||||
UnitName3: v.UnitName3,
|
||||
UnitName4: v.UnitName4,
|
||||
UnitName5: v.UnitName5,
|
||||
UnitName6: v.UnitName6,
|
||||
QualityName: v.QualityName,
|
||||
Status: v.Status,
|
||||
CreateBy: v.CreateBy,
|
||||
CreateTime: v.CreateTime,
|
||||
UpdateTime: v.UpdateTime,
|
||||
}
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sBusEngineeringQuality) GetById(ctx context.Context, id uint64) (res *model.BusEngineeringQualityInfoRes, err error) {
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
err = dao.BusEngineeringQuality.Ctx(ctx).WithAll().Where(dao.BusEngineeringQuality.Columns().Id, id).Scan(&res)
|
||||
liberr.ErrIsNil(ctx, err, "获取信息失败")
|
||||
//获取创建人 更新人
|
||||
by := coryCommon.New().CreateByOrUpdateBy(ctx, res)
|
||||
infoRes := by.(model.BusEngineeringQualityInfoRes)
|
||||
res = &infoRes
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sBusEngineeringQuality) Add(ctx context.Context, req *system.BusEngineeringQualityAddReq) (err error) {
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
name := ct.New().GetLoginUser(ctx).Id
|
||||
_, err = dao.BusEngineeringQuality.Ctx(ctx).Insert(do.BusEngineeringQuality{
|
||||
UnitName1: req.UnitName1,
|
||||
UnitName2: req.UnitName2,
|
||||
UnitName3: req.UnitName3,
|
||||
UnitName4: req.UnitName4,
|
||||
UnitName5: req.UnitName5,
|
||||
UnitName6: req.UnitName6,
|
||||
QualityName: req.QualityName,
|
||||
ProjectId: req.ProjectId,
|
||||
CreateBy: name,
|
||||
})
|
||||
liberr.ErrIsNil(ctx, err, "添加失败")
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sBusEngineeringQuality) Edit(ctx context.Context, req *system.BusEngineeringQualityEditReq) (err error) {
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
name := ct.New().GetLoginUser(ctx).Id
|
||||
_, err = dao.BusEngineeringQuality.Ctx(ctx).WherePri(req.Id).Update(do.BusEngineeringQuality{
|
||||
UnitName1: req.UnitName1,
|
||||
UnitName2: req.UnitName2,
|
||||
UnitName3: req.UnitName3,
|
||||
UnitName4: req.UnitName4,
|
||||
UnitName5: req.UnitName5,
|
||||
UnitName6: req.UnitName6,
|
||||
QualityName: req.QualityName,
|
||||
Status: req.Status,
|
||||
UpdateBy: name,
|
||||
})
|
||||
liberr.ErrIsNil(ctx, err, "修改失败")
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (s *sBusEngineeringQuality) Delete(ctx context.Context, ids []uint64) (err error) {
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
_, err = dao.BusEngineeringQuality.Ctx(ctx).Delete(dao.BusEngineeringQuality.Columns().Id+" in (?)", ids)
|
||||
liberr.ErrIsNil(ctx, err, "删除失败")
|
||||
})
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user