...
|
...
|
@@ -37,6 +37,7 @@ func BulletinRelease(uid, companyId int64, request *protocol.BulletinReleaseRequ |
|
|
CompanyId: companyId,
|
|
|
CreateAt: time.Now(),
|
|
|
UpdateAt: time.Now(),
|
|
|
Status: protocol.BulletinUnRelease,
|
|
|
}
|
|
|
|
|
|
orm := orm2.NewOrm()
|
...
|
...
|
@@ -55,6 +56,11 @@ func BulletinRelease(uid, companyId int64, request *protocol.BulletinReleaseRequ |
|
|
log.Error(err.Error())
|
|
|
return
|
|
|
}
|
|
|
if !(request.Question.Type == protocol.QuestionSingleSelect || request.Question.Type == protocol.QuestionMultiSelect) {
|
|
|
err = protocol.NewErrWithMessage("1")
|
|
|
log.Error("BulletinRelease:Question.Type error:%v", request.Question.Type)
|
|
|
return
|
|
|
}
|
|
|
bulletinQuestion = &models.BulletinQuestion{
|
|
|
BulletinId: int(id),
|
|
|
Type: int8(request.Question.Type),
|
...
|
...
|
@@ -86,6 +92,7 @@ func BulletinList(uid, companyId int64, request *protocol.BulletinListRequest) ( |
|
|
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 {
|
|
|
log.Error(err.Error())
|
|
|
return
|
...
|
...
|
@@ -93,16 +100,14 @@ func BulletinList(uid, companyId int64, request *protocol.BulletinListRequest) ( |
|
|
if len(list) == 0 {
|
|
|
return
|
|
|
}
|
|
|
rsp = &protocol.BulletinListResponse{}
|
|
|
rsp.Total = total
|
|
|
for i := range list {
|
|
|
bulletin := list[i]
|
|
|
item := &protocol.BulletinItem{
|
|
|
Id: bulletin.Id,
|
|
|
Type: bulletin.Type,
|
|
|
Title: bulletin.Title,
|
|
|
Status: int8(bulletin.Status),
|
|
|
//TODO:user
|
|
|
Receiver: []string{},
|
|
|
Id: bulletin.Id,
|
|
|
Type: bulletin.Type,
|
|
|
Title: bulletin.Title,
|
|
|
Status: int8(bulletin.Status),
|
|
|
CreateAt: bulletin.CreateAt.Format("2006-01-02 15:04:05"),
|
|
|
}
|
|
|
if item.Receiver, err = getUsersName(bulletin.Receiver); err != nil {
|
...
|
...
|
@@ -111,7 +116,7 @@ func BulletinList(uid, companyId int64, request *protocol.BulletinListRequest) ( |
|
|
}
|
|
|
rsp.List = append(rsp.List, item)
|
|
|
}
|
|
|
rsp.Total = total
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
...
|
...
|
@@ -131,13 +136,16 @@ func getUsers(idsstr string) (v []models.User, err error) { |
|
|
return models.GetUserNameByIds(ids)
|
|
|
}
|
|
|
|
|
|
func getUsersName(idsStr string) (v []string, err error) {
|
|
|
func getUsersName(idsStr string) (v []protocol.Receiver, err error) {
|
|
|
var users []models.User
|
|
|
if users, err = getUsers(idsStr); err != nil {
|
|
|
return
|
|
|
}
|
|
|
for i := range users {
|
|
|
v = append(v, users[i].NickName)
|
|
|
v = append(v, protocol.Receiver{
|
|
|
Id: users[i].Id,
|
|
|
NickName: users[i].NickName,
|
|
|
})
|
|
|
}
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -178,6 +186,7 @@ func GetBulletin(id int, companyId int64, request *protocol.GetBulletinRequest) |
|
|
}
|
|
|
rsp.QuestionSwitch = int(bulletin.QuestionSwitch)
|
|
|
rsp.Question = protocol.Question{
|
|
|
Id: question.Id,
|
|
|
Type: int(question.Type),
|
|
|
Title: question.Title,
|
|
|
}
|
...
|
...
|
@@ -238,12 +247,18 @@ func UpdateBulletin(companyId int64, request *protocol.UpdateBulletinRequest) (r |
|
|
log.Error(err.Error())
|
|
|
return
|
|
|
}
|
|
|
if bulletinQuestion.BulletinId != bulletin.Id {
|
|
|
err = protocol.NewErrWithMessage("1")
|
|
|
log.Error("UpdateBulletin:BulletinId not equal:(%v!=%v)", bulletinQuestion.BulletinId, bulletin.Id)
|
|
|
return
|
|
|
}
|
|
|
if questionContent, err = json.Marshal(request.Question.Content); err != nil {
|
|
|
log.Error(err.Error())
|
|
|
return
|
|
|
}
|
|
|
bulletinQuestion.Content = string(questionContent)
|
|
|
bulletinQuestion.Type = int8(request.Question.Type)
|
|
|
bulletinQuestion.UpdateAt = time.Now()
|
|
|
if err = models.UpdateBulletinQuestionById(bulletinQuestion); err != nil {
|
|
|
log.Error(err.Error())
|
|
|
return
|
...
|
...
|
|