作者 唐旭辉

bug fix

... ... @@ -7,6 +7,7 @@ import (
"oppmg/protocol"
serveaudit "oppmg/services/audit"
servecommon "oppmg/services/common"
"strconv"
)
type AuditController struct {
... ... @@ -59,3 +60,26 @@ func (c *AuditController) AuditListBefore() {
msg = protocol.NewReturnResponse(data, nil)
return
}
//AuditInfo 获取机会详情
//@router /v1/audit/info
func (c *AuditController) AuditInfo() {
var msg *protocol.ResponseMessage
defer func() {
c.ResposeJson(msg)
}()
type Parameter struct {
ChanceId string `json:"chance_id"`
}
var param Parameter
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &param); err != nil {
log.Error("json 解析失败", err)
msg = protocol.BadRequestParam("1")
return
}
chanceid, _ := strconv.ParseInt(param.ChanceId, 10, 64)
companyId := c.GetCompanyId()
list, err := serveaudit.GetChanceDetail(chanceid, companyId)
msg = protocol.NewReturnResponse(list, err)
return
}
... ...
... ... @@ -15,7 +15,7 @@ const (
type InputElement struct {
Id int `json:"id"`
Sort int `json:"sort"` //排序
Lable string `json:"lable"` //标题
Label string `json:"label"` //标题
InputType string `json:"inputType"` //输入类型
Required int `json:"required"` //是否必填
// CurrentValue string `json:"-"` //"当前填写的值"
... ... @@ -263,7 +263,8 @@ type RspAuditList struct {
}
type ChanceFlowLog struct {
CreateTime string `json:"create_time"`
Content string `json:"content"`
UserrName string `json:"user_name"`
ChanceId string `json:"chance_id" orm:"column(chance_id)"`
CreateAt string `json:"create_at" orm:"column(create_at)"`
Content string `json:"content" orm:"column(content)"`
NickName string `json:"nick_name" orm:"column(nick_name)"`
}
... ...
... ... @@ -100,6 +100,7 @@ func init() {
beego.NSNamespace("/audit",
beego.NSRouter("/list", &controllers.AuditController{}, "post:AuditList"),
beego.NSRouter("/list/before", &controllers.AuditController{}, "post:AuditListBefore"),
beego.NSRouter("/info", &controllers.AuditController{}, "post:AuditInfo"),
),
)
... ...
... ... @@ -190,7 +190,7 @@ func GetChanceDetail(chanceid int64, companyid int64) (ResponseChanceInfo, error
var (
chanceContent []protocol.InputElement
)
err = json.Unmarshal([]byte(chanceInfo.Content), &chanceContent)
err = json.Unmarshal([]byte(chanceInfo.SourceContent), &chanceContent)
if err != nil {
log.Error("解析机会内容失败:%s", err)
}
... ... @@ -225,6 +225,24 @@ func GetChanceDetail(chanceid int64, companyid int64) (ResponseChanceInfo, error
} else {
log.Error("GetChanceTypeById(%d) err:%s", chanceInfo.ChanceTypeId, err)
}
flowlogs, err := getAuditFlowLog(chanceid)
if err != nil {
log.Warn("获取获取记录失败")
}
returnData.FlowLog = flowlogs
return returnData, nil
}
func getAuditFlowLog(chanceid int64) ([]protocol.ChanceFlowLog, error) {
var (
flowLogs = make([]protocol.ChanceFlowLog, 0)
err error
)
const datasql string = `SELECT a.chance_id,a.content,a.create_at,c.nick_name
FROM audit_flow_log AS a
LEFT JOIN user_company AS b ON a.approve_user_id=b.id
LEFT JOIN user AS c ON b.user_id = c.id
WHERE chance_id =? `
err = utils.ExecuteQueryAll(&flowLogs, datasql, chanceid)
return flowLogs, err
}
... ...
... ... @@ -72,7 +72,7 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs
AuditTemplateId: int(templateId),
Section: input.SectionType,
SortNum: input.Sort,
Label: input.Lable,
Label: input.Label,
InputType: input.InputType,
Required: int8(input.Required),
CreateAt: time.Now(),
... ... @@ -256,7 +256,7 @@ func insertOrUpdateInput(orm orm2.Ormer, companyId int64, templateId int, input
AuditTemplateId: int(templateId),
Section: input.SectionType,
SortNum: input.Sort,
Label: input.Lable,
Label: input.Label,
InputType: input.InputType,
Required: int8(input.Required),
CreateAt: time.Now(),
... ... @@ -275,7 +275,7 @@ func insertOrUpdateInput(orm orm2.Ormer, companyId int64, templateId int, input
}
{
updateMap := map[string]interface{}{
"Label": input.Lable,
"Label": input.Label,
"InputType": input.InputType,
"Required": int8(input.Required),
}
... ... @@ -448,7 +448,7 @@ func TemplateGet(uid, companyId int64, request *protocol.TemplateGetRequest) (rs
rsp.Template.InputList = append(rsp.Template.InputList, &protocol.InputElement{
Id: input.Id,
Sort: input.SortNum,
Lable: input.InputType,
Label: input.InputType,
Required: int(input.Required),
SectionType: input.Section,
})
... ...