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,175 @@
// ==========================================================================
// GFast自动生成logic操作代码。
// 生成日期2024-03-13 18:10:56
// 生成路径: internal/app/system/logic/construction_details.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"
systemService "github.com/tiger1103/gfast/v3/internal/app/system/service"
"github.com/tiger1103/gfast/v3/library/liberr"
)
func init() {
service.RegisterConstructionDetails(New())
}
func New() *sConstructionDetails {
return &sConstructionDetails{}
}
type sConstructionDetails struct{}
func (s *sConstructionDetails) List(ctx context.Context, req *system.ConstructionDetailsSearchReq) (listRes *system.ConstructionDetailsSearchRes, err error) {
listRes = new(system.ConstructionDetailsSearchRes)
err = g.Try(ctx, func(ctx context.Context) {
m := dao.ConstructionDetails.Ctx(ctx).WithAll()
if req.Id != "" {
m = m.Where(dao.ConstructionDetails.Columns().Id+" = ?", req.Id)
}
if req.CreatedBy != "" {
m = m.Where(dao.ConstructionDetails.Columns().CreatedBy+" = ?", gconv.Uint64(req.CreatedBy))
}
if len(req.DateRange) != 0 {
m = m.Where(dao.ConstructionDetails.Columns().CreatedAt+" >=? AND "+dao.ConstructionDetails.Columns().CreatedAt+" <=?", req.DateRange[0], req.DateRange[1])
}
if req.Name != "" {
m = m.Where(dao.ConstructionDetails.Columns().Name+" like ?", "%"+req.Name+"%")
}
if req.Types != "" {
m = m.Where(dao.ConstructionDetails.Columns().Types+" = ?", req.Types)
}
if req.Total != "" {
m = m.Where(dao.ConstructionDetails.Columns().Total+" = ?", gconv.Int(req.Total))
}
if req.ConstructionId != "" {
m = m.Where(dao.ConstructionDetails.Columns().ConstructionId+" = ?", gconv.Int(req.ConstructionId))
}
if req.IsPercentage != "" {
m = m.Where(dao.ConstructionDetails.Columns().IsPercentage+" = ?", gconv.Int(req.IsPercentage))
}
if req.StartTime != "" {
m = m.Where(dao.ConstructionDetails.Columns().StartTime+" = ?", gconv.Time(req.StartTime))
}
if req.EndTime != "" {
m = m.Where(dao.ConstructionDetails.Columns().EndTime+" = ?", gconv.Time(req.EndTime))
}
if req.Completed != "" {
m = m.Where(dao.ConstructionDetails.Columns().Completed+" = ?", gconv.Int(req.Completed))
}
if req.Selectable != "" {
m = m.Where(dao.ConstructionDetails.Columns().Selectable+" = ?", gconv.Int(req.Selectable))
}
if req.Overall != "" {
m = m.Where(dao.ConstructionDetails.Columns().Overall+" = ?", gconv.Int(req.Overall))
}
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.ConstructionDetailsInfoRes
err = m.Page(req.PageNum, req.PageSize).Order(order).Scan(&res)
liberr.ErrIsNil(ctx, err, "获取数据失败")
listRes.List = make([]*model.ConstructionDetailsListRes, len(res))
for k, v := range res {
listRes.List[k] = &model.ConstructionDetailsListRes{
Id: v.Id,
CreatedBy: v.CreatedBy,
CreatedAt: v.CreatedAt,
Name: v.Name,
Types: v.Types,
Total: v.Total,
ConstructionId: v.ConstructionId,
Remark: v.Remark,
IsPercentage: v.IsPercentage,
StartTime: v.StartTime,
EndTime: v.EndTime,
Completed: v.Completed,
Selectable: v.Selectable,
Overall: v.Overall,
}
}
})
return
}
func (s *sConstructionDetails) GetById(ctx context.Context, id uint64) (res *model.ConstructionDetailsInfoRes, err error) {
err = g.Try(ctx, func(ctx context.Context) {
err = dao.ConstructionDetails.Ctx(ctx).WithAll().Where(dao.ConstructionDetails.Columns().Id, id).Scan(&res)
liberr.ErrIsNil(ctx, err, "获取信息失败")
})
return
}
func (s *sConstructionDetails) Add(ctx context.Context, req *system.ConstructionDetailsAddReq) (err error) {
err = g.Try(ctx, func(ctx context.Context) {
_, err = dao.ConstructionDetails.Ctx(ctx).Insert(do.ConstructionDetails{
Name: req.Name,
Types: req.Types,
Total: req.Total,
ConstructionId: req.ConstructionId,
Remark: req.Remark,
IsPercentage: req.IsPercentage,
StartTime: req.StartTime,
EndTime: req.EndTime,
Completed: req.Completed,
Selectable: req.Selectable,
Overall: req.Overall,
CreatedBy: systemService.Context().GetUserId(ctx),
})
liberr.ErrIsNil(ctx, err, "添加失败")
})
return
}
func (s *sConstructionDetails) Edit(ctx context.Context, req *system.ConstructionDetailsEditReq) (err error) {
err = g.Try(ctx, func(ctx context.Context) {
_, err = dao.ConstructionDetails.Ctx(ctx).WherePri(req.Id).Update(do.ConstructionDetails{
Name: req.Name,
Types: req.Types,
Total: req.Total,
ConstructionId: req.ConstructionId,
Remark: req.Remark,
IsPercentage: req.IsPercentage,
StartTime: req.StartTime,
EndTime: req.EndTime,
Completed: req.Completed,
Selectable: req.Selectable,
Overall: req.Overall,
UpdatedBy: systemService.Context().GetUserId(ctx),
})
liberr.ErrIsNil(ctx, err, "修改失败")
})
return
}
func (s *sConstructionDetails) Delete(ctx context.Context, ids []uint64) (err error) {
err = g.Try(ctx, func(ctx context.Context) {
_, err = dao.ConstructionDetails.Ctx(ctx).Delete(dao.ConstructionDetails.Columns().Id+" in (?)", ids)
liberr.ErrIsNil(ctx, err, "删除失败")
})
return
}