初始
This commit is contained in:
		| @ -0,0 +1,146 @@ | ||||
| // ========================================================================== | ||||
| // GFast自动生成logic操作代码。 | ||||
| // 生成日期:2023-08-17 10:37:21 | ||||
| // 生成路径: internal/app/system/logic/qianqi_guangfuban_zuchuan.go | ||||
| // 生成人:xyb | ||||
| // desc:组串 | ||||
| // company:云南奇讯科技有限公司 | ||||
| // ========================================================================== | ||||
|  | ||||
| package logic | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"github.com/gogf/gf/v2/frame/g" | ||||
| 	"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.RegisterQianqiGuangfubanZuchuan(New()) | ||||
| } | ||||
|  | ||||
| func New() *sQianqiGuangfubanZuchuan { | ||||
| 	return &sQianqiGuangfubanZuchuan{} | ||||
| } | ||||
|  | ||||
| type sQianqiGuangfubanZuchuan struct{} | ||||
|  | ||||
| func (s *sQianqiGuangfubanZuchuan) List(ctx context.Context, req *system.QianqiGuangfubanZuchuanSearchReq) (listRes *system.QianqiGuangfubanZuchuanSearchRes, err error) { | ||||
| 	listRes = new(system.QianqiGuangfubanZuchuanSearchRes) | ||||
| 	err = g.Try(ctx, func(ctx context.Context) { | ||||
| 		m := dao.QianqiGuangfubanZuchuan.Ctx(ctx).WithAll() | ||||
| 		if req.Id != "" { | ||||
| 			m = m.Where(dao.QianqiGuangfubanZuchuan.Columns().Id+" = ?", req.Id) | ||||
| 		} | ||||
| 		if req.CreateBy != "" { | ||||
| 			m = m.Where(dao.QianqiGuangfubanZuchuan.Columns().CreateBy+" = ?", req.CreateBy) | ||||
| 		} | ||||
| 		if req.UpdateBy != "" { | ||||
| 			m = m.Where(dao.QianqiGuangfubanZuchuan.Columns().UpdateBy+" = ?", req.UpdateBy) | ||||
| 		} | ||||
| 		if len(req.DateRange) != 0 { | ||||
| 			m = m.Where(dao.QianqiGuangfubanZuchuan.Columns().CreatedAt+" >=? AND "+dao.QianqiGuangfubanZuchuan.Columns().CreatedAt+" <=?", req.DateRange[0], req.DateRange[1]) | ||||
| 		} | ||||
| 		if req.SourceType != "" { | ||||
| 			m = m.Where(dao.QianqiGuangfubanZuchuan.Columns().SourceType+" = ?", req.SourceType) | ||||
| 		} | ||||
| 		if req.SourceId != "" { | ||||
| 			m = m.Where(dao.QianqiGuangfubanZuchuan.Columns().SourceId+" = ?", req.SourceId) | ||||
| 		} | ||||
| 		if req.ProjectId != "" { | ||||
| 			m = m.Where(dao.QianqiGuangfubanZuchuan.Columns().ProjectId+" = ?", req.ProjectId) | ||||
| 		} | ||||
| 		if req.ZuchuanId != "" { | ||||
| 			m = m.Where(dao.QianqiGuangfubanZuchuan.Columns().ZuchuanId+" = ?", req.ZuchuanId) | ||||
| 		} | ||||
| 		if req.GuangfubanId != "" { | ||||
| 			m = m.Where(dao.QianqiGuangfubanZuchuan.Columns().GuangfubanId+" = ?", req.GuangfubanId) | ||||
| 		} | ||||
| 		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 := "name asc,id asc" | ||||
| 		if req.OrderBy != "" { | ||||
| 			order = req.OrderBy | ||||
| 		} | ||||
| 		var res []*model.QianqiGuangfubanZuchuanInfoRes | ||||
| 		err = m.Fields(system.QianqiGuangfubanZuchuanSearchRes{}).Page(req.PageNum, req.PageSize).Order(order).Scan(&res) | ||||
| 		liberr.ErrIsNil(ctx, err, "获取数据失败") | ||||
| 		listRes.List = make([]*model.QianqiGuangfubanZuchuanListRes, len(res)) | ||||
| 		for k, v := range res { | ||||
| 			listRes.List[k] = &model.QianqiGuangfubanZuchuanListRes{ | ||||
| 				Id:                 v.Id, | ||||
| 				CreateBy:           v.CreateBy, | ||||
| 				UpdateBy:           v.UpdateBy, | ||||
| 				CreatedAt:          v.CreatedAt, | ||||
| 				SourceType:         v.SourceType, | ||||
| 				SourceId:           v.SourceId, | ||||
| 				ProjectId:          v.ProjectId, | ||||
| 				ZuchuanId:          v.ZuchuanId, | ||||
| 				GuangfubanId:       v.GuangfubanId, | ||||
| 				LinkedGuangfubanId: v.LinkedGuangfubanId, | ||||
| 			} | ||||
| 		} | ||||
| 	}) | ||||
| 	return | ||||
| } | ||||
|  | ||||
| func (s *sQianqiGuangfubanZuchuan) GetById(ctx context.Context, id int) (res *model.QianqiGuangfubanZuchuanInfoRes, err error) { | ||||
| 	err = g.Try(ctx, func(ctx context.Context) { | ||||
| 		err = dao.QianqiGuangfubanZuchuan.Ctx(ctx).WithAll().Where(dao.QianqiGuangfubanZuchuan.Columns().Id, id).Scan(&res) | ||||
| 		liberr.ErrIsNil(ctx, err, "获取信息失败") | ||||
| 	}) | ||||
| 	return | ||||
| } | ||||
|  | ||||
| func (s *sQianqiGuangfubanZuchuan) Add(ctx context.Context, req *system.QianqiGuangfubanZuchuanAddReq) (err error) { | ||||
| 	//err = g.Try(ctx, func(ctx context.Context) { | ||||
| 	//	_, err = dao.QianqiGuangfubanZuchuan.Ctx(ctx).Insert(do.QianqiGuangfubanZuchuan{ | ||||
| 	//		CreateBy:     req.CreateBy, | ||||
| 	//		UpdateBy:     req.UpdateBy, | ||||
| 	//		SourceType:   req.SourceType, | ||||
| 	//		SourceId:     req.SourceId, | ||||
| 	//		ProjectId:    req.ProjectId, | ||||
| 	//		ZuchuanId:    req.ZuchuanId, | ||||
| 	//		GuangfubanId: req.GuangfubanId, | ||||
| 	//	}) | ||||
| 	//	liberr.ErrIsNil(ctx, err, "添加失败") | ||||
| 	//}) | ||||
| 	return | ||||
| } | ||||
|  | ||||
| func (s *sQianqiGuangfubanZuchuan) Edit(ctx context.Context, req *system.QianqiGuangfubanZuchuanEditReq) (err error) { | ||||
| 	err = g.Try(ctx, func(ctx context.Context) { | ||||
| 		_, err = dao.QianqiGuangfubanZuchuan.Ctx(ctx).WherePri(req.Id).Update(do.QianqiGuangfubanZuchuan{ | ||||
| 			CreateBy:     req.CreateBy, | ||||
| 			UpdateBy:     req.UpdateBy, | ||||
| 			SourceType:   req.SourceType, | ||||
| 			SourceId:     req.SourceId, | ||||
| 			ProjectId:    req.ProjectId, | ||||
| 			ZuchuanId:    req.ZuchuanId, | ||||
| 			GuangfubanId: req.GuangfubanId, | ||||
| 		}) | ||||
| 		liberr.ErrIsNil(ctx, err, "修改失败") | ||||
| 	}) | ||||
| 	return | ||||
| } | ||||
|  | ||||
| func (s *sQianqiGuangfubanZuchuan) Delete(ctx context.Context, ids []int) (err error) { | ||||
| 	err = g.Try(ctx, func(ctx context.Context) { | ||||
| 		_, err = dao.QianqiGuangfubanZuchuan.Ctx(ctx).Delete(dao.QianqiGuangfubanZuchuan.Columns().Id+" in (?)", ids) | ||||
| 		liberr.ErrIsNil(ctx, err, "删除失败") | ||||
| 	}) | ||||
| 	return | ||||
| } | ||||
		Reference in New Issue
	
	Block a user