初始
This commit is contained in:
4
api/app/process/process.go
Normal file
4
api/app/process/process.go
Normal file
@ -0,0 +1,4 @@
|
||||
package process
|
||||
|
||||
type ProcessApi struct {
|
||||
}
|
47
api/app/process/req.go
Normal file
47
api/app/process/req.go
Normal file
@ -0,0 +1,47 @@
|
||||
package process
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// 新增进度
|
||||
type CreateProcessReq struct {
|
||||
g.Meta `path:"/process/create" method:"post" tags:"APP(里程碑进度上报)" summary:"新增里程碑进度"`
|
||||
Stage string `json:"stage" v:"required" dc:"上传阶段名称"`
|
||||
ProjectId int64 `json:"projectId" v:"required#该用户暂未绑定项目" dc:"项目ID"`
|
||||
Percentage int `json:"percentage" dc:"完成情况(1已完成 0未完成)"`
|
||||
Notes string `json:"notes" dc:"备注"`
|
||||
CompleteTime gtime.Time `json:"completeTime" dc:"完成时间"`
|
||||
}
|
||||
|
||||
// 获取进度列表
|
||||
type ProcessListReq struct {
|
||||
g.Meta `path:"/process/list" method:"get" tags:"APP(里程碑进度上报)" summary:"获取里程碑进度列表"`
|
||||
ProjectId int64 `json:"projectId" v:"required" dc:"项目ID"`
|
||||
Page int `json:"page" v:"required" dc:"页码"`
|
||||
PageSize int `json:"pageSize" v:"required" dc:"每页大小"`
|
||||
}
|
||||
|
||||
// 更新进度信息
|
||||
type UpdateProcessReq struct {
|
||||
g.Meta `path:"/process/update" method:"put" tags:"APP(里程碑进度上报)" summary:"更新里程碑进度信息"`
|
||||
ProcessID int64 `json:"processId" v:"required" dc:"进度ID"`
|
||||
Stage string `json:"stage" v:"required" dc:"上传阶段名称"`
|
||||
ProjectId int64 `json:"projectId" v:"required" dc:"项目ID"`
|
||||
Percentage int `json:"percentage" dc:"完成情况(1已完成 0未完成)"`
|
||||
Notes string `json:"notes" dc:"备注"`
|
||||
CompleteTime gtime.Time `json:"completeTime" dc:"完成时间"`
|
||||
}
|
||||
|
||||
// 删除进度
|
||||
type DeleteProcessReq struct {
|
||||
g.Meta `path:"/process/delete" method:"delete" tags:"APP(里程碑进度上报)" summary:"删除里程碑进度"`
|
||||
ProcessID int64 `json:"processId" v:"required" dc:"进度ID"`
|
||||
}
|
||||
|
||||
// 获取详情
|
||||
type ProcessDetailReq struct {
|
||||
g.Meta `path:"/process/detail" method:"delete" tags:"APP(里程碑进度上报)" summary:"获取里程碑进度详情"`
|
||||
ProcessID int64 `json:"processId" v:"required" dc:"进度ID"`
|
||||
}
|
56
api/app/process/res.go
Normal file
56
api/app/process/res.go
Normal file
@ -0,0 +1,56 @@
|
||||
package process
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 新增进度
|
||||
type CreateProcessRes struct {
|
||||
}
|
||||
|
||||
// 获取列表
|
||||
type ProcessListRes struct {
|
||||
g.Meta `mime:"application/json"`
|
||||
Processes []ProcessVo `json:"processes"`
|
||||
}
|
||||
|
||||
// Process 表的结构体定义
|
||||
type Process struct {
|
||||
g.Meta `mime:"application/json"`
|
||||
ProcessID int64 `json:"processId" dc:"主键ID"`
|
||||
ProjectId int64 `json:"projectId" dc:"项目ID"`
|
||||
Stage string `json:"stage" dc:"阶段"`
|
||||
Percentage int `json:"percentage" dc:"进度"`
|
||||
Notes string `json:"notes" dc:"备注"`
|
||||
CreatedAt time.Time `json:"createdAt" dc:"创建时间"`
|
||||
UpdatedAt time.Time `json:"updatedAt" dc:"更新时间"`
|
||||
CompleteTime gtime.Time `json:"completeTime" dc:"完成时间"`
|
||||
CreatedBy int `json:"createdBy" dc:"录入人"`
|
||||
}
|
||||
|
||||
// Process 表的结构体定义
|
||||
type ProcessVo struct {
|
||||
g.Meta `mime:"application/json"`
|
||||
ProcessID int64 `json:"processId" dc:"主键ID"`
|
||||
ProjectId int64 `json:"projectId" dc:"项目ID"`
|
||||
Stage string `json:"stage" dc:"阶段"`
|
||||
Percentage int `json:"percentage" dc:"进度"`
|
||||
Notes string `json:"notes" dc:"备注"`
|
||||
CreatedAt time.Time `json:"createdAt" dc:"创建时间"`
|
||||
UpdatedAt time.Time `json:"updatedAt" dc:"更新时间"`
|
||||
CompleteTime gtime.Time `json:"completeTime" dc:"完成时间"`
|
||||
CreatedBy int `json:"createdBy" dc:"录入人ID"`
|
||||
CreatedByName string `json:"createdByName" dc:"录入人姓名"`
|
||||
}
|
||||
|
||||
type UpdateProcessRes struct {
|
||||
}
|
||||
|
||||
type DeleteProcessRes struct {
|
||||
}
|
||||
|
||||
type ProcessDetailRes struct {
|
||||
ProcessInfo ProcessVo `json:"processInfo"`
|
||||
}
|
74
api/app/process/service.go
Normal file
74
api/app/process/service.go
Normal file
@ -0,0 +1,74 @@
|
||||
package process
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
ct "github.com/tiger1103/gfast/v3/internal/app/system/logic/context"
|
||||
)
|
||||
|
||||
func (p ProcessApi) CreateProcess(ctx context.Context, req *CreateProcessReq) (res *CreateProcessRes, err error) {
|
||||
res = new(CreateProcessRes)
|
||||
// 获取当前登陆用户的ID
|
||||
userID := ct.New().GetUserId(ctx)
|
||||
param := g.Map{
|
||||
"stage": req.Stage,
|
||||
"project_id": req.ProjectId,
|
||||
"percentage": req.Percentage,
|
||||
"complete_time": req.CompleteTime,
|
||||
"notes": req.Notes,
|
||||
"created_by": userID,
|
||||
}
|
||||
// 插入数据
|
||||
_, err = g.Model("process").Ctx(ctx).Insert(param)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// 根据项目列表查询里程碑数据
|
||||
func (p ProcessApi) GetProcessList(ctx context.Context, req *ProcessListReq) (res *ProcessListRes, err error) {
|
||||
res = new(ProcessListRes)
|
||||
err = g.Model("process").Ctx(ctx).Fields("process.*,sys_user.user_nickname AS createdByName").
|
||||
LeftJoin("sys_user on sys_user.id = process.created_by").
|
||||
Where("project_id = ?", req.ProjectId).Page(req.Page, req.PageSize).Scan(&res.Processes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (p ProcessApi) UpdateProcess(ctx context.Context, req *UpdateProcessReq) (res *UpdateProcessRes, err error) {
|
||||
res = new(UpdateProcessRes)
|
||||
_, err = g.Model("process").Ctx(ctx).Data(g.Map{
|
||||
"stage": req.Stage,
|
||||
"project_id": req.ProjectId,
|
||||
"percentage": req.Percentage,
|
||||
"complete_time": req.CompleteTime,
|
||||
"notes": req.Notes,
|
||||
}).Where("process_id = ?", req.ProcessID).Update()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (p ProcessApi) DeleteProcess(ctx context.Context, req *DeleteProcessReq) (res *DeleteProcessRes, err error) {
|
||||
res = new(DeleteProcessRes)
|
||||
_, err = g.Model("process").Ctx(ctx).Where("process_id", req.ProcessID).Delete()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (p ProcessApi) ProcessDetail(ctx context.Context, req *ProcessDetailReq) (res *ProcessDetailRes, err error) {
|
||||
res = new(ProcessDetailRes)
|
||||
g.Model("process").Ctx(ctx).Fields("process.*,sys_user.user_nickname AS createdByName").
|
||||
InnerJoin("sys_user on sys_user.id = process.created_by").
|
||||
Scan(&res.ProcessInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res, nil
|
||||
}
|
Reference in New Issue
Block a user