初始
This commit is contained in:
48
api/app/visual/req.go
Normal file
48
api/app/visual/req.go
Normal file
@ -0,0 +1,48 @@
|
||||
package visual
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// 新增形象进度
|
||||
type CreateVisualProgressReq struct {
|
||||
g.Meta `path:"/visual/create" method:"post" tags:"APP(形象进度相关)" summary:"新增形象进度"`
|
||||
ProjectID int64 `json:"projectId" v:"required" dc:"项目ID"`
|
||||
ReporterID int64 `json:"reporterId" v:"required" dc:"上报人ID"`
|
||||
ReportTime string `json:"reportTime" v:"required" dc:"上报时间"`
|
||||
Title string `json:"title" v:"required" dc:"形象标题"`
|
||||
ProgressDesc string `json:"progressDesc" v:"required" dc:"进度描述"`
|
||||
AttachmentURL string `json:"attachmentUrl" dc:"附件URL"`
|
||||
}
|
||||
|
||||
// 根据项目ID查询形象进度列表
|
||||
type ReadVisualProgressReq struct {
|
||||
g.Meta `path:"/visual/list" method:"get" tags:"APP(形象进度相关)" summary:"查询指定项目的形象进度列表"`
|
||||
ProjectID int64 `json:"projectId" v:"required" dc:"项目ID"`
|
||||
Page int64 `json:"page" dc:"请求的页码" v:"required"`
|
||||
PageSize int64 `json:"pageSize" dc:"每页显示的条目数" v:"required"`
|
||||
Title string `json:"title" dc:"模糊搜索字段"`
|
||||
}
|
||||
|
||||
// 更新形象进度
|
||||
type UpdateVisualProgressReq struct {
|
||||
g.Meta `path:"/visual/update" method:"post" tags:"APP(形象进度相关)" summary:"更新项目进度"`
|
||||
ID int64 `json:"id" v:"required" dc:"记录ID"`
|
||||
ProjectID int64 `json:"projectId" dc:"项目ID"`
|
||||
ReporterID int64 `json:"reporterId" dc:"上报人ID"`
|
||||
Title string `json:"title" dc:"形象标题"`
|
||||
ProgressDesc string `json:"progressDesc" dc:"进度描述"`
|
||||
AttachmentURL string `json:"attachmentUrl" dc:"附件URL"`
|
||||
}
|
||||
|
||||
// 删除形象进度
|
||||
type DeleteVisualProgressReq struct {
|
||||
g.Meta `path:"/visual/delete" method:"delete" tags:"APP(形象进度相关)" summary:"删除项目进度"`
|
||||
ID int64 `json:"id" v:"required" dc:"形象进度ID"`
|
||||
}
|
||||
|
||||
// 根据ID查询形象进度详情
|
||||
type GetVisualProgressDetailReq struct {
|
||||
g.Meta `path:"/visual/detail" method:"get" tags:"APP(形象进度相关)" summary:"根据形象进度ID查询详情"`
|
||||
ID int64 `json:"id" v:"required" dc:"形象进度ID"`
|
||||
}
|
36
api/app/visual/res.go
Normal file
36
api/app/visual/res.go
Normal file
@ -0,0 +1,36 @@
|
||||
package visual
|
||||
|
||||
// 新增形象进度
|
||||
type CreateVisualProgressRes struct{}
|
||||
|
||||
// 形象进度列表
|
||||
type ReadVisualProgressRes struct {
|
||||
ProgressList []VisualProgress `json:"progressList"`
|
||||
Total int64 `json:"total"`
|
||||
}
|
||||
type VisualProgress struct {
|
||||
Id int64 `json:"id" dc:"主键"`
|
||||
ProjectID int64 `json:"projectId" dc:"项目ID"`
|
||||
ProjectName string `json:"projectName" dc:"项目名称"`
|
||||
ReporterID int64 `json:"reporterId" dc:"上报人ID"`
|
||||
ReporterName string `json:"reporterName" dc:"上报人名字"`
|
||||
ReportTime string `json:"reportTime" dc:"上报时间"`
|
||||
Title string `json:"title" dc:"形象标题"`
|
||||
ProgressDesc string `json:"progressDesc" dc:"进度描述"`
|
||||
AttachmentURL string `json:"attachmentUrl" dc:"附件URL"`
|
||||
}
|
||||
|
||||
// 更新形象进度
|
||||
type UpdateVisualProgressRes struct{}
|
||||
|
||||
// 删除形象进度
|
||||
type DeleteVisualProgressRes struct{}
|
||||
|
||||
// 根据ID查询形象进度详情
|
||||
type GetVisualProgressDetailRes struct {
|
||||
Detail VisualProgressDetail `json:"visualProgressDetail"`
|
||||
}
|
||||
|
||||
type VisualProgressDetail struct {
|
||||
VisualProgress
|
||||
}
|
13
api/app/visual/router.go
Normal file
13
api/app/visual/router.go
Normal file
@ -0,0 +1,13 @@
|
||||
package visual
|
||||
|
||||
import "github.com/gogf/gf/v2/net/ghttp"
|
||||
|
||||
// 形象进度API
|
||||
func InitAppProjectAPI(group *ghttp.RouterGroup) {
|
||||
group.Middleware(ghttp.MiddlewareCORS)
|
||||
group.Group("/visual", func(group *ghttp.RouterGroup) {
|
||||
group.Group("/api/v1", func(group *ghttp.RouterGroup) {
|
||||
group.Bind(new(Visual))
|
||||
})
|
||||
})
|
||||
}
|
96
api/app/visual/service.go
Normal file
96
api/app/visual/service.go
Normal file
@ -0,0 +1,96 @@
|
||||
package visual
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// 新增形象进度
|
||||
func (v Visual) CreateVisualProgress(ctx context.Context, req *CreateVisualProgressReq) (res *CreateVisualProgressRes, err error) {
|
||||
res = &CreateVisualProgressRes{}
|
||||
_, err = g.Model("visual_progress").Ctx(ctx).Data(g.Map{
|
||||
"project_id": req.ProjectID,
|
||||
"reporter_id": req.ReporterID,
|
||||
"report_time": req.ReportTime,
|
||||
"title": req.Title,
|
||||
"progress_desc": req.ProgressDesc,
|
||||
"attachment_url": req.AttachmentURL,
|
||||
}).Insert()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// 形象进度列表
|
||||
func (v Visual) GetVisualProgress(ctx context.Context, req *ReadVisualProgressReq) (res *ReadVisualProgressRes, err error) {
|
||||
res = &ReadVisualProgressRes{}
|
||||
offset := (req.Page - 1) * req.PageSize
|
||||
count, err := g.Model("visual_progress").Ctx(ctx).Count()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = g.Model("visual_progress").Ctx(ctx).
|
||||
Fields("sys_project.id, sys_project.project_name, user.user_nickname AS reporterName, visual_progress.*").
|
||||
// 连表查询项目ID、项目名称
|
||||
LeftJoin("sys_project on visual_progress.project_id = sys_project.id").
|
||||
LeftJoin("sys_user AS user on user.id = visual_progress.reporter_id").
|
||||
Where("visual_progress.project_id = ?", req.ProjectID).
|
||||
Where("visual_progress.title LIKE ?", "%"+req.Title+"%").
|
||||
Offset(int(offset)).Limit(int(req.PageSize)).
|
||||
Order("visual_progress.report_time DESC").
|
||||
Scan(&res.ProgressList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res.Total = int64(count)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// 更新形象进度
|
||||
func (v Visual) UpdateVisualProgress(ctx context.Context, req *UpdateVisualProgressReq) (res *UpdateVisualProgressRes, err error) {
|
||||
res = &UpdateVisualProgressRes{}
|
||||
|
||||
_, err = g.Model("visual_progress").Ctx(ctx).Data(g.Map{
|
||||
"project_id": req.ProjectID,
|
||||
"reporter_id": req.ReporterID,
|
||||
"title": req.Title,
|
||||
"progress_desc": req.ProgressDesc,
|
||||
"attachment_url": req.AttachmentURL,
|
||||
}).Where("id", req.ID).Update()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// 删除形象进度
|
||||
func (v Visual) DeleteVisualProgress(ctx context.Context, req *DeleteVisualProgressReq) (res *DeleteVisualProgressRes, err error) {
|
||||
res = &DeleteVisualProgressRes{}
|
||||
// 删除之前调用一个方法,获取当前登录用户的ID,如果是自己才可以删除
|
||||
_, err = g.Model("visual_progress").Ctx(ctx).Where("id", req.ID).Delete()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// 根据ID查询形象进度详情
|
||||
func (v Visual) GetVisualProgressDetail(ctx context.Context, req *GetVisualProgressDetailReq) (res *GetVisualProgressDetailRes, err error) {
|
||||
res = &GetVisualProgressDetailRes{}
|
||||
// 查询项目基本信息
|
||||
err = g.Model("visual_progress").Ctx(ctx).
|
||||
Fields("sys_project.id, sys_project.project_name, user.user_nickname AS reporterName, visual_progress.*").
|
||||
// 连表查询项目ID、项目名称
|
||||
InnerJoin("sys_project on visual_progress.project_id = sys_project.id").
|
||||
// 连表查询上报人名字(暂未确定是哪张用户表,需要联查)
|
||||
InnerJoin("sys_user AS user on user.id = visual_progress.reporter_id").
|
||||
Where("visual_progress.id = ?", req.ID).
|
||||
Scan(&res.Detail)
|
||||
// 查询备注列表信息
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res, nil
|
||||
}
|
4
api/app/visual/visual.go
Normal file
4
api/app/visual/visual.go
Normal file
@ -0,0 +1,4 @@
|
||||
package visual
|
||||
|
||||
type Visual struct {
|
||||
}
|
Reference in New Issue
Block a user