正在显示
6 个修改的文件
包含
43 行增加
和
5 行删除
| @@ -19,7 +19,7 @@ mysql_db_name = "${MYSQL_DB_NAME||opportunity_dev}" | @@ -19,7 +19,7 @@ mysql_db_name = "${MYSQL_DB_NAME||opportunity_dev}" | ||
| 19 | ##redis相关配置 | 19 | ##redis相关配置 |
| 20 | redis_add = "${REDIS_HOST||127.0.0.1}" | 20 | redis_add = "${REDIS_HOST||127.0.0.1}" |
| 21 | redis_add_port = "${REDIS_PORT||6379}" | 21 | redis_add_port = "${REDIS_PORT||6379}" |
| 22 | -redis_auth = "" | 22 | +redis_auth = "123456" |
| 23 | ##log相关配置 | 23 | ##log相关配置 |
| 24 | ##out_put:"console","file" | 24 | ##out_put:"console","file" |
| 25 | log_output = "file" | 25 | log_output = "file" |
| @@ -24,6 +24,7 @@ type Bulletin struct { | @@ -24,6 +24,7 @@ type Bulletin struct { | ||
| 24 | //AllowCondition int8 `orm:"column(allow_condition);null" description:"关闭条件 (1(bit 0):公告内容查看完 2(bit 1):回答完问题)"` | 24 | //AllowCondition int8 `orm:"column(allow_condition);null" description:"关闭条件 (1(bit 0):公告内容查看完 2(bit 1):回答完问题)"` |
| 25 | CompanyId int64 `orm:"column(company_id);null" description:"公司Id"` | 25 | CompanyId int64 `orm:"column(company_id);null" description:"公司Id"` |
| 26 | Status int8 `orm:"column(status)" description:"状态 1-下架 2-上架"` | 26 | Status int8 `orm:"column(status)" description:"状态 1-下架 2-上架"` |
| 27 | + AllPeople int8 `orm:"column(all_people);null" description:"是否是所有人 0:否 1:是"` | ||
| 27 | } | 28 | } |
| 28 | 29 | ||
| 29 | func (t *Bulletin) TableName() string { | 30 | func (t *Bulletin) TableName() string { |
| @@ -143,3 +143,15 @@ func GetUserCompanyReal(ids []int64) ([]UserCompany, error) { | @@ -143,3 +143,15 @@ func GetUserCompanyReal(ids []int64) ([]UserCompany, error) { | ||
| 143 | All(&data) | 143 | All(&data) |
| 144 | return data, err | 144 | return data, err |
| 145 | } | 145 | } |
| 146 | + | ||
| 147 | +//获取公司的所有人员 | ||
| 148 | +func GetUserCompanyAll(companyId int64) (v []*UserCompany, err error) { | ||
| 149 | + o := orm.NewOrm() | ||
| 150 | + sql := `select a.*,b.nick_name from ( | ||
| 151 | +select id,user_id from user_company where company_id=? and enable=1 | ||
| 152 | +)a inner join user b on a.user_id = b.id` | ||
| 153 | + if _, err = o.Raw(sql, companyId).QueryRows(&v); err == nil { | ||
| 154 | + return v, nil | ||
| 155 | + } | ||
| 156 | + return nil, err | ||
| 157 | +} |
| @@ -20,7 +20,7 @@ type BulletinReleaseRequest struct { | @@ -20,7 +20,7 @@ type BulletinReleaseRequest struct { | ||
| 20 | //AllowCondition int `json:"allow_condition"` | 20 | //AllowCondition int `json:"allow_condition"` |
| 21 | QuestionSwitch int `json:"question_switch"` | 21 | QuestionSwitch int `json:"question_switch"` |
| 22 | Receiver []VisibleObject `json:"receiver"` | 22 | Receiver []VisibleObject `json:"receiver"` |
| 23 | - SendToAll int `json:"send_to_all"` //所有人 1:是 0:否 | 23 | + AllPeo int8 `json:"allPeo"` //所有人 1:是 0:否 |
| 24 | Question Question `json:"question"` | 24 | Question Question `json:"question"` |
| 25 | Cover Cover `json:"cover"` | 25 | Cover Cover `json:"cover"` |
| 26 | IsPublish int `json:"is_publish"` //是否直接发布 0:否 1:直接发布 | 26 | IsPublish int `json:"is_publish"` //是否直接发布 0:否 1:直接发布 |
| @@ -70,6 +70,7 @@ type GetBulletinResponse struct { | @@ -70,6 +70,7 @@ type GetBulletinResponse struct { | ||
| 70 | Title string `json:"title" valid:"Required"` | 70 | Title string `json:"title" valid:"Required"` |
| 71 | Content string `json:"content" valid:"Required"` | 71 | Content string `json:"content" valid:"Required"` |
| 72 | AllowClose int `json:"allow_close"` | 72 | AllowClose int `json:"allow_close"` |
| 73 | + AllPeo int8 `json:"allPeo"` //所有人 1:是 0:否 | ||
| 73 | //AllowCondition int `json:"allow_condition"` | 74 | //AllowCondition int `json:"allow_condition"` |
| 74 | QuestionSwitch int `json:"question_switch"` | 75 | QuestionSwitch int `json:"question_switch"` |
| 75 | Receiver []VisibleObject `json:"receiver" valid:"Required"` | 76 | Receiver []VisibleObject `json:"receiver" valid:"Required"` |
| @@ -90,10 +91,12 @@ type UpdateBulletinRequest struct { | @@ -90,10 +91,12 @@ type UpdateBulletinRequest struct { | ||
| 90 | Content string `json:"content" valid:"Required"` | 91 | Content string `json:"content" valid:"Required"` |
| 91 | AllowClose int `json:"allow_close"` | 92 | AllowClose int `json:"allow_close"` |
| 92 | //AllowCondition int `json:"allow_condition"` | 93 | //AllowCondition int `json:"allow_condition"` |
| 94 | + AllPeo int8 `json:"allPeo"` //所有人 1:是 0:否 | ||
| 93 | QuestionSwitch int `json:"question_switch"` | 95 | QuestionSwitch int `json:"question_switch"` |
| 94 | Receiver []VisibleObject `json:"receiver" valid:"Required"` | 96 | Receiver []VisibleObject `json:"receiver" valid:"Required"` |
| 95 | Question Question `json:"question"` | 97 | Question Question `json:"question"` |
| 96 | Cover Cover `json:"cover" valid:"Required"` | 98 | Cover Cover `json:"cover" valid:"Required"` |
| 99 | + IsPublish int `json:"is_publish"` //是否直接发布 0:否 1:直接发布 | ||
| 97 | } | 100 | } |
| 98 | type UpdateBulletinResponse struct { | 101 | type UpdateBulletinResponse struct { |
| 99 | } | 102 | } |
| @@ -160,10 +160,12 @@ func TemplateUpdate(uid, companyId int64, request *protocol.TemplateUpdateReques | @@ -160,10 +160,12 @@ func TemplateUpdate(uid, companyId int64, request *protocol.TemplateUpdateReques | ||
| 160 | log.Error("template_id:%v 不存在 ,err:%v", request.Template.Id, err.Error()) | 160 | log.Error("template_id:%v 不存在 ,err:%v", request.Template.Id, err.Error()) |
| 161 | return | 161 | return |
| 162 | } | 162 | } |
| 163 | + if template.Name != request.Template.Name { | ||
| 163 | if _, err = models.GetAuditTemplateByName(companyId, request.Template.Name); err == nil { | 164 | if _, err = models.GetAuditTemplateByName(companyId, request.Template.Name); err == nil { |
| 164 | err = protocol.NewErrWithMessage("10271") | 165 | err = protocol.NewErrWithMessage("10271") |
| 165 | return | 166 | return |
| 166 | } | 167 | } |
| 168 | + } | ||
| 167 | orm := orm2.NewOrm() | 169 | orm := orm2.NewOrm() |
| 168 | //模板 | 170 | //模板 |
| 169 | { | 171 | { |
| @@ -45,6 +45,7 @@ func BulletinRelease(uid, companyId int64, request *protocol.BulletinReleaseRequ | @@ -45,6 +45,7 @@ func BulletinRelease(uid, companyId int64, request *protocol.BulletinReleaseRequ | ||
| 45 | CreateAt: time.Now(), | 45 | CreateAt: time.Now(), |
| 46 | UpdateAt: time.Now(), | 46 | UpdateAt: time.Now(), |
| 47 | Status: status, | 47 | Status: status, |
| 48 | + AllPeople: request.AllPeo, | ||
| 48 | } | 49 | } |
| 49 | 50 | ||
| 50 | orm := orm2.NewOrm() | 51 | orm := orm2.NewOrm() |
| @@ -85,7 +86,7 @@ func BulletinRelease(uid, companyId int64, request *protocol.BulletinReleaseRequ | @@ -85,7 +86,7 @@ func BulletinRelease(uid, companyId int64, request *protocol.BulletinReleaseRequ | ||
| 85 | } | 86 | } |
| 86 | //TODO:发送公告消息 | 87 | //TODO:发送公告消息 |
| 87 | if request.IsPublish == 1 { | 88 | if request.IsPublish == 1 { |
| 88 | - if err = sendBulletinUserMsg(orm, request.Receiver, companyId, int64(id), bulletin.Title); err != nil { | 89 | + if err = sendBulletinUserMsg(orm, request.Receiver, companyId, int64(id), bulletin.Title, request.AllPeo); err != nil { |
| 89 | log.Error(err.Error()) | 90 | log.Error(err.Error()) |
| 90 | orm.Rollback() | 91 | orm.Rollback() |
| 91 | return | 92 | return |
| @@ -136,14 +137,24 @@ func getBulletinReceiverIds(orm orm2.Ormer, receivers []protocol.VisibleObject, | @@ -136,14 +137,24 @@ func getBulletinReceiverIds(orm orm2.Ormer, receivers []protocol.VisibleObject, | ||
| 136 | } | 137 | } |
| 137 | 138 | ||
| 138 | //发送公告消息 | 139 | //发送公告消息 |
| 139 | -func sendBulletinUserMsg(orm orm2.Ormer, receivers []protocol.VisibleObject, companyId int64, sourceId int64, message string) (err error) { | 140 | +func sendBulletinUserMsg(orm orm2.Ormer, receivers []protocol.VisibleObject, companyId int64, sourceId int64, message string, allPeople int8) (err error) { |
| 140 | var ( | 141 | var ( |
| 141 | ids []int64 | 142 | ids []int64 |
| 142 | sended = make(map[int64]int64) | 143 | sended = make(map[int64]int64) |
| 143 | ) | 144 | ) |
| 145 | + if allPeople == 1 { | ||
| 146 | + if userCompanys, e := models.GetUserCompanyAll(companyId); e == nil { | ||
| 147 | + for i := range userCompanys { | ||
| 148 | + ids = append(ids, userCompanys[i].Id) | ||
| 149 | + } | ||
| 150 | + } else { | ||
| 151 | + log.Error("%v %v", companyId, e.Error()) | ||
| 152 | + } | ||
| 153 | + } else { | ||
| 144 | if ids, err = getBulletinReceiverIds(orm, receivers, companyId, sourceId, message); err != nil { | 154 | if ids, err = getBulletinReceiverIds(orm, receivers, companyId, sourceId, message); err != nil { |
| 145 | return | 155 | return |
| 146 | } | 156 | } |
| 157 | + } | ||
| 147 | for i := range ids { | 158 | for i := range ids { |
| 148 | if _, ok := sended[ids[i]]; ok { | 159 | if _, ok := sended[ids[i]]; ok { |
| 149 | continue | 160 | continue |
| @@ -256,6 +267,7 @@ func GetBulletin(id int, companyId int64, request *protocol.GetBulletinRequest) | @@ -256,6 +267,7 @@ func GetBulletin(id int, companyId int64, request *protocol.GetBulletinRequest) | ||
| 256 | Title: bulletin.Title, | 267 | Title: bulletin.Title, |
| 257 | Content: bulletin.Content, | 268 | Content: bulletin.Content, |
| 258 | AllowClose: int(bulletin.AllowClose), | 269 | AllowClose: int(bulletin.AllowClose), |
| 270 | + AllPeo: bulletin.AllPeople, | ||
| 259 | //AllowCondition: int(bulletin.AllowCondition), | 271 | //AllowCondition: int(bulletin.AllowCondition), |
| 260 | Cover: protocol.Cover(bulletin.Cover), | 272 | Cover: protocol.Cover(bulletin.Cover), |
| 261 | Question: protocol.Question{ | 273 | Question: protocol.Question{ |
| @@ -377,6 +389,14 @@ func UpdateBulletin(companyId int64, request *protocol.UpdateBulletinRequest) (r | @@ -377,6 +389,14 @@ func UpdateBulletin(companyId int64, request *protocol.UpdateBulletinRequest) (r | ||
| 377 | } | 389 | } |
| 378 | 390 | ||
| 379 | } | 391 | } |
| 392 | + orm := orm2.NewOrm() | ||
| 393 | + if request.IsPublish == 1 && bulletin.Status == protocol.BulletinUnRelease { | ||
| 394 | + if err = sendBulletinUserMsg(orm, request.Receiver, companyId, int64(bulletin.Id), bulletin.Title, request.AllPeo); err != nil { | ||
| 395 | + log.Error(err.Error()) | ||
| 396 | + orm.Rollback() | ||
| 397 | + return | ||
| 398 | + } | ||
| 399 | + } | ||
| 380 | return | 400 | return |
| 381 | } | 401 | } |
| 382 | 402 | ||
| @@ -419,7 +439,7 @@ func OperateBulletin(companyId int64, request *protocol.OperateBulletinRequest) | @@ -419,7 +439,7 @@ func OperateBulletin(companyId int64, request *protocol.OperateBulletinRequest) | ||
| 419 | } | 439 | } |
| 420 | if request.CmdType == protocol.BulletinRelease { //上架 | 440 | if request.CmdType == protocol.BulletinRelease { //上架 |
| 421 | status = protocol.BulletinRelease | 441 | status = protocol.BulletinRelease |
| 422 | - if err = sendBulletinUserMsg(orm, receiver, companyId, int64(bulletin.Id), bulletin.Title); err != nil { | 442 | + if err = sendBulletinUserMsg(orm, receiver, companyId, int64(bulletin.Id), bulletin.Title, bulletin.AllPeople); err != nil { |
| 423 | log.Error(err.Error()) | 443 | log.Error(err.Error()) |
| 424 | orm.Rollback() | 444 | orm.Rollback() |
| 425 | return | 445 | return |
-
请 注册 或 登录 后发表评论