...
|
...
|
@@ -45,6 +45,7 @@ func BulletinRelease(uid, companyId int64, request *protocol.BulletinReleaseRequ |
|
|
CreateAt: time.Now(),
|
|
|
UpdateAt: time.Now(),
|
|
|
Status: status,
|
|
|
AllPeople: request.AllPeo,
|
|
|
}
|
|
|
|
|
|
orm := orm2.NewOrm()
|
...
|
...
|
@@ -85,7 +86,7 @@ func BulletinRelease(uid, companyId int64, request *protocol.BulletinReleaseRequ |
|
|
}
|
|
|
//TODO:发送公告消息
|
|
|
if request.IsPublish == 1 {
|
|
|
if err = sendBulletinUserMsg(orm, request.Receiver, companyId, int64(id), bulletin.Title); err != nil {
|
|
|
if err = sendBulletinUserMsg(orm, request.Receiver, companyId, int64(id), bulletin.Title, request.AllPeo); err != nil {
|
|
|
log.Error(err.Error())
|
|
|
orm.Rollback()
|
|
|
return
|
...
|
...
|
@@ -136,14 +137,24 @@ func getBulletinReceiverIds(orm orm2.Ormer, receivers []protocol.VisibleObject, |
|
|
}
|
|
|
|
|
|
//发送公告消息
|
|
|
func sendBulletinUserMsg(orm orm2.Ormer, receivers []protocol.VisibleObject, companyId int64, sourceId int64, message string) (err error) {
|
|
|
func sendBulletinUserMsg(orm orm2.Ormer, receivers []protocol.VisibleObject, companyId int64, sourceId int64, message string, allPeople int8) (err error) {
|
|
|
var (
|
|
|
ids []int64
|
|
|
sended = make(map[int64]int64)
|
|
|
)
|
|
|
if allPeople == 1 {
|
|
|
if userCompanys, e := models.GetUserCompanyAll(companyId); e == nil {
|
|
|
for i := range userCompanys {
|
|
|
ids = append(ids, userCompanys[i].Id)
|
|
|
}
|
|
|
} else {
|
|
|
log.Error("%v %v", companyId, e.Error())
|
|
|
}
|
|
|
} else {
|
|
|
if ids, err = getBulletinReceiverIds(orm, receivers, companyId, sourceId, message); err != nil {
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
for i := range ids {
|
|
|
if _, ok := sended[ids[i]]; ok {
|
|
|
continue
|
...
|
...
|
@@ -256,6 +267,7 @@ func GetBulletin(id int, companyId int64, request *protocol.GetBulletinRequest) |
|
|
Title: bulletin.Title,
|
|
|
Content: bulletin.Content,
|
|
|
AllowClose: int(bulletin.AllowClose),
|
|
|
AllPeo: bulletin.AllPeople,
|
|
|
//AllowCondition: int(bulletin.AllowCondition),
|
|
|
Cover: protocol.Cover(bulletin.Cover),
|
|
|
Question: protocol.Question{
|
...
|
...
|
@@ -377,6 +389,14 @@ func UpdateBulletin(companyId int64, request *protocol.UpdateBulletinRequest) (r |
|
|
}
|
|
|
|
|
|
}
|
|
|
orm := orm2.NewOrm()
|
|
|
if request.IsPublish == 1 && bulletin.Status == protocol.BulletinUnRelease {
|
|
|
if err = sendBulletinUserMsg(orm, request.Receiver, companyId, int64(bulletin.Id), bulletin.Title, request.AllPeo); err != nil {
|
|
|
log.Error(err.Error())
|
|
|
orm.Rollback()
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
...
|
...
|
@@ -419,7 +439,7 @@ func OperateBulletin(companyId int64, request *protocol.OperateBulletinRequest) |
|
|
}
|
|
|
if request.CmdType == protocol.BulletinRelease { //上架
|
|
|
status = protocol.BulletinRelease
|
|
|
if err = sendBulletinUserMsg(orm, receiver, companyId, int64(bulletin.Id), bulletin.Title); err != nil {
|
|
|
if err = sendBulletinUserMsg(orm, receiver, companyId, int64(bulletin.Id), bulletin.Title, bulletin.AllPeople); err != nil {
|
|
|
log.Error(err.Error())
|
|
|
orm.Rollback()
|
|
|
return
|
...
|
...
|
|