作者 yangfu

成果详情

[dev]
#数据库相关
mysql_user = "${MYSQL_USER||root}"
mysql_password = "${MYSQL_PASSWORD||sutianxia2015}"
mysql_host = "${MYSQL_HOST||115.29.205.99}"
mysql_password = "${MYSQL_PASSWORD||sutianxia2018}"
mysql_host = "${MYSQL_HOST||101.37.68.23}"
mysql_port = "${MYSQL_PORT||3306}"
mysql_db_name = "${MYSQL_DB_NAME||opportunity}"
mysql_db_name = "${MYSQL_DB_NAME||opportunity_dev}"
#日志
log_level = "${LOG_LEVEL||debug}"
... ...
... ... @@ -27,7 +27,7 @@ type Achievement struct {
}
func (t *Achievement) TableName() string {
return "new_achievement"
return "achievement"
}
func init() {
... ... @@ -69,20 +69,20 @@ func UpdateAchievementById(m *Achievement) (err error) {
func GetAchievementAll(uid, cid int64, chanceTypeId int, lastId int64, departmentId int, pageSize int, v interface{}) (total int, err error) {
var whereString bytes.Buffer
if departmentId > 0 {
whereString.WriteString(fmt.Sprintf(` and %v in (select department_id from user_department where user_company_id=achievement.user_company_id and enable_status=1) `, departmentId))
}
if uid > 0 {
whereString.WriteString(fmt.Sprintf(` and user_company_id=%v `, uid))
}
sql := fmt.Sprintf(`
select id,user_company_id,create_at,source_content,audit_template_id,chance_type_id,grasp_score,user_grasp_score,comment_total,zan_total,view_total,images from new_achievement
select id,user_company_id,create_at,source_content,audit_template_id,chance_type_id,grasp_score,user_grasp_score,comment_total,zan_total,view_total,images from achievement
where company_id=%v and (%v=0 or id<%v) and (%v=0 or chance_type_id =%v) and status=1 %v
order by create_at desc
limit %v
`, cid, lastId, lastId, chanceTypeId, chanceTypeId, whereString.String(), pageSize)
sqlCount := fmt.Sprintf(`
select count(0) from new_achievement
select count(0) from achievement
where company_id=%v and (%v=0 or chance_type_id =%v) and status=1 %v
`, cid, chanceTypeId, chanceTypeId, whereString.String())
... ... @@ -100,7 +100,7 @@ where company_id=%v and (%v=0 or chance_type_id =%v) and status=1 %v
//成果详情
func GetCommAchievementItemOrmId(id int64, v interface{}) (err error) {
o := orm.NewOrm()
sql := "select * from new_achievement where id=?"
sql := "select * from achievement where id=?"
if _, err = o.Raw(sql, id).QueryRows(v); err == nil {
return nil
}
... ...
... ... @@ -15,7 +15,7 @@ type AchievementChance struct {
}
func (t *AchievementChance) TableName() string {
return "new_achievement_chance"
return "achievement_chance"
}
func init() {
... ... @@ -32,3 +32,19 @@ func GetAchievementChanceById(id int64) (v *AchievementChance, err error) {
}
return nil, err
}
//查询成果提供者列表
func GetAchievementChances(achievementId int64, v interface{}) (err error) {
o := orm.NewOrm()
sql := `select a.*,b.images,speechs,videos
from (
select chance_id,b.user_id chance_user_id,approve_time create_at,source_content,enable_status,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,publish_status,status
from achievement_chance a inner join chance b on a.chance_id=b.id where achievement_id=? and b.review_status=3
) a left JOIN chance_data b on a.chance_id =b.chance_id
order by a.create_at desc
`
if _, err = o.Raw(sql, achievementId).QueryRows(v); err == nil {
return nil
}
return err
}
... ...
... ... @@ -15,7 +15,7 @@ type AchievementProvider struct {
}
func (t *AchievementProvider) TableName() string {
return "new_achievement_provider"
return "achievement_provider"
}
func init() {
... ... @@ -36,7 +36,7 @@ func GetAchievementProviderById(id int64) (v *AchievementProvider, err error) {
//查询成果提供者列表
func GetAchievementProviders(achievementId int64) (v []*AchievementProvider, err error) {
o := orm.NewOrm()
sql := "select * from new_achievement_provider where achievement_id=?"
sql := "select * from achievement_provider where achievement_id=?"
if _, err = o.Raw(sql, achievementId).QueryRows(&v); err == nil {
return v, nil
}
... ...
... ... @@ -97,11 +97,11 @@ type AchievementDetailResponse struct {
Achievement AchievementItem `json:"achievement,omitempty"` //成果详情
StatisticData interface{} `json:"statisticData,omitempty"` //统计数据(是否收藏/点赞 浏览数 点赞总数 评论数
//模板
ChanceType interface{} `json:"chanceType,omitempty"` //机会类型
ChanceTemplate interface{} `json:"template,omitempty"` //机会模板
Status int `json:"-"` //0:删除 1:开启 2:关闭
SourceChance []ChanceItem `json:"sourceChance"` //机会来源
Participants []UserGraspInfo //参与人
ChanceType interface{} `json:"chanceType,omitempty"` //机会类型
ChanceTemplate interface{} `json:"template,omitempty"` //机会模板
Status int `json:"-"` //0:删除 1:开启 2:关闭
SourceChance []*CommonListItem `json:"sourceChance"` //机会来源
Participants []UserGraspInfo `json:"participants"` //参与人
}
type UserGraspInfo struct {
... ... @@ -109,3 +109,10 @@ type UserGraspInfo struct {
GraspScore float64 `json:"graspScore"` //把握分
Type int `json:"type"` //1:把握人 2:提供者
}
type SourceChanceItemOrm struct {
CommChanceItemOrm
TemplateId int `orm:"column(audit_template_id)"`
ChanceTypeId int `orm:"column(chance_type_id)"`
}
... ...
... ... @@ -514,11 +514,11 @@ type CommonListItem struct {
CommentedData interface{} `json:"commentedData,omitempty"`
SourceType int `json:"sourceType,omitempty"` //类型 1:机会 2:评论
ChanceStatus int `json:"chanceStatus"` //0:正常 1.删除 2.关闭
Status int `json:"-"` //1:开启 2:关闭
ReviewStatus int `json:"reviewStatus"` //审核状态
ChanceStatus int `json:"chanceStatus"` //0:正常 1.删除 2.关闭
Status int `json:"-"` //1:开启 2:关闭
ReviewStatus int `json:"reviewStatus,omitempty"` //审核状态
ChanceId int64 `json:"chanceId"` //机会编号
ChanceId int64 `json:"chanceId,omitempty"` //机会编号
}
type MsgCommonListItem struct {
... ...
... ... @@ -95,6 +95,7 @@ func AchievementDetail(header *protocol.RequestHeader, request *protocol.Achieve
var (
items []protocol.CommAchievementItemOrm
participants []*models.AchievementProvider
chances []protocol.SourceChanceItemOrm
)
if err = models.GetCommAchievementItemOrmId(request.Id, &items); err != nil {
log.Error(err)
... ... @@ -145,7 +146,50 @@ func AchievementDetail(header *protocol.RequestHeader, request *protocol.Achieve
//查看数量
utils.ExecuteSqlByRoll(true, agg.GetIncrementSql((&models.Achievement{}).TableName(), "view_total", 1, request.Id))
if err = models.GetAchievementChances(request.Id, &chances); err != nil {
log.Error(err)
return
}
for i := range chances {
chance := chances[i]
commItem := &protocol.CommonListItem{}
commItem.Chance, commItem.ChanceStatus = SetChanceItem(header, chance.CommChanceItemOrm)
//commItem.ChanceTemplate = getTemplate(chance.TemplateId)
//commItem.ChanceType = getChanceType(chance.ChanceTypeId)
commItem.ChanceId = chance.ChanceId
rsp.SourceChance = append(rsp.SourceChance, commItem)
}
agg.ValidChancePermission(header.UserId, header.CompanyId, rsp.SourceChance)
return
}
//func GetSourceChance(header )
//设置机会详情
func SetChanceItem(header *protocol.RequestHeader, chance protocol.CommChanceItemOrm) (item protocol.ChanceItem, chanceStatus int) {
var provider *protocol.BaseUserInfo
var err error
if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil {
chanceStatus = protocol.ChanceStatusDelete
log.Error(err)
return
}
if len(chance.SourceContent) == 0 || chance.ChanceEnableStatus == 0 { //机会删除
chanceStatus = protocol.ChanceStatusDelete
}
if chance.Status == models.ChanceStatusClose { //机会关闭
chanceStatus = protocol.ChanceStatusClose
return
}
item = protocol.ChanceItem{
Id: chance.ChanceId,
Provider: provider,
CreateTime: chance.CreateTime.Unix() * 1000,
//PublicStatus: chance.PublishStatus,
}
jsonUnmarshal(chance.SourceContent, &item.FormList)
item.FormList = clearEmptyForm(item.FormList)
jsonUnmarshal(chance.Images, &item.Pictures)
jsonUnmarshal(chance.Voices, &item.Speechs)
jsonUnmarshal(chance.Videos, &item.Videos)
return item, chanceStatus
}
... ...