初始
This commit is contained in:
167
internal/app/system/logic/documentProject/document_project.go
Normal file
167
internal/app/system/logic/documentProject/document_project.go
Normal file
@ -0,0 +1,167 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成logic操作代码。
|
||||
// 生成日期:2023-09-16 10:32:03
|
||||
// 生成路径: internal/app/system/logic/document_project.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/service"
|
||||
"github.com/tiger1103/gfast/v3/library/liberr"
|
||||
)
|
||||
|
||||
func init() {
|
||||
service.RegisterDocumentProject(New())
|
||||
}
|
||||
|
||||
func New() *sDocumentProject {
|
||||
return &sDocumentProject{}
|
||||
}
|
||||
|
||||
type sDocumentProject struct{}
|
||||
|
||||
//func (s *sDocumentProject) TreeStructureFunc(ctx context.Context, req *system.TreeStructureReq) (res *system.TreeStructureRes, err error) {
|
||||
// res = new(system.TreeStructureRes)
|
||||
// var entity []*model.DocumentProjectListRes
|
||||
// join := dao.DocumentProject.Ctx(ctx)
|
||||
// if req.IdStr != "" {
|
||||
// join = join.Where("pid", req.IdStr)
|
||||
// } else {
|
||||
// join = join.Where("pid", "0")
|
||||
// }
|
||||
// if req.ProjectId != "" {
|
||||
// join = join.Where(dao.DocumentProject.Columns().ProjectId, req.ProjectId)
|
||||
// }
|
||||
// join.Scan(&entity)
|
||||
// res.List = entity
|
||||
// return
|
||||
//}
|
||||
|
||||
//func (s *sDocumentProject) List(ctx context.Context, req *system.DocumentProjectSearchReq) (listRes *system.DocumentProjectSearchRes, err error) {
|
||||
// listRes = new(system.DocumentProjectSearchRes)
|
||||
// err = g.Try(ctx, func(ctx context.Context) {
|
||||
// m := dao.DocumentProject.Ctx(ctx).WithAll()
|
||||
// if req.ProjectId != "" {
|
||||
// m = m.Where(dao.DocumentProject.Columns().ProjectId+" = ?", req.ProjectId)
|
||||
// }
|
||||
// if req.Name != "" {
|
||||
// m = m.Where(dao.DocumentProject.Columns().Name+" like ?", "%"+req.Name+"%")
|
||||
// }
|
||||
// if req.UpdateBy != "" {
|
||||
// m = m.Where(dao.DocumentProject.Columns().UpdateBy+" = ?", req.UpdateBy)
|
||||
// }
|
||||
// if len(req.DateRange) != 0 {
|
||||
// m = m.Where(dao.DocumentProject.Columns().CreatedAt+" >=? AND "+dao.DocumentProject.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.DocumentProjectInfoRes
|
||||
// err = m.Fields(system.DocumentProjectSearchRes{}).Page(req.PageNum, req.PageSize).Order(order).Scan(&res)
|
||||
// liberr.ErrIsNil(ctx, err, "获取数据失败")
|
||||
// listRes.List = make([]*model.DocumentProjectListRes, len(res))
|
||||
// for k, v := range res {
|
||||
// //filePath := ([]*comModel.UpFile)(nil)
|
||||
// //err = gjson.DecodeTo(v.FilePath, &filePath)
|
||||
// //liberr.ErrIsNil(ctx, err)
|
||||
// //a := "https://www.yj-3d.com:8919" + v.FilePath
|
||||
// listRes.List[k] = &model.DocumentProjectListRes{
|
||||
// Id: v.Id,
|
||||
// Pid: v.Pid,
|
||||
// Name: v.Name,
|
||||
// FilePath: v.FilePath,
|
||||
// Type: v.Type,
|
||||
// ProjectId: v.ProjectId,
|
||||
// CreatedAt: v.CreatedAt,
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//func (s *sDocumentProject) GetById(ctx context.Context, id int) (res *model.DocumentProjectInfoRes, err error) {
|
||||
// res = new(model.DocumentProjectInfoRes)
|
||||
// err = g.Try(ctx, func(ctx context.Context) {
|
||||
// err = dao.DocumentProject.Ctx(ctx).WithAll().Where(dao.DocumentProject.Columns().Id, id).Scan(&res)
|
||||
// //json2 := res.FilePath
|
||||
// //if json2 != "" {
|
||||
// // data, _ := coryCommon.PutJson(json2)
|
||||
// // res.FilePath = data
|
||||
// //}
|
||||
// json := res.Json
|
||||
// if json != "" {
|
||||
// data, _ := coryCommon.PutJson(json)
|
||||
// res.Json = data
|
||||
// }
|
||||
// //res.FilePath = "/wx" + res.FilePath
|
||||
//
|
||||
// liberr.ErrIsNil(ctx, err, "获取信息失败")
|
||||
// })
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//func (s *sDocumentProject) Add(ctx context.Context, req *system.DocumentProjectAddReq) (err error) {
|
||||
// err = g.Try(ctx, func(ctx context.Context) {
|
||||
// _, err = dao.DocumentProject.Ctx(ctx).Insert(do.DocumentProject{
|
||||
// IdStr: req.IdStr,
|
||||
// Pid: req.Pid,
|
||||
// Name: req.Name,
|
||||
// Type: req.Type,
|
||||
// Json: req.Json,
|
||||
// ProjectId: req.ProjectId,
|
||||
// })
|
||||
// liberr.ErrIsNil(ctx, err, "添加失败")
|
||||
// })
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//func (s *sDocumentProject) Edit(ctx context.Context, req *system.DocumentProjectEditReq) (err error) {
|
||||
// err = g.Try(ctx, func(ctx context.Context) {
|
||||
// var ey *model.DocumentProjectInfoRes
|
||||
// dao.DocumentProject.Ctx(ctx).WherePri(req.Id).Scan(&ey)
|
||||
// var pathName = ""
|
||||
// if ey != nil {
|
||||
// dir := filepath.Dir(ey.FilePath)
|
||||
// dir = strings.ReplaceAll(dir, "/file", coryCommon.GetCWD()+"/resource/public")
|
||||
// timestamp := time.Now().UnixNano() / int64(time.Millisecond)
|
||||
// sjc := strconv.FormatInt(timestamp, 10)
|
||||
// pathName = dir + "/" + strconv.FormatInt(ey.ProjectId, 10) + strconv.FormatInt(ey.Id, 10) + sjc + ".txt"
|
||||
// flag, err := coryCommon.OutJson([]byte(req.Json), pathName)
|
||||
//
|
||||
// if err != nil || flag == false {
|
||||
// err = errors.New("修改失败")
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
// _, err = dao.DocumentProject.Ctx(ctx).WherePri(req.Id).Update(do.DocumentProject{
|
||||
// Json: pathName,
|
||||
// })
|
||||
// liberr.ErrIsNil(ctx, err, "修改失败")
|
||||
// })
|
||||
// return
|
||||
//}
|
||||
|
||||
func (s *sDocumentProject) Delete(ctx context.Context, ids []int) (err error) {
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
_, err = dao.DocumentProject.Ctx(ctx).Delete(dao.DocumentProject.Columns().Id+" in (?)", ids)
|
||||
liberr.ErrIsNil(ctx, err, "删除失败")
|
||||
})
|
||||
return
|
||||
}
|
Reference in New Issue
Block a user