做双端审批流
This commit is contained in:
1 parent
5b4dbb2b46
commit
ffaadc26ae
69 files changed
+6662
-1071
No files matched your search
@@ -463,7 +463,8 @@ func (c *PlatformTenantDomainController) CustomDomainGuide() {
|
||||
|
||||
// Apply POST /platform/domain/tenant/apply body:{tid,sub_domain,main_domain}
|
||||
func (c *PlatformTenantDomainController) Apply() {
|
||||
if _, err := requirePlatform(&c.Controller); err != nil {
|
||||
claims, err := requirePlatform(&c.Controller)
|
||||
if err != nil {
|
||||
jsonErr(&c.Controller, 401, 401, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -551,13 +552,21 @@ func (c *PlatformTenantDomainController) Apply() {
|
||||
jsonErr(&c.Controller, 500, 500, "申请失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
c.Data["json"] = map[string]interface{}{"code": 200, "msg": "申请提交成功,等待审核", "data": map[string]interface{}{"id": uint64(id)}}
|
||||
// 进入平台侧审批流(严格:未配置流程/无有效审批人则提交失败并回滚)
|
||||
if errMsg := submitDomainApprovalChecked(uint64(id), p.Tid, uint64(claims.UserID), claims.Username, full); errMsg != "" {
|
||||
jsonErr(&c.Controller, 400, 400, errMsg)
|
||||
return
|
||||
}
|
||||
c.Data["json"] = map[string]interface{}{"code": 200, "msg": "申请提交成功,等待审批", "data": map[string]interface{}{"id": uint64(id)}}
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
||||
// Audit POST /platform/domain/tenant/audit body:{id,action} action=approve/reject
|
||||
// Audit POST /platform/domain/tenant/audit body:{id,action,comment} action=approve/reject
|
||||
// 引擎驱动:已配置审批流则走多级流转,仅当前待办人可操作;
|
||||
// 未配置流程(无在途实例)则回退到单级直改状态,保证兼容。
|
||||
func (c *PlatformTenantDomainController) Audit() {
|
||||
if _, err := requirePlatform(&c.Controller); err != nil {
|
||||
claims, err := requirePlatform(&c.Controller)
|
||||
if err != nil {
|
||||
jsonErr(&c.Controller, 401, 401, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -567,8 +576,9 @@ func (c *PlatformTenantDomainController) Audit() {
|
||||
return
|
||||
}
|
||||
var p struct {
|
||||
ID uint64 `json:"id"`
|
||||
Action string `json:"action"`
|
||||
ID uint64 `json:"id"`
|
||||
Action string `json:"action"`
|
||||
Comment string `json:"comment"`
|
||||
}
|
||||
if err := json.Unmarshal(raw, &p); err != nil || p.ID == 0 {
|
||||
jsonErr(&c.Controller, 400, 400, "参数错误")
|
||||
@@ -587,25 +597,34 @@ func (c *PlatformTenantDomainController) Audit() {
|
||||
jsonErr(&c.Controller, 400, 400, "该域名已审核过了")
|
||||
return
|
||||
}
|
||||
newStatus := 2
|
||||
msg := "已拒绝"
|
||||
if strings.ToLower(strings.TrimSpace(p.Action)) == "approve" {
|
||||
newStatus = 1
|
||||
msg = "审核通过"
|
||||
pass := strings.ToLower(strings.TrimSpace(p.Action)) == "approve"
|
||||
var bizTid uint64
|
||||
if row.Tid != nil {
|
||||
bizTid = *row.Tid
|
||||
}
|
||||
now := time.Now()
|
||||
_, err = models.Orm.QueryTable(new(models.SystemTenantDomain)).Filter("id", p.ID).Update(map[string]interface{}{
|
||||
"status": newStatus,
|
||||
"update_time": now,
|
||||
})
|
||||
if err != nil {
|
||||
jsonErr(&c.Controller, 500, 500, "审核失败: "+err.Error())
|
||||
|
||||
// 严格引擎驱动:必须命中在途实例与当前待办,否则拒绝(已移除单级兼容回退)
|
||||
msg, code := engineDomainAudit(p.ID, uint64(claims.UserID), pass, p.Comment, bizTid)
|
||||
if code != 200 {
|
||||
jsonErr(&c.Controller, code, code, msg)
|
||||
return
|
||||
}
|
||||
c.Data["json"] = map[string]interface{}{"code": 200, "msg": msg}
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
||||
// AuditProgress GET /platform/domain/tenant/audit/progress/:id
|
||||
// 返回该域名的审批进度(节点 + 各审批人状态),供平台端展示流转。
|
||||
func (c *PlatformTenantDomainController) AuditProgress() {
|
||||
if _, err := requirePlatform(&c.Controller); err != nil {
|
||||
jsonErr(&c.Controller, 401, 401, err.Error())
|
||||
return
|
||||
}
|
||||
id, _ := strconv.ParseUint(c.Ctx.Input.Param(":id"), 10, 64)
|
||||
c.Data["json"] = map[string]interface{}{"code": 200, "msg": "ok", "data": domainApprovalProgress(id)}
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
||||
// ToggleStatus POST /platform/domain/tenant/toggleStatus body:{id}
|
||||
func (c *PlatformTenantDomainController) ToggleStatus() {
|
||||
if _, err := requirePlatform(&c.Controller); err != nil {
|
||||
|
||||
Reference in new issue
Block a user