作者 yangfu

修改 草稿箱列表(自查内容,表单)

... ... @@ -381,6 +381,10 @@ func (this *ChanceController) ChanceDetail() {
return
}
header := controllers.GetRequestHeader(this.Ctx)
if request.IsDraft {
msg = protocol.NewReturnResponse(chance.ChanceDraftDetail(header, request))
return
}
msg = protocol.NewReturnResponse(chance.ChanceDetail(header, request))
}
... ... @@ -834,6 +838,7 @@ func (this *ChanceController) DraftSaveChance() {
return
}
header := controllers.GetRequestHeader(this.Ctx)
request.SelfChecks.SetSelfChecksLevel1ByRule()
msg = protocol.NewReturnResponse(chance.DraftSaveChance(header, request))
}
... ...
... ... @@ -130,6 +130,7 @@ type TemplateRequest struct {
TemplateId int `json:"templateId" valid:"Required"`
ChanceId int64 `json:"chanceId" ` //机会编号 ios特殊使用
IsDraft bool `json:"isDraft"` //是否是草稿
}
type TemplateResponse struct {
Template *Template `json:"template"`
... ... @@ -416,7 +417,8 @@ type CommChanceItemOrm struct {
/*ChanceDetail 机会详情*/
type ChanceDetailRequest struct {
Id int64 `json:"id"` //机会编号
Id int64 `json:"id"` //机会编号
IsDraft bool `json:"isDraft"` //是否是草稿
}
type ChanceDetailResponse struct {
ChanceDetail ChanceItem `json:"chance"`
... ... @@ -594,6 +596,9 @@ type CommonListItem struct {
ReviewStatus int `json:"reviewStatus,omitempty"` //审核状态
ChanceId int64 `json:"chanceId,omitempty"` //机会编号
//Questions interface{} `json:"questions,omitempty"`
}
type MsgCommonListItem struct {
... ...
... ... @@ -287,16 +287,17 @@ func Templates(header *protocol.RequestHeader, request *protocol.TemplatesReques
//模板详情
func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest) (rsp *protocol.TemplateResponse, err error) {
var (
templates *models.AuditTemplate
forms []*models.AuditForm
chance *models.Chance
templates *models.AuditTemplate
forms []*models.AuditForm
chance *models.Chance
chanceDraft *models.ChanceDraft
)
rsp = &protocol.TemplateResponse{}
if templates, err = models.GetAuditTemplate(header.CompanyId, request.ChanceTypeId, request.TemplateId); err != nil {
log.Error(fmt.Sprintf("公司:%v chance_type_id:%v id:%v无模板 ", header.CompanyId, request.ChanceTypeId, request.TemplateId), err)
return
}
if request.ChanceId > 0 {
if request.ChanceId > 0 && !request.IsDraft {
if chance, err = models.GetChanceById(request.ChanceId); err == nil {
if chance.EnableStatus == 0 {
err = protocol.NewErrWithMessage(5101)
... ... @@ -326,9 +327,17 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest)
template.Link = fmt.Sprintf("%v/#/ability/opportunity?id=%v", beego.AppConfig.String("h5_host"), item.Id)
}
if request.ChanceId > 0 {
if template.Questions, err = agg.GetCheckQuestionsByChanceId(header, request.ChanceId); err != nil {
log.Error(err)
return
if request.IsDraft { //是否是机会草稿
if chanceDraft, err = models.GetChanceDraftById(request.ChanceId); err == nil {
var old []protocol.SelfCheck
utils.JsonUnmarshal(chanceDraft.SelfChecks, &old)
template.Questions = GetNewestCheckQuestions(chanceDraft.AuditTemplateId, old)
}
} else { //正常机会
if template.Questions, err = agg.GetCheckQuestionsByChanceId(header, request.ChanceId); err != nil {
log.Error(err)
return
}
}
} else {
if template.Questions, err = agg.GetCheckQuestionsByTemplateId(templates.Id); err != nil {
... ... @@ -2043,6 +2052,60 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail
return
}
func ChanceDraftDetail(header *protocol.RequestHeader, request *protocol.ChanceDetailRequest) (rsp *protocol.ChanceDetailResponse, err error) {
var (
chance *models.ChanceDraft
chanceData *models.ChanceData
provider *protocol.BaseUserInfo
)
rsp = &protocol.ChanceDetailResponse{}
if chance, err = models.GetChanceDraftById(request.Id); err != nil {
if err == orm.ErrNoRows {
err = protocol.NewErrWithMessage(5101)
return
}
log.Error(err)
return
}
//用户信息
if provider, err = agg.GetUserBaseInfo(chance.UserId, header.CompanyId); err != nil {
log.Error(err)
return
}
if template, e := models.GetAuditTemplateById(chance.AuditTemplateId); e == nil {
rsp.ChanceTemplate = protocol.NameItem{
Id: int(template.Id),
Name: template.Name,
}
}
if chanceType, e := models.GetChanceTypeById(chance.ChanceTypeId); e == nil {
rsp.ChanceType = protocol.NameItem{
Id: int(chanceType.Id),
Name: chanceType.Name,
}
}
item := protocol.ChanceItem{
Id: chance.Id,
Provider: provider,
CreateTime: chance.CreateAt.Unix() * 1000,
UpdateTime: chance.UpdateAt.Unix() * 1000,
}
jsonUnmarshal(chance.SourceContent, &item.FormList)
jsonUnmarshal(chance.SelfChecks, &item.SelfChecks)
item.FormList = clearEmptyForm(item.FormList)
if chanceData, err = models.GetChanceDataByChanceId(chance.Id); err == nil {
if len(chanceData.Videos) > 0 {
chanceData.Videos = strings.ReplaceAll(chanceData.Videos, "https", "http")
}
jsonUnmarshal(chanceData.Images, &item.Pictures)
jsonUnmarshal(chanceData.Speechs, &item.Speechs)
jsonUnmarshal(chanceData.Videos, &item.Videos)
}
rsp.ChanceDetail = item
return
}
//机会删除
func ChanceDelete(header *protocol.RequestHeader, request *protocol.ChanceDeleteRequest) (rsp *protocol.ChanceDeleteResponse, err error) {
var (
... ... @@ -2408,11 +2471,11 @@ func DraftByChance(header *protocol.RequestHeader, request *protocol.DraftByChan
commItem.Chance.RelatedDepartmentInfo = agg.GetDepartment(ormItem.DepartmentId)
commItem.Chance.ApproveTime = 0
commItem.Chance.FormList = GetNewestFormList(header, ormItem.ChanceTypeId, ormItem.TemplateId, commItem.Chance.FormList)
//commItem.Chance.FormList = GetNewestFormList(header, ormItem.ChanceTypeId, ormItem.TemplateId, commItem.Chance.FormList)
if len(ormItem.SelfChecks) > 0 {
utils.JsonUnmarshal(ormItem.SelfChecks, &commItem.Chance.SelfChecks)
}
commItem.Chance.SelfChecks = GetNewestSelfChecks(int64(ormItem.TemplateId), commItem.Chance.SelfChecks)
//commItem.Questions = GetNewestCheckQuestions(int64(ormItem.TemplateId), commItem.Chance.SelfChecks)
rsp.List = append(rsp.List, commItem)
}
return
... ... @@ -2445,31 +2508,20 @@ func getNewestFormList(new []*protocol.Form, old []*protocol.Form) []*protocol.F
}
//获取最新的自查列表
func GetNewestSelfChecks(tpId int64, old []protocol.SelfCheck) protocol.SelfChecks {
var new []protocol.SelfCheck = make([]protocol.SelfCheck, 0)
func GetNewestCheckQuestions(tpId int64, old []protocol.SelfCheck) []*protocol.CheckQuestion {
var rsp = []*protocol.CheckQuestion{}
if questions, err := agg.GetCheckQuestionsByTemplateId(tpId); err != nil {
log.Error(err)
return old
return rsp
} else {
for i := range questions {
q := questions[i]
new = append(new, protocol.SelfCheck{
Id: q.Id,
ParentId: q.ParentId,
CheckItem: q.CheckItem,
GroupId: q.GroupId,
Answer: q.Answer,
Reason: q.Reason,
})
}
}
new = getNewestSelfChecks(new, old)
protocol.SelfChecks(new).SetSelfChecksLevel1ByRule()
return new
getNewestSelfChecks(questions, old)
rsp = questions
}
return rsp
}
func getNewestSelfChecks(new []protocol.SelfCheck, old []protocol.SelfCheck) []protocol.SelfCheck {
func getNewestSelfChecks(new []*protocol.CheckQuestion, old []protocol.SelfCheck) {
if len(new) == 0 {
return old
return
}
for i := 0; i < len(new); i++ {
itemNew := new[i]
... ... @@ -2482,5 +2534,5 @@ func getNewestSelfChecks(new []protocol.SelfCheck, old []protocol.SelfCheck) []p
}
}
}
return new
return
}
... ...
package contrab
import (
"fmt"
"github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
"net/url"
"opp/internal/aliyun"
"strings"
"testing"
)
func MyGetURLUploadInfos(client *vod.Client) (response *vod.GetURLUploadInfosResponse, err error) {
request := vod.CreateGetURLUploadInfosRequest()
// 对URL进行编码
sourceUrls := []string{
"http:/mmm-opp-dev.fjmaimaimai.com/file/opp/voice/20200106/1578275187_mxeseTAEQXTH7A7ZK6z4FzZ2YeDwX3Kw.mp3",
//"http:/mmm-opp-dev.fjmaimaimai.com/file/opp/image/20200106/1578297295_RxJscRHCzQmxeseTAEQXTH7A7ZK6z4Fz.jpg",
}
uploadUrls := []string{}
for _, surl := range sourceUrls {
encodeUrl := url.QueryEscape(surl)
uploadUrls = append(uploadUrls, encodeUrl)
}
// 设置上传的URL列表,用逗号分隔
request.UploadURLs = strings.Join(uploadUrls, ",")
// 也可以传入jobId查询
//request.JobIds = "jobId1,jobId2"
request.AcceptFormat = "JSON"
return client.GetURLUploadInfos(request)
}
func Test_MyGetURLUploadInfos(t *testing.T) {
client, err := aliyun.DefaultVodClient()
if err != nil {
panic(err)
}
response, err := MyGetURLUploadInfos(client)
if err != nil {
panic(err)
}
fmt.Println(response.GetHttpContentString())
fmt.Println(response.NonExists)
for _, uploadInfo := range response.URLUploadInfoList {
fmt.Printf("%s: %s %s\n", uploadInfo.UploadURL, uploadInfo.Status, uploadInfo.MediaId)
}
}
... ...