作者 yangfu

公告修改

... ... @@ -41,6 +41,10 @@ func (this *BulletinController) BulletinRelease() {
msg = m
return
}
if len([]rune(request.Title)) > 30 {
msg = protocol.BadRequestParam("10278")
return
}
rsp, err := bulletin.BulletinRelease(uid, companyId, request)
msg = protocol.NewReturnResponse(rsp, err)
return
... ... @@ -205,7 +209,7 @@ func (this *BulletinController) ExportFeedBacks() {
msg = protocol.BadRequestParam("1")
return
}
//excel.FileName = fmt.Sprintf("商品列表%v.xlsx","")
//excel.FileName = fmt.Sprintf("商品列表%v.xlsx",time.Now().Format("2006-1-2 15:04:05"))
if err = this.ResponseExcelByFile(this.Ctx, excel); err != nil {
log.Error(err.Error())
msg = protocol.BadRequestParam("1")
... ...
... ... @@ -2,6 +2,7 @@ package models
import (
"fmt"
"oppmg/utils"
"time"
"github.com/astaxie/beego/orm"
... ... @@ -82,10 +83,10 @@ func DeleteBulletin(id int) (err error) {
return
}
func GetBulletins(companyId int64, status int8, page, pageSize int) (v []*Bulletin, total int, err error) {
func GetBulletins(companyId int64, status int8, offset, pageSize int) (v []*Bulletin, total int, err error) {
sql := "select * from bulletin where (status=? or ?=0) and company_id =? order by create_at desc limit ?,?"
o := orm.NewOrm()
if _, err = o.Raw(sql, status, status, companyId, page-1, pageSize).QueryRows(&v); err != nil {
if err = utils.ExecuteQueryAllWithOrmer(o, &v, sql, status, status, companyId, offset, pageSize); err != nil {
return
}
... ...
... ... @@ -75,6 +75,7 @@ var errmessge ErrorMap = map[string]string{
"10275": "最多添加1个节点",
"10276": "最多选择1个角色",
"10277": "最多一个小数",
"10278": "公告标题大于30个字符",
"10170": "请选择指定成员",
"10171": "请选择审批人类别",
... ...
... ... @@ -171,7 +171,7 @@ func BulletinList(uid, companyId int64, request *protocol.BulletinListRequest) (
request.PageSize = 20
}
rsp = &protocol.BulletinListResponse{}
if list, total, err = models.GetBulletins(companyId, request.Status, request.PageIndex, request.PageSize); err != nil {
if list, total, err = models.GetBulletins(companyId, request.Status, (request.PageIndex-1)*request.PageIndex, request.PageSize); err != nil {
log.Error(err.Error())
return
}
... ... @@ -277,6 +277,11 @@ func GetBulletin(id int, companyId int64, request *protocol.GetBulletinRequest)
log.Error(err.Error())
return
}
for i := range rsp.Question.Content {
if rsp.Question.Content[i].Id == -1 && len(rsp.Question.Content[i].Content) == 0 {
rsp.Question.Content[i].Content = "其他"
}
}
}
if e := json.Unmarshal([]byte(bulletin.Receiver), &rsp.Receiver); e != nil {
log.Error(e.Error())
... ...