Skip to content

Commit

Permalink
v3.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
cookieY committed Jul 3, 2023
1 parent 5de68e4 commit 371702c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 12 deletions.
29 changes: 20 additions & 9 deletions src/handler/fetch/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package fetch
import (
"Yearning-go/src/engine"
"Yearning-go/src/handler/common"
tpl2 "Yearning-go/src/handler/manage/tpl"
"Yearning-go/src/handler/manage/tpl"
"Yearning-go/src/lib"
"Yearning-go/src/model"
"encoding/json"
Expand Down Expand Up @@ -103,19 +103,30 @@ func FetchSource(c yee.Context) (err error) {
return c.JSON(http.StatusOK, common.SuccessPayload(source))
}

type StepInfo struct {
tpl.Tpl
model.CoreWorkflowDetail
}

func FetchAuditSteps(c yee.Context) (err error) {
u := c.QueryParam("source_id")
unescape, _ := url.QueryUnescape(u)
var s model.CoreDataSource
var tpl model.CoreWorkflowTpl
var whoIsAuditor []tpl2.Tpl
model.DB().Model(model.CoreDataSource{}).Where("source_id = ?", unescape).First(&s)
if err := model.DB().Model(model.CoreWorkflowTpl{}).Where("id =?", s.FlowID).First(&tpl).Error; errors.Is(err, gorm.ErrRecordNotFound) {
return c.JSON(http.StatusOK, common.ERR_COMMON_MESSAGE(errors.New("数据源没有添加流程!无法提交工单")))
whoIsAuditor, err := tpl.OrderRelation(unescape)
if err != nil {
return c.JSON(http.StatusOK, common.ERR_COMMON_MESSAGE(err))
}
workId := c.QueryParam("work_id")
var s []model.CoreWorkflowDetail
model.DB().Where("work_id = ?", workId).Find(&s)
var steps []StepInfo
for _, v := range whoIsAuditor {
steps = append(steps, StepInfo{Tpl: v})
}
for i, v := range s {
steps[i].CoreWorkflowDetail = v
}
_ = json.Unmarshal(tpl.Steps, &whoIsAuditor)

return c.JSON(http.StatusOK, common.SuccessPayload(whoIsAuditor))
return c.JSON(http.StatusOK, common.SuccessPayload(steps))

}

Expand Down
1 change: 1 addition & 0 deletions src/handler/manage/db/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func SuperEditSource(source *model.CoreDataSource) common.Resp {
"cert": source.Cert,
"key_file": source.KeyFile,
})
model.DB().Model(model.CoreQueryOrder{}).Where("status =? and source_id =?", 1, source.SourceId).Updates(&model.CoreQueryOrder{Assigned: source.Principal})
var k []model.CoreRoleGroup
model.DB().Find(&k)
for i := range k {
Expand Down
20 changes: 20 additions & 0 deletions src/handler/manage/tpl/impl.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package tpl

import (
"Yearning-go/src/model"
"encoding/json"
"errors"
"gorm.io/gorm"
)

type Tpl struct {
Desc string `json:"desc"`
Auditor []string `json:"auditor"`
Expand All @@ -17,3 +24,16 @@ type ReqTpl struct {
Source string `json:"source"`
Page int ` json:"page"`
}

func OrderRelation(source_id string) ([]Tpl, error) {
var s model.CoreDataSource
var tpl model.CoreWorkflowTpl
var whoIsAuditor []Tpl
model.DB().Model(model.CoreDataSource{}).Where("source_id = ?", source_id).First(&s)
if err := model.DB().Model(model.CoreWorkflowTpl{}).Where("id =?", s.FlowID).First(&tpl).Error; errors.Is(err, gorm.ErrRecordNotFound) {
return nil, errors.New("数据源没有添加流程!无法提交工单")
}
_ = json.Unmarshal(tpl.Steps, &whoIsAuditor)

return whoIsAuditor, nil
}
10 changes: 7 additions & 3 deletions src/handler/order/query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,24 @@ func QueryHandlerSets(c yee.Context) (err error) {
c.Logger().Error(err.Error())
return c.JSON(http.StatusOK, common.ERR_REQ_BIND)
}
found := model.DB().Where("work_id=? AND status=?", u.WorkId, 1).Error
token := new(lib.Token).JwtParse(c)
empty := new(model.CoreQueryOrder)
found := model.DB().Where("work_id=? AND status=? AND assigned = ?", u.WorkId, 1, token.Username).Find(empty).Error
switch c.Params("tp") {
case "agreed":
if !errors.Is(found, gorm.ErrRecordNotFound) {
model.DB().Model(model.CoreQueryOrder{}).Where("work_id =?", u.WorkId).Updates(&model.CoreQueryOrder{Status: 2, ApprovalTime: time.Now().Format("2006-01-02 15:04")})
lib.MessagePush(u.WorkId, 8, "")
return c.JSON(http.StatusOK, common.SuccessPayLoadToMessage(common.ORDER_IS_AGREE))
}
return c.JSON(http.StatusOK, common.SuccessPayLoadToMessage(common.ORDER_IS_AGREE))
return c.JSON(http.StatusOK, common.ERR_REQ_FAKE)
case "reject":
if !errors.Is(found, gorm.ErrRecordNotFound) {
model.DB().Model(model.CoreQueryOrder{}).Where("work_id =?", u.WorkId).Updates(&model.CoreQueryOrder{Status: 4})
lib.MessagePush(u.WorkId, 9, "")
return c.JSON(http.StatusOK, common.SuccessPayLoadToMessage(common.ORDER_IS_REJECT))
}
return c.JSON(http.StatusOK, common.SuccessPayLoadToMessage(common.ORDER_IS_REJECT))
return c.JSON(http.StatusOK, common.ERR_REQ_FAKE)
case "undo":
t := new(lib.Token)
t.JwtParse(c)
Expand Down

0 comments on commit 371702c

Please sign in to comment.