初始
This commit is contained in:
		
							
								
								
									
										219
									
								
								internal/app/system/logic/qianqiPingchang/qianqi_pingchang.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										219
									
								
								internal/app/system/logic/qianqiPingchang/qianqi_pingchang.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,219 @@ | ||||
| // ========================================================================== | ||||
| // GFast自动生成logic操作代码。 | ||||
| // 生成日期:2023-08-08 10:08:24 | ||||
| // 生成路径: internal/app/system/logic/qianqi_pingchang.go | ||||
| // 生成人:gfast | ||||
| // desc:平场数据 | ||||
| // company:云南奇讯科技有限公司 | ||||
| // ========================================================================== | ||||
|  | ||||
| package logic | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"github.com/gogf/gf/v2/frame/g" | ||||
| 	"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/service" | ||||
| 	"github.com/tiger1103/gfast/v3/library/liberr" | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| 	service.RegisterQianqiPingchang(New()) | ||||
| } | ||||
|  | ||||
| func New() *sQianqiPingchang { | ||||
| 	return &sQianqiPingchang{} | ||||
| } | ||||
|  | ||||
| type sQianqiPingchang struct{} | ||||
|  | ||||
| //func (s *sQianqiPingchang) List(ctx context.Context, req *system.QianqiPingchangSearchReq) (listRes *system.QianqiPingchangSearchRes, err error) { | ||||
| //	listRes = new(system.QianqiPingchangSearchRes) | ||||
| //	err = g.Try(ctx, func(ctx context.Context) { | ||||
| //		m := dao.QianqiPingchang.Ctx(ctx).WithAll() | ||||
| //		if req.Id != "" { | ||||
| //			m = m.Where(dao.QianqiPingchang.Columns().Id+" = ?", req.Id) | ||||
| //		} | ||||
| //		if req.CreateAt != "" { | ||||
| //			m = m.Where(dao.QianqiPingchang.Columns().CreateAt+" = ?", gconv.Time(req.CreateAt)) | ||||
| //		} | ||||
| //		if req.UpdateAt != "" { | ||||
| //			m = m.Where(dao.QianqiPingchang.Columns().UpdateAt+" = ?", gconv.Time(req.UpdateAt)) | ||||
| //		} | ||||
| //		if req.DeleteAt != "" { | ||||
| //			m = m.Where(dao.QianqiPingchang.Columns().DeleteAt+" = ?", gconv.Time(req.DeleteAt)) | ||||
| //		} | ||||
| //		if req.ProjectId != "" { | ||||
| //			m = m.Where(dao.QianqiPingchang.Columns().ProjectId+" = ?", req.ProjectId) | ||||
| //		} | ||||
| //		if req.PcId != "" { | ||||
| //			m = m.Where(dao.QianqiPingchang.Columns().PcId+" = ?", req.PcId) | ||||
| //		} | ||||
| //		if req.PcName != "" { | ||||
| //			m = m.Where(dao.QianqiPingchang.Columns().PcName+" like ?", "%"+req.PcName+"%") | ||||
| //		} | ||||
| //		if req.Range != "" { | ||||
| //			m = m.Where(dao.QianqiPingchang.Columns().Range+" = ?", req.Range) | ||||
| //		} | ||||
| //		if req.Points != "" { | ||||
| //			m = m.Where(dao.QianqiPingchang.Columns().Points+" = ?", req.Points) | ||||
| //		} | ||||
| //		if req.SmoothPoints != "" { | ||||
| //			m = m.Where(dao.QianqiPingchang.Columns().SmoothPoints+" = ?", req.SmoothPoints) | ||||
| //		} | ||||
| //		if req.Shp != "" { | ||||
| //			m = m.Where(dao.QianqiPingchang.Columns().Shp+" = ?", req.Shp) | ||||
| //		} | ||||
| //		if req.Imported != "" { | ||||
| //			m = m.Where(dao.QianqiPingchang.Columns().Imported+" = ?", gconv.Int(req.Imported)) | ||||
| //		} | ||||
| //		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.QianqiPingchangInfoRes | ||||
| //		err = m.Fields(system.QianqiPingchangSearchRes{}).Page(req.PageNum, req.PageSize).Order(order).Scan(&res) | ||||
| //		liberr.ErrIsNil(ctx, err, "获取数据失败") | ||||
| //		listRes.List = make([]*model.QianqiPingchangListRes, len(res)) | ||||
| //		for k, v := range res { | ||||
| //			listRes.List[k] = &model.QianqiPingchangListRes{ | ||||
| //				Id:           v.Id, | ||||
| //				CreateAt:     v.CreateAt, | ||||
| //				UpdateAt:     v.UpdateAt, | ||||
| //				DeleteAt:     v.DeleteAt, | ||||
| //				ProjectId:    v.ProjectId, | ||||
| //				PcId:         v.PcId, | ||||
| //				PcName:       v.PcName, | ||||
| //				GridWidth:    v.GridWidth, | ||||
| //				Progress:     v.Progress, | ||||
| //				Range:        v.Range, | ||||
| //				Points:       v.Points, | ||||
| //				SmoothPoints: v.SmoothPoints, | ||||
| //				Shp:          v.Shp, | ||||
| //				Area:         v.Area, | ||||
| //				Cut:          v.Cut, | ||||
| //				Fill:         v.Fill, | ||||
| //				Total:        v.Total, | ||||
| //				Imported:     v.Imported, | ||||
| //			} | ||||
| //		} | ||||
| //	}) | ||||
| //	return | ||||
| //} | ||||
|  | ||||
| func (s *sQianqiPingchang) GetById(ctx context.Context, id uint64) (res *model.QianqiPingchangInfoRes, err error) { | ||||
| 	err = g.Try(ctx, func(ctx context.Context) { | ||||
| 		err = dao.QianqiPingchang.Ctx(ctx).WithAll().Where(dao.QianqiPingchang.Columns().Id, id).Scan(&res) | ||||
| 		liberr.ErrIsNil(ctx, err, "获取信息失败") | ||||
| 	}) | ||||
| 	return | ||||
| } | ||||
|  | ||||
| //func (s *sQianqiPingchang) Add(ctx context.Context, req *system.QianqiPingchangAddReq) (err error) { | ||||
| //	/*	err = g.Try(ctx, func(ctx context.Context) { | ||||
| //		var FilePath = "" | ||||
| //		res, e := service.SysProject().GetByProjectId(ctx, req.ProjectId) | ||||
| //		if e != nil { | ||||
| //			liberr.ErrIsNil(ctx, e) | ||||
| //			return | ||||
| //		} | ||||
| //		if res == nil { | ||||
| //			liberr.ErrIsNil(ctx, errors.New("项目不存在")) | ||||
| //			return | ||||
| //		} | ||||
| //		file := req.File | ||||
| //		for i := range file { | ||||
| //			str, err := coryCommon.UploadFile(ctx, file[i], coryCommon.LargeFileShp) | ||||
| //			if err != nil { | ||||
| //				liberr.ErrIsNil(ctx, err, "上传失败!") | ||||
| //			} | ||||
| //			arr := strings.Split(str, ".") | ||||
| //			arr[len(arr)-1] = "shp" | ||||
| //			FilePath = strings.Join(arr, ".") | ||||
| //			//FilePath = strings.Join(split[:len(split)-1], "/") //strings.Replace(, "/resource/public", "/file", -1) | ||||
| //			//sourceId, _ = gmd5.EncryptString(FilePath) | ||||
| //		} | ||||
| //		//需要读取方阵里面的信息 | ||||
| //		err1, s2 := shp.ReadShp(FilePath) | ||||
| //		if err1 != nil { | ||||
| //			liberr.ErrIsNil(ctx, err1) | ||||
| //		} | ||||
| //		CreateBy := ct.New().GetLoginUser(ctx).Id | ||||
| //		var arr []do.QianqiPingchang | ||||
| //		for _, p := range s2.Polylines { | ||||
| //			//将方阵的名称  作为方阵的id | ||||
| //			//sourceId := gmd5.MustEncryptString(p.Name) | ||||
| //						nibianqi := do.QianqiPingchang{} | ||||
| //						nibianqi.ProjectId = req.ProjectId | ||||
| //						nibianqi.SourceId = gmd5.MustEncryptString(req.ProjectId + p.Name) | ||||
| //						nibianqi.Name = p.Name | ||||
| //						nibianqi.ModelId = "41b366a9bae250098716da675d3ae26d" | ||||
| //						nibianqi.CreateBy = CreateBy | ||||
| //						detail := shp.Detail{Position: p.Positions[0]} | ||||
| //						marshal, err := json.Marshal(detail) | ||||
| //						if err != nil { | ||||
| //							continue | ||||
| //						} | ||||
| //						nibianqi.Detail = string(marshal) | ||||
| // | ||||
| //						//time.Sleep(time.Millisecond) | ||||
| // | ||||
| //						//判断是否已经存在了该方阵,存在了就不再添加 | ||||
| //						count, _ := dao.QianqiNibianqi.Ctx(ctx).Where(dao.QianqiNibianqi.Columns().SourceId, nibianqi.SourceId).Count() | ||||
| //						if count == 0 { | ||||
| //							arr = append(arr, nibianqi) | ||||
| // | ||||
| //						} | ||||
| //		} | ||||
| //			if len(arr) > 0 { | ||||
| //				_, err = dao.QianqiNibianqi.Ctx(ctx).Insert(&arr) | ||||
| //				liberr.ErrIsNil(ctx, err, "添加失败") | ||||
| //			} | ||||
| // | ||||
| //	}) */ | ||||
| //	return | ||||
| //} | ||||
| // | ||||
| //func (s *sQianqiPingchang) Edit(ctx context.Context, req *system.QianqiPingchangEditReq) (err error) { | ||||
| //	err = g.Try(ctx, func(ctx context.Context) { | ||||
| //		_, err = dao.QianqiPingchang.Ctx(ctx).WherePri(req.Id).Update(do.QianqiPingchang{ | ||||
| //			CreateAt:     req.CreateAt, | ||||
| //			UpdateAt:     req.UpdateAt, | ||||
| //			DeleteAt:     req.DeleteAt, | ||||
| //			ProjectId:    req.ProjectId, | ||||
| //			PcId:         req.PcId, | ||||
| //			PcName:       req.PcName, | ||||
| //			GridWidth:    req.GridWidth, | ||||
| //			Progress:     req.Progress, | ||||
| //			Range:        req.Range, | ||||
| //			Points:       req.Points, | ||||
| //			SmoothPoints: req.SmoothPoints, | ||||
| //			Shp:          req.Shp, | ||||
| //			Area:         req.Area, | ||||
| //			Cut:          req.Cut, | ||||
| //			Fill:         req.Fill, | ||||
| //			Total:        req.Total, | ||||
| //			Imported:     req.Imported, | ||||
| //		}) | ||||
| //		liberr.ErrIsNil(ctx, err, "修改失败") | ||||
| //	}) | ||||
| //	return | ||||
| //} | ||||
|  | ||||
| func (s *sQianqiPingchang) Delete(ctx context.Context, ids []uint64) (err error) { | ||||
| 	err = g.Try(ctx, func(ctx context.Context) { | ||||
| 		_, err = dao.QianqiPingchang.Ctx(ctx).Delete(dao.QianqiPingchang.Columns().Id+" in (?)", ids) | ||||
| 		liberr.ErrIsNil(ctx, err, "删除失败") | ||||
| 	}) | ||||
| 	return | ||||
| } | ||||
		Reference in New Issue
	
	Block a user