作者 yangfu

我的审核修改

... ... @@ -28,16 +28,20 @@
|功能|完成状态|时间|接口路径
|---|---|----|----|
|我的机会-我提交的| | |/v1/chance/mySubmitChance|
|机会详情| | |v1/chance/detail|
|机会更新| | | |
|机会删除| | |/v1/chance/delete|
|我的机会-我的审核| | | |
|机会审核| | | /v1/chance/approve|
|机会修改评分| | |/v1/chance/changeScore|
|机会修改公开状态| | |/v1/chance/changePublish|
|计算发现分| | |/v1/chance/calculateScore|
|用户机会权限| | | |
|我的机会-我的审核| | |/v1/chance/myApproveChance|
|机会-详情| | |v1/chance/detail|
|机会-更新| | | |
|机会-删除| | |/v1/chance/delete|
|机会-审核| | | /v1/chance/approve|
|机会-修改评分| | |/v1/chance/changeScore|
|机会-修改公开状态| | |/v1/chance/changePublish|
|机会-计算发现分| | |/v1/chance/calculateScore|
|配置-用户机会权限| | | |
|配置-评分| | |v1/config/score|
|消息-机会审核消息| | | |
|机会池| | | |
|我的机会-我的收藏| | |/v1/chance/|
|我的机会-我的点赞| | |/v1/chance/|
|消息-点赞| | |v1/message/msgInteractive|
|消息-评论| | |v1/message/msgInteractive|
|机会评论列表| | |/v1/chance/comments|
... ... @@ -51,10 +55,5 @@
|机会审核消息| | |v1/message/msgInteractive|
|我提交的机会| | | v1/chance/chances|
|我审核的机会| | | v1/chance/chances|
|机会详情| | | |
|待抓住机会列表| | |v1/chance/chances|
|配置-评分| | |v1/config/score|
|机会审核| | |v1/chance/audit|
|机会修改评分| | |v1/chance/editScore|
|机会修改公开状态| | |v1/chance/editStatus|
... ...
... ... @@ -231,7 +231,7 @@ func (this *ChanceController) ChanceSubmit() {
msg = protocol.NewReturnResponse(chance.ChanceSubmit(header, request))
}
//ChanceStatistics
//ChanceStatistics 机会统计
//@router /statistics [post]
func (this *ChanceController) ChanceStatistics() {
var msg *protocol.ResponseMessage
... ...
... ... @@ -150,7 +150,7 @@ func ExecuteQueryOneWithOrmer(o orm.Ormer, result interface{}, sqlstr string, pa
//ExecuteQuerySql 执行原生sql查询多条记录
func ExecuteQueryAll(result interface{}, sqlstr string, param ...interface{}) error {
PrintLogSql(sqlstr, param...)
//PrintLogSql(sqlstr, param...)
var err error
o := orm.NewOrm()
err = ExecuteQueryAllWithOrmer(o, result, sqlstr, param)
... ...
... ... @@ -109,12 +109,12 @@ order by create_at desc
limit ?
) a left JOIN chance_data b on a.id =b.chance_id`
sqlCount := `select count(0) from (
sqlCount := fmt.Sprintf(`select count(0) from (
select id,user_id,create_at,source_content from chance
where user_id=? and company_id=? and review_status in (?)
where user_id=? and company_id=? and review_status in (%v)
order by create_at desc
) a left JOIN chance_data b on a.id =b.chance_id`
if err = utils.ExecuteQueryOne(&total, sqlCount, uid, cid, utils.JoinInt8s(reviewStatus, ",")); err != nil {
) a left JOIN chance_data b on a.id =b.chance_id`, utils.JoinInt8s(reviewStatus, ","))
if err = utils.ExecuteQueryOne(&total, sqlCount, uid, cid); err != nil {
return
}
if v != nil {
... ... @@ -126,22 +126,22 @@ 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 (
sql := fmt.Sprintf(`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,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>?)
from audit_flow_process where uid=? and enable_status =1 and review_status in (%v) 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
order by a.approve_time desc
LIMIT ?`
LIMIT ?`, utils.JoinInt8s(reviewStatus, ","))
sqlCount := `select count(0)
from audit_flow_process where uid=? and enable_status =1 and review_status in (?) `
if err = utils.ExecuteQueryOne(&total, sqlCount, uid, utils.JoinInt8s(reviewStatus, ",")); err != nil {
sqlCount := fmt.Sprintf(`select count(0)
from audit_flow_process where uid=? and enable_status =1 and review_status in (%v) `, utils.JoinInt8s(reviewStatus, ","))
if err = utils.ExecuteQueryOne(&total, sqlCount, uid); err != nil {
return
}
if v != nil {
if err = utils.ExecuteQueryAll(v, sql, uid, utils.JoinInt8s(reviewStatus, ","), lastId, lastId, pageSize); err != nil {
if err = utils.ExecuteQueryAll(v, sql, uid, lastId, lastId, pageSize); err != nil {
return
}
}
... ...
... ... @@ -53,7 +53,7 @@ const (
ChanceStatusClose = 2 //关闭
)
/*Favorite */
/*Favorite 我的收藏/点赞*/
type FavoriteRequest struct {
ObjectType int `json:"object_type" valid:"Required"` //收藏 点赞
ChanceType int `json:"chance_type" valid:"Required"`
... ... @@ -66,29 +66,7 @@ type FavoriteResponse struct {
Lists []*ChanceFavorite `json:"lists"`
}
type ChanceFavorite struct {
Id int64 `json:"id"`
Favorite interface{} `json:"favorite"`
}
type ChanceDetail struct {
Id int64 `json:"id"`
Provider *BaseUserInfo `json:"provider"`
IsCollect bool `json:"is_collect"`
IsZan bool `json:"is_zan"`
Content string `json:"content"`
ChanceType int `json:"chance_type"`
//图片
//视频
//语音
ViewTotal int `json:"view_total"`
CommentTotal int `json:"comment_total"`
ZanTotal int `json:"zan_total"`
}
/*SympathyAction */
/*SympathyAction 点赞,收藏*/
type SympathyActionRequest struct {
MarkType int `json:"mark_type" valid:"Required"` // 1.赞 2.收藏
SourceType int `json:"source_type" valid:"Required"` //protocol.SourceType //机会 评论
... ... @@ -113,27 +91,7 @@ type TemplatesResponse struct {
Templates []*Template `json:"list"`
}
//模板
type Template struct {
Id int64 `json:"id"`
Name string `json:"name"`
Doc string `json:"doc"`
Icon string `json:"icon"`
FormList []*Form `json:"formList"`
Link string `json:"link"` //示例
}
//表单
type Form struct {
Id int `json:"id"`
Label string `json:"label"`
InputType string `json:"inputType"`
SectionType int8 `json:"sectionType"`
Value string `json:"value"`
Required int8 `json:"required"`
}
/*ChanceExample*/
/*ChanceExample 机会示例*/
type ChanceExampleRequest struct {
TemplateId int `json:"templateId" valid:"Required"`
}
... ... @@ -141,6 +99,7 @@ type ChanceExampleResponse struct {
Content string `json:"content"`
}
/*提交机会*/
type ChanceSubmitRequest struct {
Id int64 `json:"id"` // = 0添加 >0 编辑
AuditTemplateId int64 `json:"auditTemplateId" valid:"Required"`
... ... @@ -151,29 +110,9 @@ type ChanceSubmitRequest struct {
Videos []Video `json:"videos"`
RelatedDepartment int64 `json:"relatedDepartments" valid:"Required"`
}
type ChanceSubmitResponse struct {
}
type Speech struct {
Path string `json:"path"`
Duration int `json:"duration"`
}
type Picture struct {
Path string `json:"path"`
W int `json:"w"`
H int `json:"h"`
}
type Video struct {
Path string `json:"path"`
Cover Cover `json:"cover"` //封面
Duration int `json:"duration"`
}
type AuditConfig struct {
NoApprover int8 `json:"no_approver"` //审核人空时:【1:自动通过】【2:转交给管理员】
}
/*ChanceStatistics 首页-机会池统计*/
type ChanceStatisticsRequest struct {
}
... ... @@ -182,12 +121,6 @@ type ChanceStatisticsResponse struct {
List []ChanceTotalItem `json:"list"`
}
type ChanceTotalItem struct {
Id int `json:"id"` //类型
Name string `json:"name"` //总数
Total int `json:"total"`
}
/*MyChance 我的机会*/
type MySubmitChanceRequest struct {
LastId int64 `json:"lastId"`
... ... @@ -199,31 +132,6 @@ type MySubmitChanceResponse struct {
Total int `json:"total"`
}
/*MyApproveChance 我审核的机会*/
type MyApproveChanceRequest struct {
LastId int64 `json:"lastId"`
PageSize int `json:"pageSize" valid:"Required"`
ReviewStatus int8 `json:"reviewStatus"` //审核状态
}
type MyApproveChanceResponse struct {
List []CommonListItem `json:"list"`
Total int `json:"total"`
}
//机会列表 通用项
type CommonListItem struct {
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"` //0:正常 1.删除 2.关闭
}
type ChanceData struct {
}
//我的机会列表
type ChanceItemOrm struct {
Id int64 `orm:"column(id)"`
... ... @@ -236,14 +144,16 @@ type ChanceItemOrm struct {
ApproveData string `json:"approveData"` //审核数据
}
type ChanceItem struct {
Id int64 `json:"id"`
CreateTime int64 `json:"createTime"`
Provider *BaseUserInfo `json:"provider"`
FormList []*Form `json:"formList" valid:"Required"`
Speechs []Speech `json:"speechs"`
Pictures []Picture `json:"pictures"`
Videos []Video `json:"videos"`
/*MyApproveChance 我审核的机会*/
type MyApproveChanceRequest struct {
LastId int64 `json:"lastId"`
PageSize int `json:"pageSize" valid:"Required"`
ReviewStatus int8 `json:"reviewStatus"` //审核状态
}
type MyApproveChanceResponse struct {
List []CommonListItem `json:"list"`
Total int `json:"total"`
}
//我的审核机会列表
... ... @@ -270,18 +180,12 @@ type ChanceDetailRequest struct {
}
type ChanceDetailResponse struct {
ChanceDetail ChanceItem `json:"chance"`
ApproveData *ApproveData `json:"publicData"`
ChanceData interface{} `json:"chanceData,omitempty"` //机会数据(是否收藏/点赞 浏览数 点赞总数 评论数)ChanceData
ApproveData *ApproveData `json:"approveData"`
ApproveProcess []*ProcessItem `json:"approveProcess"`
ApproveAccess *ApproveAccess `json:"approveAccess"` //
}
/*ChanceDelete 机会删除*/
type ChanceDeleteRequest struct {
Id int64 `json:"id"` //机会编号
}
type ChanceDeleteResponse struct {
}
/*ChanceChangePublish 修改公开状态*/
type ChanceChangePublishRequest struct {
ChanceId int64 `json:"chanceId"` //机会编号
... ... @@ -305,3 +209,113 @@ type ChanceCalculateScoreRequest struct {
type ChanceCalculateScoreResponse struct {
DiscoveryScore float64 `json:"discoveryScore"` //发现分
}
/*ChanceDelete 机会删除*/
type ChanceDeleteRequest struct {
Id int64 `json:"id"` //机会编号
}
type ChanceDeleteResponse struct {
}
type ChanceFavorite struct {
Id int64 `json:"id"`
Favorite interface{} `json:"favorite"`
}
//机会详情
type ChanceDetail struct {
Id int64 `json:"id"`
Provider *BaseUserInfo `json:"provider"`
IsCollect bool `json:"is_collect"`
IsZan bool `json:"is_zan"`
Content string `json:"content"`
ChanceType int `json:"chance_type"`
//图片
//视频
//语音
ViewTotal int `json:"view_total"`
CommentTotal int `json:"comment_total"`
ZanTotal int `json:"zan_total"`
}
//模板
type Template struct {
Id int64 `json:"id"`
Name string `json:"name"`
Doc string `json:"doc"`
Icon string `json:"icon"`
FormList []*Form `json:"formList"`
Link string `json:"link"` //示例
}
//表单
type Form struct {
Id int `json:"id"`
Label string `json:"label"`
InputType string `json:"inputType"`
SectionType int8 `json:"sectionType"`
Value string `json:"value"`
Required int8 `json:"required"`
}
//语音
type Speech struct {
Path string `json:"path"`
Duration int `json:"duration"`
}
//图片
type Picture struct {
Path string `json:"path"`
W int `json:"w"`
H int `json:"h"`
}
//视频
type Video struct {
Path string `json:"path"`
Cover Cover `json:"cover"` //封面
Duration int `json:"duration"`
}
//审批配置
type AuditConfig struct {
NoApprover int8 `json:"no_approver"` //审核人空时:【1:自动通过】【2:转交给管理员】
}
//机会池 - 统计
type ChanceTotalItem struct {
Id int `json:"id"` //类型
Name string `json:"name"` //总数
Total int `json:"total"`
}
//机会列表 通用项
type CommonListItem struct {
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"` //0:正常 1.删除 2.关闭
}
type ChanceItem struct {
Id int64 `json:"id"`
CreateTime int64 `json:"createTime"`
Provider *BaseUserInfo `json:"provider"`
FormList []*Form `json:"formList" valid:"Required"`
Speechs []Speech `json:"speechs"`
Pictures []Picture `json:"pictures"`
Videos []Video `json:"videos"`
}
type ChanceData struct {
ThumbsUpTotal int `json:"thumbsUpTotal"` //点赞总数
CommentTotal int `json:"commentTotal"` //评论总数
PageViewTotal int `json:"pageViewTotal"` //评论总数
IsThumbsUp int `json:"isThumbsUp"` //是否点赞 1 点赞, 0 没有点赞
IsCollect int `json:"isCollect"` //是否收藏 1 是 0 否
}
... ...
... ... @@ -37,6 +37,27 @@ type ChanceApproveProcessResponse struct {
ApproveAccess *ApproveAccess `json:"approveOperate"`
}
//审批数据
type Approve struct {
//Provider *BaseUserInfo `json:"provider"`
ProcessId int64 `json:"processId"`
CreateTime int64 `json:"createTime"`
ApproveTime int64 `json:"approveTime"`
}
//审核操作权限
type ApproveAccess struct {
ProcessId int64 `json:"processId"`
AllowApprove int `json:"allowApprove"`
AllowReject int `json:"allowReject"`
}
//审核数据 审核通过
type ApproveData struct {
PublicData PublicData `json:"publicData"` // 公开数据
Score Score `json:"score"`
}
//进程项
type ProcessItem struct {
Id int64 `json:"id"`
... ... @@ -49,36 +70,11 @@ type ProcessItem struct {
Name string `json:"name"`
RoleName string `json:"roleName"`
Role int `json:"-"`
ApproveData ApproveData `json:"ApproveData"` //审核数据
ApproveData *ApproveData `json:"approveData"` //审核数据
//ApproveUser UserItem `json:"approveUser"` //审核人 //状态不是审核中
ApproveUsers []UserItem `json:"approveUsers"` //审核人员 //1 会签 2 或签 //审核中 1.部门长 2.角色
}
//用户项
type UserItem struct {
Uid int64 `json:"uid"`
Name string `json:"name"`
}
//角色项
type Role struct {
Id int `json:"id"`
Name string `json:"name"`
}
type Approve struct {
//Provider *BaseUserInfo `json:"provider"`
ProcessId int64 `json:"processId"`
CreateTime int64 `json:"createTime"`
ApproveTime int64 `json:"approveTime"`
}
//审核数据 审核通过
type ApproveData struct {
PublicData PublicData `json:"publicData"` // 公开数据
Score Score `json:"score"`
}
//公开数据
type PublicData struct {
PublishStatus int `json:"publishStatus"` //公开状态 0未公开、1部门公开、2公司公开
... ... @@ -99,10 +95,3 @@ type Score struct {
ValueScore float64 `json:"valueScore"` //价值分
DiscoveryScore float64 `json:"discoveryScore"` //发现分
}
//审核操作权限
type ApproveAccess struct {
ProcessId int64 `json:"processId"`
AllowApprove int `json:"allowApprove"`
AllowReject int `json:"allowReject"`
}
... ...
... ... @@ -36,3 +36,32 @@ const (
MyAuditChancePass //我审核的机会-已通过
MyAuditChanceReturn //我审核的机会-已退回
)
var MapStaticName map[int64]string
func init() {
MapStaticName = make(map[int64]string)
MapStaticName[CollectStatic] = "收藏"
MapStaticName[ZanStatic] = "点赞"
MapStaticName[CommentStatic] = "评论"
MapStaticName[MyCommitChance] = "我提交的机会"
MapStaticName[MyCommitChanceWait] = "我提交的机会-待审批"
MapStaticName[MyCommitChanceReturn] = "我提交的机会-退回"
MapStaticName[MyCommitChancePass] = "我提交的机会-已通过"
MapStaticName[MyAuditChance] = "我审核的机会"
MapStaticName[MyAuditChanceWait] = "我审核的机会-待我审批"
MapStaticName[MyAuditChancePass] = "我审核的机会-已通过"
MapStaticName[MyAuditChanceReturn] = "我审核的机会-已退回"
}
//用户项
type UserItem struct {
Uid int64 `json:"uid"`
Name string `json:"name"`
}
//角色项
type Role struct {
Id int `json:"id"`
Name string `json:"name"`
}
... ...
... ... @@ -54,6 +54,15 @@ type UserInfoResponse struct {
User User `json:"user"`
}
//用户统计信息
/*UserStatistics */
type UserStatisticsRequest struct {
TypeTotal int64 `json:"typeTotal" valid:"Required"`
}
type UserStatisticsResponse struct {
Totals []TypeTotalItem `json:"totals"`
}
type User struct {
UserId int64 `json:"uid"`
Name string `json:"uname"`
... ... @@ -89,14 +98,6 @@ type Job struct {
Level int `json:"level"`
}
//用户统计信息
/*UserStatistics */
type UserStatisticsRequest struct {
TypeTotal int64 `json:"typeTotal" valid:"Required"`
}
type UserStatisticsResponse struct {
Totals []TypeTotalItem `json:"totals"`
}
type TypeTotalItem struct {
Type int64 `json:"type"` //类型
Total int `json:"total"` //总数
... ...
... ... @@ -20,3 +20,16 @@ func MyChanceStatic(header *protocol.RequestHeader, reviewStatus ...int8) (total
}
return
}
func MyApproveStatic(header *protocol.RequestHeader, reviewStatus ...int8) (total int, err error) {
var ()
if total, err = models.GetChanceMyApproveChance(header.UserId, header.CompanyId, reviewStatus, 0, 0, nil); err != nil {
if err == orm.ErrNoRows {
err = nil
return
}
log.Error(err)
return
}
return
}
... ...
... ... @@ -291,6 +291,11 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
err = protocol.NewErrWithMessage(5101)
return
}
if chance.EnableStatus == 0 {
log.Error(fmt.Sprintf("chance_id:%v enable_status:%v", chance.Id, chance.EnableStatus))
err = protocol.NewErrWithMessage(5101)
return
}
if process, err = models.GetAuditFlowProcessBy(request.ProcessId, header.UserId); err != nil {
log.Error(request.ProcessId, header.UserId, err)
err = protocol.NewErrWithMessage(5202)
... ... @@ -507,8 +512,10 @@ func ChanceApproveProcess(header *protocol.RequestHeader, chance *models.Chance)
checkApprovePermission(p)
//机会已经审核通过的直接添加到审核人列表
if chance.ReviewStatus == protocol.ReviewStatusPass {
if len(p.ApproveData) > 0 {
if e := json.Unmarshal([]byte(p.ApproveData), &item.ApproveData); e != nil {
log.Error(e)
log.Error("data", p.ApproveData, e)
}
}
rsp.ApproveProcess = append(rsp.ApproveProcess, item)
continue
... ...
... ... @@ -368,40 +368,67 @@ func UserStatistics(header *protocol.RequestHeader, request *protocol.UserStatis
total int
)
rsp = &protocol.UserStatisticsResponse{}
isMark := func(v int64) bool {
if flag != v {
return false
}
return (request.TypeTotal & v) > 0
}
for flag = 1; flag < (1 << 20); flag = flag << 1 {
//buf :=bytes.NewBuffer(nil)
//buf.WriteString(fmt.Sprintf("用户中心-统计信息 user:%v type_total:%v \n",header.UserId,request.TypeTotal))
for flag = 1; flag <= (protocol.MyAuditChanceReturn); flag = flag << 1 {
total = 0
if isMark(protocol.MyCommitChance) {
switch flag {
case protocol.MyCommitChance:
if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusAuditging, protocol.ReviewStatusReturn, protocol.ReviewStatusPass); err != nil {
log.Error(err)
}
}
if isMark(protocol.MyCommitChanceWait) {
break
case protocol.MyCommitChanceWait:
if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusAuditging); err != nil {
log.Error(err)
}
break
case protocol.MyCommitChancePass:
if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusPass); err != nil {
log.Error(err)
}
if isMark(protocol.MyAuditChanceReturn) {
break
case protocol.MyCommitChanceReturn:
if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusReturn); err != nil {
log.Error(err)
}
break
case protocol.MyAuditChance:
if total, err = agg.MyApproveStatic(header, protocol.ReviewStatusAuditging, protocol.ReviewStatusReturn, protocol.ReviewStatusPass); err != nil {
log.Error(err)
}
if isMark(protocol.MyCommitChancePass) {
if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusPass); err != nil {
break
case protocol.MyAuditChanceWait:
if total, err = agg.MyApproveStatic(header, protocol.ReviewStatusAuditging); err != nil {
log.Error(err)
}
break
case protocol.MyAuditChancePass:
if total, err = agg.MyApproveStatic(header, protocol.ReviewStatusPass); err != nil {
log.Error(err)
}
break
case protocol.MyAuditChanceReturn:
if total, err = agg.MyApproveStatic(header, protocol.ReviewStatusReturn); err != nil {
log.Error(err)
}
break
}
if flag&request.TypeTotal > 0 {
rsp.Totals = append(rsp.Totals, protocol.TypeTotalItem{
Type: flag,
Total: total,
})
log.Debug(fmt.Sprintf("用户中心-统计信息 user:%v name:%v type:%v total:%v ", header.UserId, protocol.MapStaticName[flag], flag, total))
//buf.WriteString(fmt.Sprintf("user:%v name:%v type:%v total:%v ",header.UserId,protocol.MapStaticName[flag],flag,total))
//if err!=nil{
// buf.WriteString("err:%v \n")
//}else{
// buf.WriteString("\n")
//}
}
}
//log.Debug(buf.String())
return
}
... ...