...
|
...
|
@@ -162,21 +162,22 @@ func BulletinList(uid, companyId int64, request *protocol.BulletinListRequest) ( |
|
|
list []*models.Bulletin
|
|
|
total int
|
|
|
)
|
|
|
if request.Page == 0 {
|
|
|
request.Page = 1
|
|
|
if request.PageIndex == 0 {
|
|
|
request.PageIndex += 1
|
|
|
}
|
|
|
if request.PageSize == 0 {
|
|
|
request.PageSize = 20
|
|
|
}
|
|
|
rsp = &protocol.BulletinListResponse{}
|
|
|
if list, total, err = models.GetBulletins(companyId, request.Status, request.Page, request.PageSize); err != nil {
|
|
|
if list, total, err = models.GetBulletins(companyId, request.Status, request.PageIndex, request.PageSize); err != nil {
|
|
|
log.Error(err.Error())
|
|
|
return
|
|
|
}
|
|
|
if len(list) == 0 {
|
|
|
return
|
|
|
}
|
|
|
rsp.Total = total
|
|
|
rsp.TotalPage = total
|
|
|
rsp.CurrentPage = request.PageIndex
|
|
|
for i := range list {
|
|
|
bulletin := list[i]
|
|
|
item := &protocol.BulletinItem{
|
...
|
...
|
@@ -186,8 +187,8 @@ func BulletinList(uid, companyId int64, request *protocol.BulletinListRequest) ( |
|
|
Status: int8(bulletin.Status),
|
|
|
CreateAt: bulletin.CreateAt.Format("2006-01-02 15:04:05"),
|
|
|
}
|
|
|
if item.Receiver, err = getUsersName(bulletin.Receiver); err != nil {
|
|
|
log.Error(err.Error())
|
|
|
if item.Receiver, err = agg.GetVisibleObject(bulletin.Receiver); err != nil {
|
|
|
log.Error(bulletin.Receiver, err.Error())
|
|
|
continue
|
|
|
}
|
|
|
rsp.List = append(rsp.List, item)
|
...
|
...
|
@@ -374,7 +375,7 @@ func OperateBulletin(companyId int64, request *protocol.OperateBulletinRequest) |
|
|
orm.Begin()
|
|
|
if request.CmdType == protocol.BulletinUnRelease { //下架
|
|
|
status = protocol.BulletinUnRelease
|
|
|
if err = utils.ExecuteSQLWithOrmer(orm, models.DeleteUserMsgSql, companyId, models.MsgTypeBulletin, bulletin.Id); err != nil {
|
|
|
if err = utils.ExecuteSQLWithOrmer(orm, models.SqlDeleteUserMsg, companyId, models.MsgTypeBulletin, bulletin.Id); err != nil {
|
|
|
log.Error(err.Error())
|
|
|
orm.Rollback()
|
|
|
return
|
...
|
...
|
@@ -397,3 +398,57 @@ func OperateBulletin(companyId int64, request *protocol.OperateBulletinRequest) |
|
|
rsp = &protocol.OperateBulletinResponse{}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//反馈详情
|
|
|
func BulletinFeedbacks(companyId int64, request *protocol.BulletinFeedbacksRequest) (rsp *protocol.BulletinFeedbacksResponse, err error) {
|
|
|
type Feedback struct {
|
|
|
Answer string `orm:"column(answer);null" description:"答案"`
|
|
|
Uid int64 `orm:"column(uid);null" description:"用户id"`
|
|
|
UpdateAt time.Time `orm:"column(update_at);type(timestamp);null" description:"更新时间"`
|
|
|
NickName string `orm:"column(nick_name);size(100)" description:"昵称"`
|
|
|
}
|
|
|
var (
|
|
|
feedbacks []Feedback
|
|
|
total int
|
|
|
answer protocol.Answer
|
|
|
)
|
|
|
rsp = &protocol.BulletinFeedbacksResponse{}
|
|
|
if total, err = models.GetBulletinQuestionAnswers(request.PageIndex, request.PageSize, request.Id, &feedbacks); err != nil {
|
|
|
if err == orm2.ErrNoRows {
|
|
|
err = nil
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
rsp.CurrentPage = request.PageIndex
|
|
|
rsp.TotalPage = total
|
|
|
for i := range feedbacks {
|
|
|
tmp := feedbacks[i]
|
|
|
var content string
|
|
|
var other string
|
|
|
if err = json.Unmarshal([]byte(tmp.Answer), &answer); err != nil {
|
|
|
log.Error(err.Error())
|
|
|
continue
|
|
|
}
|
|
|
for i := range answer.VoteResults {
|
|
|
value := answer.VoteResults[i]
|
|
|
if value == -1 {
|
|
|
other = " 其他"
|
|
|
} else if value < 10 {
|
|
|
content += string(byte('A') + byte(value) - 1)
|
|
|
if i+1 < len(answer.VoteResults) {
|
|
|
content += ","
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
content = content + other
|
|
|
if len(answer.EditContent) != 0 {
|
|
|
content = fmt.Sprintf("%v (%v)", content, answer.EditContent)
|
|
|
}
|
|
|
rsp.List = append(rsp.List, protocol.FeedBackItem{
|
|
|
Time: tmp.UpdateAt.Unix(),
|
|
|
Name: tmp.NickName,
|
|
|
Content: content,
|
|
|
})
|
|
|
}
|
|
|
return
|
|
|
} |
...
|
...
|
|