作者 yangfu

我的审核

... ... @@ -30,6 +30,8 @@ type AuditFlowProcess struct {
UserName string `orm:"column(user_name);size(50)" description:"用户名-冗余"`
RoleName string `orm:"column(role_name);size(50)" description:"角色名-冗余"`
RoleId int `orm:"column(role_id);size(50)" description:"角色id-冗余"`
ApproveMessage string `orm:"column(approve_message);size(50)" description:"审核消息-冗余"`
TemplateId int `orm:"column(template_id);size(50)" description:"模板编号-冗余"`
}
func (t *AuditFlowProcess) TableName() string {
... ...
... ... @@ -128,7 +128,7 @@ order by create_at desc
func GetChanceMyApproveChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) {
sql := `select a.*,b.images,b.speechs,b.videos from (
select a.*,b.user_id,b.source_content,b.enable_status from (
select id,approve_time,approve_data,uid,chance_id
select id,approve_time,approve_data,uid,chance_id,approve_message,create_at process_create_time
from audit_flow_process where uid=? and enable_status =1 and review_status in (?) and (?=0 or id>?)
)a left outer join chance b on a.chance_id = b.id
)a left outer join chance_data b on a.chance_id =b.chance_id
... ...
... ... @@ -48,6 +48,11 @@ const (
PublicToCompany = 2 //公司公开
)
const (
ChanceStatusDelete = 1 //删除
ChanceStatusClose = 2 //关闭
)
/*Favorite */
type FavoriteRequest struct {
ObjectType int `json:"object_type" valid:"Required"` //收藏 点赞
... ... @@ -207,13 +212,13 @@ type MyApproveChanceResponse struct {
//机会列表 通用项
type CommonListItem struct {
Chance ChanceItem `json:"chance,omitempty"` //机会详情
ChanceData ChanceData `json:"chanceData,omitempty"` //机会数据(是否收藏/点赞 浏览数 点赞总数 评论数)
Approve Approve `json:"approve,omitempty"` //审核人 审核信息(时间)
ApproveData ApproveData `json:"ApproveData"` //审核数据(公开状态 评分)
Chance ChanceItem `json:"chance,omitempty"` //机会详情
ChanceData interface{} `json:"chanceData,omitempty"` //机会数据(是否收藏/点赞 浏览数 点赞总数 评论数)ChanceData
Approve interface{} `json:"approve,omitempty"` //审核人 审核信息(时间) Approve
ApproveData interface{} `json:"ApproveData,omitempty"` //审核数据(公开状态 评分) ApproveData
Message interface{} `json:"message,omitempty"`
Comment interface{} `json:"comment,omitempty"`
ChanceStatus int `json:"chanceStatus,omitempty"` //1.删除 2.关闭
ChanceStatus int `json:"chanceStatus"` //0:正常 1.删除 2.关闭
}
type ChanceData struct {
... ... @@ -243,16 +248,18 @@ type ChanceItem struct {
type ChanceApproveItemOrm struct {
ChanceUserId int64 `orm:"column(chance_user_id)"`
SourceContent string `orm:"column(source_content)"`
ChanceEnableStatus string `orm:"column(enable_status)"`
ChanceEnableStatus int `orm:"column(enable_status)"`
Images string `orm:"column(images)"`
Voices string `orm:"column(speechs)"`
Videos string `orm:"column(videos)"`
Id int64 `orm:"column(id)"` //审核id
ApproveTime time.Time `orm:"column(approve_time)"`
ApproveData string `orm:"column(approve_data)"`
ApproveUserId int64 `orm:"column(uid)"`
ChanceId int64 `orm:"column(chance_id)"` // 机会id
Id int64 `orm:"column(id)"` //审核id
ApproveTime time.Time `orm:"column(approve_time)"`
ApproveData string `orm:"column(approve_data)"`
ApproveMessage string `orm:"column(approve_message)"`
ApproveUserId int64 `orm:"column(uid)"`
ProcessCreateTime time.Time `orm:"column(process_create_time)"`
ChanceId int64 `orm:"column(chance_id)"` // 机会id
}
/*ChanceDetail 机会详情*/
... ...
... ... @@ -67,9 +67,10 @@ type Role struct {
}
type Approve struct {
Provider BaseUserInfo `json:"provider"`
ProcessId int64 `json:"processId"`
ApproveTime int64 `json:"approveTime"`
//Provider *BaseUserInfo `json:"provider"`
ProcessId int64 `json:"processId"`
CreateTime int64 `json:"createTime"`
ApproveTime int64 `json:"approveTime"`
}
//审核数据 审核通过
... ...
... ... @@ -53,6 +53,12 @@ const (
MsgTypeAudit = 8 //机会审核
)
var (
MessageApproving = "提交了一条%v机会消息,需要您审核"
MessageApproveSuccess = "审核通过你提交的%v机会"
MessageApproveReject = "退回您了提交的%v机会"
)
/*MessageCenter */
type MessageCenterRequest struct {
MsgType int `json:"msgType" valid:"Required"`
... ...
... ... @@ -236,12 +236,17 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
auditConfig *protocol.AuditConfig
auditFlows []*models.AuditFlowProcess
suplusApprove SuplusApprove
chanceType *models.ChanceType
)
//1.模板是否存在
if template, err = models.GetAuditTemplateById(request.AuditTemplateId); err != nil {
log.Error("模板不存在:", request.AuditTemplateId, err)
return
}
if chanceType, err = models.GetChanceTypeById(template.ChanceTypeId); err != nil {
log.Error("一级分类不存在:", request.AuditTemplateId, err)
return
}
auditConfig = &protocol.AuditConfig{NoApprover: template.NoApprover}
orm := orm.NewOrm()
orm.Begin()
... ... @@ -284,6 +289,8 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
return
}
for i := 0; i < len(auditFlows); i++ {
auditFlows[i].ApproveMessage = fmt.Sprintf(protocol.MessageApproving, chanceType.Name)
//auditFlows[i].TemplateId = int(template.Id)
if _, err = orm.Insert(auditFlows[i]); err != nil {
log.Error(err)
orm.Rollback()
... ... @@ -660,6 +667,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat
RoleName: roleName,
UserName: approver.NickName,
ReviewStatus: protocol.ReviewStatusAuditging,
TemplateId: int(templateId),
}
if config.Level == 1 {
item.IsActive = 1
... ... @@ -799,7 +807,7 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove
provider *protocol.BaseUserInfo
)
rsp = &protocol.MyApproveChanceResponse{}
if total, err = models.GetChanceMyChance(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &myChances); err != nil {
if total, err = models.GetChanceMyApproveChance(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &myChances); err != nil {
if err == orm.ErrNoRows {
err = nil
return
... ... @@ -807,30 +815,47 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove
log.Error(err)
return
}
if provider, err = agg.GetUserBaseInfo(header.UserId, header.CompanyId); err != nil {
log.Error(err)
return
}
rsp = &protocol.MyApproveChanceResponse{Total: total}
for i := 0; i < len(myChances); i++ {
chance := myChances[i]
commItem := protocol.CommonListItem{}
item := protocol.ChanceItem{
Id: chance.Id,
Provider: provider,
//CreateTime: chance.CreateTime.Unix() * 1000,
if len(chance.SourceContent) == 0 { //机会删除
commItem.ChanceStatus = protocol.ChanceStatusDelete
} else if chance.ChanceEnableStatus == 0 { //机会关闭
commItem.ChanceStatus = protocol.ChanceStatusClose
} else {
if provider, err = agg.GetUserBaseInfo(header.UserId, header.CompanyId); err != nil {
commItem.ChanceStatus = protocol.ChanceStatusDelete
log.Error(err)
//return
} else {
item := protocol.ChanceItem{
Id: chance.Id,
Provider: provider,
//CreateTime: chance.CreateTime.Unix() * 1000,
}
jsonUnmarshal(chance.SourceContent, &item.FormList)
jsonUnmarshal(chance.Images, &item.Pictures)
jsonUnmarshal(chance.Voices, &item.Speechs)
jsonUnmarshal(chance.Videos, &item.Videos)
commItem.Chance = item
}
}
jsonUnmarshal(chance.SourceContent, &item.FormList)
jsonUnmarshal(chance.Images, &item.Pictures)
jsonUnmarshal(chance.Voices, &item.Speechs)
jsonUnmarshal(chance.Videos, &item.Videos)
{
commItem.Chance = item
commItem.Approve = protocol.Approve{
ProcessId: chance.Id,
//Provider:provider,
CreateTime: chance.ProcessCreateTime.Unix() * 1000,
ApproveTime: chance.ApproveTime.Unix() * 1000,
}
//审核完有审核数据
if request.ReviewStatus == protocol.ReviewStatusAuditging {
commItem.Message = chance.ApproveMessage
}
if request.ReviewStatus == protocol.ReviewStatusPass {
jsonUnmarshal(chance.ApproveData, &commItem.ApproveData)
}
rsp.List = append(rsp.List, commItem)
}
return
}
... ...