正在显示
10 个修改的文件
包含
163 行增加
和
26 行删除
@@ -69,7 +69,7 @@ func (this *BulletinController) BulletinList() { | @@ -69,7 +69,7 @@ func (this *BulletinController) BulletinList() { | ||
69 | return | 69 | return |
70 | } | 70 | } |
71 | rsp, err := bulletin.BulletinList(uid, companyId, request) | 71 | rsp, err := bulletin.BulletinList(uid, companyId, request) |
72 | - msg = protocol.NewReturnResponse(rsp, err) | 72 | + msg = protocol.NewPageDataResponse(rsp, err) |
73 | } | 73 | } |
74 | 74 | ||
75 | //GetBulletin | 75 | //GetBulletin |
@@ -149,3 +149,29 @@ func (this *BulletinController) OperateBulletin() { | @@ -149,3 +149,29 @@ func (this *BulletinController) OperateBulletin() { | ||
149 | rsp, err := bulletin.OperateBulletin(companyId, request) | 149 | rsp, err := bulletin.OperateBulletin(companyId, request) |
150 | msg = protocol.NewReturnResponse(rsp, err) | 150 | msg = protocol.NewReturnResponse(rsp, err) |
151 | } | 151 | } |
152 | + | ||
153 | +//BulletinFeedbacks 反馈详情 | ||
154 | +//@router /bulletinFeedbacks [post] | ||
155 | +func (this *BulletinController) BulletinFeedbacks() { | ||
156 | + var msg *protocol.ResponseMessage | ||
157 | + defer func() { | ||
158 | + this.ResposeJson(msg) | ||
159 | + }() | ||
160 | + var request *protocol.BulletinFeedbacksRequest | ||
161 | + if err := json.Unmarshal(this.Ctx.Input.RequestBody, &request); err != nil { | ||
162 | + log.Error("json 解析失败", err) | ||
163 | + msg = protocol.BadRequestParam("1") | ||
164 | + return | ||
165 | + } | ||
166 | + if b, m := this.Valid(request); !b { | ||
167 | + msg = m | ||
168 | + return | ||
169 | + } | ||
170 | + companyId := this.GetCompanyId() | ||
171 | + if companyId <= 0 { | ||
172 | + msg = protocol.BadRequestParam("1") | ||
173 | + return | ||
174 | + } | ||
175 | + rsp, err := bulletin.BulletinFeedbacks(companyId, request) | ||
176 | + msg = protocol.NewPageDataResponse(rsp, err) | ||
177 | +} |
@@ -14,6 +14,7 @@ type AuditTemplate struct { | @@ -14,6 +14,7 @@ type AuditTemplate struct { | ||
14 | Name string `orm:"column(name);size(20)" description:"子分类名称"` | 14 | Name string `orm:"column(name);size(20)" description:"子分类名称"` |
15 | Doc string `orm:"column(doc);size(255)" description:"说明"` | 15 | Doc string `orm:"column(doc);size(255)" description:"说明"` |
16 | Icon string `orm:"column(icon);size(255)" description:"图标"` | 16 | Icon string `orm:"column(icon);size(255)" description:"图标"` |
17 | + Code string `orm:"column(code);size(50)" description:"编码"` | ||
17 | NoticeType int8 `orm:"column(notice_type)" description:"通知方式"` | 18 | NoticeType int8 `orm:"column(notice_type)" description:"通知方式"` |
18 | NoApprover int8 `orm:"column(no_approver)" description:"审核人空时:【1:自动通过】【2:转交给管理员】"` | 19 | NoApprover int8 `orm:"column(no_approver)" description:"审核人空时:【1:自动通过】【2:转交给管理员】"` |
19 | SortNum int `orm:"column(sort_num)" description:"自定义排序编号"` | 20 | SortNum int `orm:"column(sort_num)" description:"自定义排序编号"` |
@@ -2,6 +2,7 @@ package models | @@ -2,6 +2,7 @@ package models | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "oppmg/utils" | ||
5 | "time" | 6 | "time" |
6 | 7 | ||
7 | "github.com/astaxie/beego/orm" | 8 | "github.com/astaxie/beego/orm" |
@@ -73,3 +74,29 @@ func DeleteBulletinQuestionAnswer(id int) (err error) { | @@ -73,3 +74,29 @@ func DeleteBulletinQuestionAnswer(id int) (err error) { | ||
73 | } | 74 | } |
74 | return | 75 | return |
75 | } | 76 | } |
77 | + | ||
78 | +func GetBulletinQuestionAnswers(page, pageSize int, id int, v interface{}) (total int, err error) { | ||
79 | + sql := `select b.*,a.nick_name ` | ||
80 | + where := ` from user a INNER JOIN ( | ||
81 | +select b.*,a.user_id from user_company a INNER JOIN ( | ||
82 | +select answer,update_at,uid from bulletin_question_answer where bulletin_id =? order by update_at desc | ||
83 | +)b on a.id = b.uid | ||
84 | +) b on a.id = b.user_id ` | ||
85 | + sqlCount := `select count(0) ` | ||
86 | + sqlCount += where | ||
87 | + | ||
88 | + sql += where | ||
89 | + sql += ` limit ?,?` | ||
90 | + if v != nil { | ||
91 | + if err = utils.ExecuteQueryOne(&total, sqlCount, id); err != nil { | ||
92 | + return | ||
93 | + } | ||
94 | + } | ||
95 | + if page == 0 { | ||
96 | + page = 1 | ||
97 | + } | ||
98 | + if err = utils.ExecuteQueryAll(v, sql, id, (page-1)*pageSize, pageSize); err != nil { | ||
99 | + return | ||
100 | + } | ||
101 | + return | ||
102 | +} |
@@ -11,6 +11,7 @@ type ChanceType struct { | @@ -11,6 +11,7 @@ type ChanceType struct { | ||
11 | Id int `orm:"column(id);auto"` | 11 | Id int `orm:"column(id);auto"` |
12 | Name string `orm:"column(name);size(50)" description:"机会类型名称"` | 12 | Name string `orm:"column(name);size(50)" description:"机会类型名称"` |
13 | Icon string `orm:"column(icon);size(500);null" description:"图标地址"` | 13 | Icon string `orm:"column(icon);size(500);null" description:"图标地址"` |
14 | + Code string `orm:"column(code);size(50)" description:"编码"` | ||
14 | CompanyId int `orm:"column(company_id)" description:"表company.id 公司编号"` | 15 | CompanyId int `orm:"column(company_id)" description:"表company.id 公司编号"` |
15 | SortNum int `orm:"column(sort_num);null" description:"序号 公司下的序号"` | 16 | SortNum int `orm:"column(sort_num);null" description:"序号 公司下的序号"` |
16 | CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间 "` | 17 | CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间 "` |
@@ -34,7 +34,7 @@ const ( | @@ -34,7 +34,7 @@ const ( | ||
34 | ) | 34 | ) |
35 | 35 | ||
36 | const ( | 36 | const ( |
37 | - DeleteUserMsgSql = "delete from user_msg where company_id=? and msg_type=? and source_id=?" | 37 | + SqlDeleteUserMsg = "delete from user_msg where company_id=? and msg_type=? and source_id=?" |
38 | ) | 38 | ) |
39 | 39 | ||
40 | func (t *UserMsg) TableName() string { | 40 | func (t *UserMsg) TableName() string { |
@@ -86,12 +86,13 @@ type TemplateAddResponse struct { | @@ -86,12 +86,13 @@ type TemplateAddResponse struct { | ||
86 | } | 86 | } |
87 | 87 | ||
88 | type Template struct { | 88 | type Template struct { |
89 | - Id int64 `json:"id"` //创建时 0 | ||
90 | - ChanceTypeId int `json:"chanceTypeId"` //机会类型编号 | ||
91 | - Name string `json:"name"` | ||
92 | - Doc string `json:"doc"` | ||
93 | - Icon string `json:"icon"` | ||
94 | - InputList []*InputElement `json:"inputList"` | 89 | + Id int64 `json:"id"` //创建时 0 |
90 | + Code string `json:"code" valid:"Required; MaxSize(6)"` | ||
91 | + ChanceTypeId int `json:"chanceTypeId" valid:"Required;"` //机会类型编号 | ||
92 | + Name string `json:"name" valid:"Required;"` | ||
93 | + Doc string `json:"doc" valid:"Required;"` | ||
94 | + Icon string `json:"icon" valid:"Required;"` | ||
95 | + InputList []*InputElement `json:"inputList" valid:"Required;"` | ||
95 | } | 96 | } |
96 | 97 | ||
97 | /*TemplateUpdate */ | 98 | /*TemplateUpdate */ |
@@ -107,6 +108,7 @@ type TemplateListRequest struct { | @@ -107,6 +108,7 @@ type TemplateListRequest struct { | ||
107 | } | 108 | } |
108 | type TemplateListResponse struct { | 109 | type TemplateListResponse struct { |
109 | List []*TemplateList `json:"list"` | 110 | List []*TemplateList `json:"list"` |
111 | + //ResponsePageInfo | ||
110 | } | 112 | } |
111 | 113 | ||
112 | type TemplateList struct { | 114 | type TemplateList struct { |
@@ -145,6 +147,7 @@ type TemplateEditVisibleResponse struct { | @@ -145,6 +147,7 @@ type TemplateEditVisibleResponse struct { | ||
145 | type TemplateOperateCategoryRequest struct { | 147 | type TemplateOperateCategoryRequest struct { |
146 | Id int `json:"id"` | 148 | Id int `json:"id"` |
147 | Name string `json:"name"` | 149 | Name string `json:"name"` |
150 | + Code string `json:"code"` | ||
148 | Icon string `json:"icon"` | 151 | Icon string `json:"icon"` |
149 | } | 152 | } |
150 | type TemplateOperateCategoryResponse struct { | 153 | type TemplateOperateCategoryResponse struct { |
@@ -44,22 +44,22 @@ type BulletinReleaseResponse struct { | @@ -44,22 +44,22 @@ type BulletinReleaseResponse struct { | ||
44 | 44 | ||
45 | /*BulletinList */ | 45 | /*BulletinList */ |
46 | type BulletinListRequest struct { | 46 | type BulletinListRequest struct { |
47 | - Status int8 `json:"status"` //1:待上架 2:上架 | ||
48 | - Page int `json:"page"` | ||
49 | - PageSize int `json:"pageSize"` | 47 | + Status int8 `json:"status"` //1:待上架 2:上架 |
48 | + RequestPageInfo | ||
50 | } | 49 | } |
51 | type BulletinListResponse struct { | 50 | type BulletinListResponse struct { |
52 | - List []*BulletinItem `json:"list"` | ||
53 | - Total int | 51 | + List []*BulletinItem `json:"list"` |
52 | + //Total int | ||
53 | + ResponsePageInfo | ||
54 | } | 54 | } |
55 | 55 | ||
56 | type BulletinItem struct { | 56 | type BulletinItem struct { |
57 | - Id int `json:"id"` | ||
58 | - Type int8 `json:"type"` | ||
59 | - Title string `json:"title"` | ||
60 | - Status int8 `json:"status"` | ||
61 | - Receiver []Receiver `json:"receiver" valid:"Required"` | ||
62 | - CreateAt string `json:"time"` | 57 | + Id int `json:"id"` |
58 | + Type int8 `json:"type"` | ||
59 | + Title string `json:"title"` | ||
60 | + Status int8 `json:"status"` | ||
61 | + Receiver []VisibleObject `json:"receiver" valid:"Required"` | ||
62 | + CreateAt string `json:"time"` | ||
63 | } | 63 | } |
64 | 64 | ||
65 | /*GetBulletin */ | 65 | /*GetBulletin */ |
@@ -107,3 +107,24 @@ type OperateBulletinRequest struct { | @@ -107,3 +107,24 @@ type OperateBulletinRequest struct { | ||
107 | } | 107 | } |
108 | type OperateBulletinResponse struct { | 108 | type OperateBulletinResponse struct { |
109 | } | 109 | } |
110 | + | ||
111 | +/*BulletinFeedbacks 反馈详情*/ | ||
112 | +type BulletinFeedbacksRequest struct { | ||
113 | + RequestPageInfo | ||
114 | + Id int `json:"id" valid:"Required"` //公告编号 | ||
115 | +} | ||
116 | +type BulletinFeedbacksResponse struct { | ||
117 | + ResponsePageInfo | ||
118 | + List []FeedBackItem `json:"list"` | ||
119 | +} | ||
120 | + | ||
121 | +type FeedBackItem struct { | ||
122 | + Time int64 `json:"time"` | ||
123 | + Name string `json:"name"` | ||
124 | + Content string `json:"content"` | ||
125 | +} | ||
126 | + | ||
127 | +type Answer struct { | ||
128 | + VoteResults []int `json:"voteResults"` | ||
129 | + EditContent string `json:"editContent"` | ||
130 | +} |
@@ -51,6 +51,7 @@ func init() { | @@ -51,6 +51,7 @@ func init() { | ||
51 | beego.NSRouter("/get", &controllers.BulletinController{}, "post:GetBulletin"), | 51 | beego.NSRouter("/get", &controllers.BulletinController{}, "post:GetBulletin"), |
52 | beego.NSRouter("/update", &controllers.BulletinController{}, "post:UpdateBulletin"), | 52 | beego.NSRouter("/update", &controllers.BulletinController{}, "post:UpdateBulletin"), |
53 | beego.NSRouter("/operate", &controllers.BulletinController{}, "post:OperateBulletin"), | 53 | beego.NSRouter("/operate", &controllers.BulletinController{}, "post:OperateBulletin"), |
54 | + beego.NSRouter("/feedbacks", &controllers.BulletinController{}, "post:BulletinFeedbacks"), | ||
54 | ), | 55 | ), |
55 | beego.NSNamespace("/common", | 56 | beego.NSNamespace("/common", |
56 | beego.NSRouter("/department", &controllers.CommonController{}, "post:SelectorDepartment"), | 57 | beego.NSRouter("/department", &controllers.CommonController{}, "post:SelectorDepartment"), |
@@ -35,6 +35,7 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs | @@ -35,6 +35,7 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs | ||
35 | Name: request.Template.Name, | 35 | Name: request.Template.Name, |
36 | Doc: request.Template.Doc, | 36 | Doc: request.Template.Doc, |
37 | Icon: request.Template.Icon, | 37 | Icon: request.Template.Icon, |
38 | + Code: request.Template.Code, | ||
38 | NoApprover: 1, //TODO:配置 | 39 | NoApprover: 1, //TODO:配置 |
39 | SortNum: 0, | 40 | SortNum: 0, |
40 | VisibleType: int8(0), | 41 | VisibleType: int8(0), |
@@ -285,6 +286,7 @@ func TemplateOperateCategory(uid, companyId int64, request *protocol.TemplateOpe | @@ -285,6 +286,7 @@ func TemplateOperateCategory(uid, companyId int64, request *protocol.TemplateOpe | ||
285 | chanceType = &models.ChanceType{ | 286 | chanceType = &models.ChanceType{ |
286 | Name: request.Name, | 287 | Name: request.Name, |
287 | Icon: request.Icon, | 288 | Icon: request.Icon, |
289 | + Code: request.Code, | ||
288 | CompanyId: int(companyId), | 290 | CompanyId: int(companyId), |
289 | CreateAt: time.Now(), | 291 | CreateAt: time.Now(), |
290 | UpdateAt: time.Now(), | 292 | UpdateAt: time.Now(), |
@@ -162,21 +162,22 @@ func BulletinList(uid, companyId int64, request *protocol.BulletinListRequest) ( | @@ -162,21 +162,22 @@ func BulletinList(uid, companyId int64, request *protocol.BulletinListRequest) ( | ||
162 | list []*models.Bulletin | 162 | list []*models.Bulletin |
163 | total int | 163 | total int |
164 | ) | 164 | ) |
165 | - if request.Page == 0 { | ||
166 | - request.Page = 1 | 165 | + if request.PageIndex == 0 { |
166 | + request.PageIndex += 1 | ||
167 | } | 167 | } |
168 | if request.PageSize == 0 { | 168 | if request.PageSize == 0 { |
169 | request.PageSize = 20 | 169 | request.PageSize = 20 |
170 | } | 170 | } |
171 | rsp = &protocol.BulletinListResponse{} | 171 | rsp = &protocol.BulletinListResponse{} |
172 | - if list, total, err = models.GetBulletins(companyId, request.Status, request.Page, request.PageSize); err != nil { | 172 | + if list, total, err = models.GetBulletins(companyId, request.Status, request.PageIndex, request.PageSize); err != nil { |
173 | log.Error(err.Error()) | 173 | log.Error(err.Error()) |
174 | return | 174 | return |
175 | } | 175 | } |
176 | if len(list) == 0 { | 176 | if len(list) == 0 { |
177 | return | 177 | return |
178 | } | 178 | } |
179 | - rsp.Total = total | 179 | + rsp.TotalPage = total |
180 | + rsp.CurrentPage = request.PageIndex | ||
180 | for i := range list { | 181 | for i := range list { |
181 | bulletin := list[i] | 182 | bulletin := list[i] |
182 | item := &protocol.BulletinItem{ | 183 | item := &protocol.BulletinItem{ |
@@ -186,8 +187,8 @@ func BulletinList(uid, companyId int64, request *protocol.BulletinListRequest) ( | @@ -186,8 +187,8 @@ func BulletinList(uid, companyId int64, request *protocol.BulletinListRequest) ( | ||
186 | Status: int8(bulletin.Status), | 187 | Status: int8(bulletin.Status), |
187 | CreateAt: bulletin.CreateAt.Format("2006-01-02 15:04:05"), | 188 | CreateAt: bulletin.CreateAt.Format("2006-01-02 15:04:05"), |
188 | } | 189 | } |
189 | - if item.Receiver, err = getUsersName(bulletin.Receiver); err != nil { | ||
190 | - log.Error(err.Error()) | 190 | + if item.Receiver, err = agg.GetVisibleObject(bulletin.Receiver); err != nil { |
191 | + log.Error(bulletin.Receiver, err.Error()) | ||
191 | continue | 192 | continue |
192 | } | 193 | } |
193 | rsp.List = append(rsp.List, item) | 194 | rsp.List = append(rsp.List, item) |
@@ -374,7 +375,7 @@ func OperateBulletin(companyId int64, request *protocol.OperateBulletinRequest) | @@ -374,7 +375,7 @@ func OperateBulletin(companyId int64, request *protocol.OperateBulletinRequest) | ||
374 | orm.Begin() | 375 | orm.Begin() |
375 | if request.CmdType == protocol.BulletinUnRelease { //下架 | 376 | if request.CmdType == protocol.BulletinUnRelease { //下架 |
376 | status = protocol.BulletinUnRelease | 377 | status = protocol.BulletinUnRelease |
377 | - if err = utils.ExecuteSQLWithOrmer(orm, models.DeleteUserMsgSql, companyId, models.MsgTypeBulletin, bulletin.Id); err != nil { | 378 | + if err = utils.ExecuteSQLWithOrmer(orm, models.SqlDeleteUserMsg, companyId, models.MsgTypeBulletin, bulletin.Id); err != nil { |
378 | log.Error(err.Error()) | 379 | log.Error(err.Error()) |
379 | orm.Rollback() | 380 | orm.Rollback() |
380 | return | 381 | return |
@@ -397,3 +398,57 @@ func OperateBulletin(companyId int64, request *protocol.OperateBulletinRequest) | @@ -397,3 +398,57 @@ func OperateBulletin(companyId int64, request *protocol.OperateBulletinRequest) | ||
397 | rsp = &protocol.OperateBulletinResponse{} | 398 | rsp = &protocol.OperateBulletinResponse{} |
398 | return | 399 | return |
399 | } | 400 | } |
401 | + | ||
402 | +//反馈详情 | ||
403 | +func BulletinFeedbacks(companyId int64, request *protocol.BulletinFeedbacksRequest) (rsp *protocol.BulletinFeedbacksResponse, err error) { | ||
404 | + type Feedback struct { | ||
405 | + Answer string `orm:"column(answer);null" description:"答案"` | ||
406 | + Uid int64 `orm:"column(uid);null" description:"用户id"` | ||
407 | + UpdateAt time.Time `orm:"column(update_at);type(timestamp);null" description:"更新时间"` | ||
408 | + NickName string `orm:"column(nick_name);size(100)" description:"昵称"` | ||
409 | + } | ||
410 | + var ( | ||
411 | + feedbacks []Feedback | ||
412 | + total int | ||
413 | + answer protocol.Answer | ||
414 | + ) | ||
415 | + rsp = &protocol.BulletinFeedbacksResponse{} | ||
416 | + if total, err = models.GetBulletinQuestionAnswers(request.PageIndex, request.PageSize, request.Id, &feedbacks); err != nil { | ||
417 | + if err == orm2.ErrNoRows { | ||
418 | + err = nil | ||
419 | + } | ||
420 | + return | ||
421 | + } | ||
422 | + rsp.CurrentPage = request.PageIndex | ||
423 | + rsp.TotalPage = total | ||
424 | + for i := range feedbacks { | ||
425 | + tmp := feedbacks[i] | ||
426 | + var content string | ||
427 | + var other string | ||
428 | + if err = json.Unmarshal([]byte(tmp.Answer), &answer); err != nil { | ||
429 | + log.Error(err.Error()) | ||
430 | + continue | ||
431 | + } | ||
432 | + for i := range answer.VoteResults { | ||
433 | + value := answer.VoteResults[i] | ||
434 | + if value == -1 { | ||
435 | + other = " 其他" | ||
436 | + } else if value < 10 { | ||
437 | + content += string(byte('A') + byte(value) - 1) | ||
438 | + if i+1 < len(answer.VoteResults) { | ||
439 | + content += "," | ||
440 | + } | ||
441 | + } | ||
442 | + } | ||
443 | + content = content + other | ||
444 | + if len(answer.EditContent) != 0 { | ||
445 | + content = fmt.Sprintf("%v (%v)", content, answer.EditContent) | ||
446 | + } | ||
447 | + rsp.List = append(rsp.List, protocol.FeedBackItem{ | ||
448 | + Time: tmp.UpdateAt.Unix(), | ||
449 | + Name: tmp.NickName, | ||
450 | + Content: content, | ||
451 | + }) | ||
452 | + } | ||
453 | + return | ||
454 | +} |
-
请 注册 或 登录 后发表评论