作者 yangfu

修改 机会审核(编码)

增加 草稿箱列表/删除/添加草稿
增加 储备类型列表
... ... @@ -206,26 +206,26 @@ func (this *ChanceController) ChanceType() {
msg = protocol.NewReturnResponse(chance.ChanceType(header, request))
}
//Permission 机会权限
//@router /permission [post]
//func (this *ChanceController) Permission() {
// var msg *protocol.ResponseMessage
// defer func() {
// this.Resp(msg)
// }()//
// var request *protocol.ChancePermissionRequest
// if err := json.Unmarshal(this.ByteBody, &request); err != nil {
// log.Error(err)
// msg = protocol.BadRequestParam(1)
// return
// }
// if b, m := this.Valid(request); !b {
// msg = m
// return
// }
// header := controllers.GetRequestHeader(this.Ctx)
// msg = protocol.NewReturnResponse(chance.ChancePermission(header, request))
//}
//ChanceReserveType 机会储备类型
//@router /chanceReserveType [post]
func (this *ChanceController) ChanceReserveType() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *protocol.ChanceReserveTypeRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(chance.ChanceReserveType(header, request))
}
//Templates
//@router /templates [post]
... ... @@ -643,6 +643,28 @@ func (this *ChanceController) ChancePool() {
msg = protocol.NewReturnResponse(chance.ChancePool(header, request))
}
//ChanceReservePool 储备池
//@router /chanceReservePool [post]
func (this *ChanceController) ChanceReservePool() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *protocol.ChancePoolRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
header := controllers.GetRequestHeader(this.Ctx)
request.Type = 1
msg = protocol.NewReturnResponse(chance.ChancePool(header, request))
}
//ChanceReviseDetail 机会补充详情
//@router /chanceReviseDetail [post]
func (this *ChanceController) ChanceReviseDetail() {
... ...
... ... @@ -7,12 +7,12 @@ import (
)
type ChanceReserveType struct {
Id int `orm:"column(id);auto"`
Name string `orm:"column(name);size(50)" description:"储备类型名称"`
CompanyId int `orm:"column(company_id)" description:"表company.id 公司编号"`
SortNum int `orm:"column(sort_num);null" description:"序号 "`
CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间 "`
UpdateAt time.Time `orm:"column(update_at);type(timestamp);null" description:"更新时间 "`
Id int `orm:"column(id);auto" json:"id"`
Name string `orm:"column(name);size(50)" description:"储备类型名称" json:"name"`
CompanyId int `orm:"column(company_id)" description:"表company.id 公司编号" json:"-"`
SortNum int `orm:"column(sort_num);null" description:"序号 " json:"-"`
CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间 " json:"-"`
UpdateAt time.Time `orm:"column(update_at);type(timestamp);null" description:"更新时间 " json:"-"`
}
func (t *ChanceReserveType) TableName() string {
... ... @@ -33,3 +33,12 @@ func GetChanceReserveTypeById(id int) (v *ChanceReserveType, err error) {
}
return nil, err
}
func GetChanceReserveTypes(cid int64) (v []*ChanceReserveType, err error) {
o := orm.NewOrm()
sql := "select * from chance_reserve_type where company_id=? order by sort_num,id"
if _, err = o.Raw(sql, cid).QueryRows(&v); err == nil {
return
}
return
}
... ...
package models
import (
"time"
"github.com/astaxie/beego/orm"
)
type MenuApp struct {
Id int `orm:"column(id);auto" description:"主键"`
Name string `orm:"column(name);size(10)" description:"菜单名称"`
Icon string `orm:"column(icon);size(128)" description:"菜单图标地址"`
ParentId int `orm:"column(parent_id)" description:"上一级菜单 id"`
Type int `orm:"column(type)" description:"类型:1为 pc 2为app"`
Url string `orm:"column(url);size(128)" description:"菜单地址"`
Code string `orm:"column(code);size(128)" description:"菜单编码"`
Sort int `orm:"column(sort)" description:"同级菜单序号 "`
CreateTime time.Time `orm:"column(create_time);type(timestamp);null" description:"创建时间"`
Enabled int8 `orm:"column(enabled)" description:"是否有效"`
}
func (t *MenuApp) TableName() string {
return "menu_app"
}
func init() {
orm.RegisterModel(new(MenuApp))
}
// GetMenuAppById retrieves MenuApp by Id. Returns error if
// Id doesn't exist
func GetMenuAppById(id int) (v *MenuApp, err error) {
o := orm.NewOrm()
v = &MenuApp{Id: id}
if err = o.Read(v); err == nil {
return v, nil
}
return nil, err
}
func GetMenuApp() (v []*MenuApp, err error) {
o := orm.NewOrm()
sql := "select * from menu_app where enabled=1 order by sort"
if _, err = o.Raw(sql).QueryRows(&v); err == nil {
return
}
return
}
... ...
package protocol
import (
"opp/models"
"time"
)
... ... @@ -56,6 +55,11 @@ const (
ChanceStatusClose = 2 //关闭
)
const (
ChanceClass = iota //机会一级分类
SubmitMenu //提交菜单
)
/*Favorite 我的收藏/点赞*/
type FavoriteRequest struct {
ObjectType int `json:"object_type" valid:"Required"` //收藏 点赞
... ... @@ -84,7 +88,32 @@ type SympathyActionResponse struct {
type ChanceTypeRequest struct {
}
type ChanceTypeResponse struct {
List []*models.ChanceType `json:"list"`
List []*MenuItem `json:"list"`
}
/*ChanceReserveType 机会储备类型*/
type ChanceReserveTypeRequest struct {
}
type ChanceReserveTypeResponse struct {
List interface{} `json:"list"`
}
type MenuItem struct {
Id int `json:"id"`
Name string `json:"name"`
Icon string `json:"icon"`
Code string `json:"code"` //草稿箱-机会列表 CHANCE_DRAFT
Type int `json:"type"` //0:机会一级分类 1:菜单
}
func NewMenuItem(id int, name, icon, code string, t int) *MenuItem {
return &MenuItem{
Id: id,
Name: name,
Icon: icon,
Code: code,
Type: t,
}
}
/*Templates 模板列表请求*/
... ...
... ... @@ -121,6 +121,22 @@ func init() {
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "ChanceReservePool",
Router: `/chanceReservePool`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "ChanceReserveType",
Router: `/chanceReserveType`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "ChanceReviseDetail",
Router: `/chanceReviseDetail`,
AllowHTTPMethods: []string{"post"},
... ...
... ... @@ -185,9 +185,10 @@ END:
func ChanceType(header *protocol.RequestHeader, request *protocol.ChanceTypeRequest) (rsp *protocol.ChanceTypeResponse, err error) {
var (
list []*models.ChanceType
menus []*models.MenuApp
)
rsp = &protocol.ChanceTypeResponse{}
rsp.List = make([]*models.ChanceType, 0)
rsp.List = make([]*protocol.MenuItem, 0)
if list, err = models.GetChanceTypeAll(header.CompanyId); err != nil {
if err == orm.ErrNoRows {
err = nil
... ... @@ -196,7 +197,35 @@ func ChanceType(header *protocol.RequestHeader, request *protocol.ChanceTypeRequ
log.Error(err)
return
}
rsp.List = append(rsp.List, list...)
for i := range list {
item := list[i]
rsp.List = append(rsp.List, protocol.NewMenuItem(item.Id, item.Name, item.Icon, item.Code, protocol.ChanceClass)) //机会一级分类
}
if menus, err = models.GetMenuApp(); err != nil {
if err == orm.ErrNoRows {
err = nil
return
}
log.Error(err)
return
}
for i := range menus {
item := menus[i]
rsp.List = append(rsp.List, protocol.NewMenuItem(item.Id, item.Name, item.Icon, item.Code, protocol.SubmitMenu)) //菜单
}
return
}
//机会储备类型
func ChanceReserveType(header *protocol.RequestHeader, request *protocol.ChanceReserveTypeRequest) (rsp *protocol.ChanceReserveTypeResponse, err error) {
var (
v []*models.ChanceReserveType
)
v, _ = models.GetChanceReserveTypes(header.CompanyId)
if len(v) == 0 {
v = make([]*models.ChanceReserveType, 0)
}
rsp = &protocol.ChanceReserveTypeResponse{List: v}
return
}
... ...
... ... @@ -113,6 +113,10 @@ func SubmitChecks(header *protocol.RequestHeader, request *protocol.SubmitChecks
err = protocol.NewCustomMessage(5102, "该机会已被关闭")
return
}
if chance.Type == models.ChanceReserve {
err = protocol.NewCustomMessage(1, "该机会已被移至储备池,不允许提交")
return
}
if _, result := CheckIsCommitAllCheck(request.ChanceId); result {
err = protocol.NewCustomMessage(1, "所有人均已提交,不允许修改自查内容")
return
... ...