作者 yangfu

ali视频点播修改

package aliyun
const (
RegionID = "cn-shanghai"
RegionID = "cn-shanghai"
//AccessKeyID = "LTAI4Fv7TX3UP9nYuofpLHRy"
//AccessKeySecret = "Yx6lSe7JE9KjtWyOV2LSBnjalrGUk6"
AccessKeyID = "LTAI4FhiZ3UktC6N1u3H5GFC"
AccessKeySecret = "UyspWwdni55CYQ02hUCint4qY2jNYO"
)
... ...
... ... @@ -66,7 +66,7 @@ func CreateUploadImage(client *vod.Client, r *CreateUploadImageRequest) (respons
if err != nil {
return
}
err = utils.DeepCopy(&response, &rsp)
err = utils.JsonDeepCopy(&response, &rsp)
return
}
... ...
... ... @@ -99,6 +99,15 @@ func DeepCopy(dst, src interface{}) error {
return gob.NewDecoder(&buf).Decode(dst)
}
//深度拷贝
func JsonDeepCopy(dst, src interface{}) error {
var buf bytes.Buffer
if err := json.NewEncoder(&buf).Encode(src); err != nil {
return err
}
return json.NewDecoder(&buf).Decode(dst)
}
//检查版本信息
func ValidVersion(current, compare string) bool {
curVersions := strings.Split(current, ".")
... ...
... ... @@ -44,7 +44,7 @@ const (
)
var (
SqlGetChanceSelfChecks = `select self_checks from chance where id =?` //机会自查数据
SqlGetChanceSelfChecks = `select user_id,review_status,self_checks from chance where id =?` //机会自查数据
)
func (t *Chance) TableName() string {
... ...
... ... @@ -153,6 +153,7 @@ type CheckQuestion struct {
CheckItem string `json:"checkItem"`
Title string `json:"title"`
GroupId int64 `json:"groupId"`
Answer string `json:"answer,omitempty"`
CheckOptions []CheckOption `json:"options"`
}
type CheckOption struct {
... ...
... ... @@ -269,7 +269,7 @@ func GetCheckQuestionsByTemplateId(id int64) (rsp []*protocol.CheckQuestion, err
}
//获取自查问题列表 通过机会(历史模板)
func GetCheckQuestionsByChanceId(id int64) (rsp []*protocol.CheckQuestion, err error) {
func GetCheckQuestionsByChanceId(header *protocol.RequestHeader, id int64) (rsp []*protocol.CheckQuestion, err error) {
var (
chance *models.Chance
selfChecks protocol.SelfChecks
... ... @@ -286,6 +286,10 @@ func GetCheckQuestionsByChanceId(id int64) (rsp []*protocol.CheckQuestion, err e
if len(chance.SelfChecks) == 0 {
return
}
//if chance.ReviewStatus==protocol.ReviewStatusPass{
// log.Warn("机会已审核通过不可编辑自查数据:",chance.Id)
// return
//}
if e := json.Unmarshal([]byte(chance.SelfChecks), &selfChecks); e != nil {
log.Error(e)
return
... ... @@ -300,6 +304,9 @@ func GetCheckQuestionsByChanceId(id int64) (rsp []*protocol.CheckQuestion, err e
idx = 0
}
item := protocol.NewCheckQuestion(c.CheckItem, getQuestionTitle(groupIdx, idx, c.CheckItem), c.GroupId, protocol.CheckOptionsCommit)
if header.UserId == chance.UserId && chance.ReviewStatus != protocol.ReviewStatusPass {
item.Answer = c.Answer
}
rsp = append(rsp, item)
idx++
}
... ...
... ... @@ -704,7 +704,6 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate
updateMap["DiscoveryScore"] = chance.DiscoveryScore
}
}
go agg.BulkInsertSelfChecks(header, chance.Id, chance.Id, request.SelfChecks, true, protocol.TypeSubmit)
}
}
... ... @@ -712,7 +711,12 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate
//机会发布 并且当前机会不是已经通过的,机会状态审核中(存在更新时自动通过)
if request.IsPublish && chance.ReviewStatus != protocol.ReviewStatusPass {
updateMap["ReviewStatus"] = int8(protocol.ReviewStatusAuditging)
}
//本人可以重新编辑
if len(request.SelfChecks) > 0 && header.UserId == chance.UserId && chance.ReviewStatus != protocol.ReviewStatusPass {
updateMap["SelfChecks"] = common.AssertJson(request.SelfChecks)
go agg.BulkInsertSelfChecks(header, chance.Id, chance.Id, request.SelfChecks, true, protocol.TypeSubmit)
}
updateMap["AuditTemplateConfig"] = common.AssertJson(auditConfig)
updateMap["Content"] = request.Content
... ... @@ -2340,7 +2344,7 @@ func ChanceReviseDetail(header *protocol.RequestHeader, request *protocol.Chance
func CheckQuestions(header *protocol.RequestHeader, request *protocol.CheckQuestionsRequest) (rsp *protocol.CheckQuestionsResponse, err error) {
var ()
rsp = &protocol.CheckQuestionsResponse{}
rsp.Questions, err = agg.GetCheckQuestionsByChanceId(request.ChanceId)
rsp.Questions, err = agg.GetCheckQuestionsByChanceId(header, request.ChanceId)
if err != nil {
log.Error(err)
}
... ...