正在显示
10 个修改的文件
包含
171 行增加
和
39 行删除
| @@ -3,8 +3,10 @@ package controllers | @@ -3,8 +3,10 @@ package controllers | ||
| 3 | import ( | 3 | import ( |
| 4 | "encoding/json" | 4 | "encoding/json" |
| 5 | "oppmg/common/log" | 5 | "oppmg/common/log" |
| 6 | + "oppmg/models" | ||
| 6 | "oppmg/protocol" | 7 | "oppmg/protocol" |
| 7 | serveaudit "oppmg/services/audit" | 8 | serveaudit "oppmg/services/audit" |
| 9 | + servecommon "oppmg/services/common" | ||
| 8 | ) | 10 | ) |
| 9 | 11 | ||
| 10 | type AuditController struct { | 12 | type AuditController struct { |
| @@ -31,10 +33,29 @@ func (c *AuditController) AuditList() { | @@ -31,10 +33,29 @@ func (c *AuditController) AuditList() { | ||
| 31 | return | 33 | return |
| 32 | } | 34 | } |
| 33 | 35 | ||
| 34 | -// func (c *AuditController) Test() { | ||
| 35 | -// data, err := serverbac.GetUserPermission(11) | ||
| 36 | -// fmt.Println(err) | ||
| 37 | -// bt, err := json.Marshal(data) | ||
| 38 | -// fmt.Println(err) | ||
| 39 | -// fmt.Println(string(bt)) | ||
| 40 | -// } | 36 | +//AuditListBefore |
| 37 | +//@router /v1/audit/list/before | ||
| 38 | +func (c *AuditController) AuditListBefore() { | ||
| 39 | + var msg *protocol.ResponseMessage | ||
| 40 | + defer func() { | ||
| 41 | + c.ResposeJson(msg) | ||
| 42 | + }() | ||
| 43 | + // uid := c.GetUserId() | ||
| 44 | + companyId := c.GetCompanyId() | ||
| 45 | + templatelist := servecommon.SelectGetTemplateList(companyId) | ||
| 46 | + chanceTypeList := servecommon.SeleteGetChanceTypeList(companyId) | ||
| 47 | + departmentList := servecommon.SelectorDepartment(companyId, -1) | ||
| 48 | + publicStatus := models.ChancePublishStatusMap | ||
| 49 | + enableStatus := models.ChanceEnableStatusMap | ||
| 50 | + reviewStatus := models.ChanceReviewStatusMap | ||
| 51 | + data := map[string]interface{}{ | ||
| 52 | + "template": templatelist, | ||
| 53 | + "chance_type": chanceTypeList, | ||
| 54 | + "public_status": publicStatus, | ||
| 55 | + "enable_status": enableStatus, | ||
| 56 | + "review_status": reviewStatus, | ||
| 57 | + "department": departmentList, | ||
| 58 | + } | ||
| 59 | + msg = protocol.NewReturnResponse(data, nil) | ||
| 60 | + return | ||
| 61 | +} |
| @@ -8,7 +8,7 @@ import ( | @@ -8,7 +8,7 @@ import ( | ||
| 8 | ) | 8 | ) |
| 9 | 9 | ||
| 10 | type Chance struct { | 10 | type Chance struct { |
| 11 | - Id int `orm:"column(id);pk" description:"id 主键"` | 11 | + Id int64 `orm:"column(id);pk" description:"id 主键"` |
| 12 | UserId int64 `orm:"column(user_id)" description:"表user_company.id id"` | 12 | UserId int64 `orm:"column(user_id)" description:"表user_company.id id"` |
| 13 | DepartmentId int64 `orm:"column(department_id)" description:"表department.id 部门id (提交机会指定的部门)"` | 13 | DepartmentId int64 `orm:"column(department_id)" description:"表department.id 部门id (提交机会指定的部门)"` |
| 14 | ChanceTypeId int `orm:"column(chance_type_id)" description:"表chance_type.id 机会类型 "` | 14 | ChanceTypeId int `orm:"column(chance_type_id)" description:"表chance_type.id 机会类型 "` |
| @@ -90,7 +90,7 @@ func AddChance(m *Chance) (id int64, err error) { | @@ -90,7 +90,7 @@ func AddChance(m *Chance) (id int64, err error) { | ||
| 90 | 90 | ||
| 91 | // GetChanceById retrieves Chance by Id. Returns error if | 91 | // GetChanceById retrieves Chance by Id. Returns error if |
| 92 | // Id doesn't exist | 92 | // Id doesn't exist |
| 93 | -func GetChanceById(id int) (v *Chance, err error) { | 93 | +func GetChanceById(id int64) (v *Chance, err error) { |
| 94 | o := orm.NewOrm() | 94 | o := orm.NewOrm() |
| 95 | v = &Chance{Id: id} | 95 | v = &Chance{Id: id} |
| 96 | if err = o.Read(v); err == nil { | 96 | if err = o.Read(v); err == nil { |
models/chance_data.go
0 → 100644
| 1 | +package models | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "time" | ||
| 5 | + | ||
| 6 | + "github.com/astaxie/beego/orm" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +type ChanceData struct { | ||
| 10 | + Id int `orm:"column(id);pk" description:"唯一编号"` | ||
| 11 | + ChanceId int64 `orm:"column(chance_id);null" description:"表chance.id 机会编号"` | ||
| 12 | + Images string `orm:"column(images);null" description:"图片 json"` | ||
| 13 | + Speechs string `orm:"column(speechs);null" description:"语音 json"` | ||
| 14 | + Videos string `orm:"column(videos);null" description:"视频 json"` | ||
| 15 | + CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间"` | ||
| 16 | + UpdateAt time.Time `orm:"column(update_at);type(timestamp);null" description:"更新时间"` | ||
| 17 | +} | ||
| 18 | + | ||
| 19 | +func (t *ChanceData) TableName() string { | ||
| 20 | + return "chance_data" | ||
| 21 | +} | ||
| 22 | + | ||
| 23 | +func init() { | ||
| 24 | + orm.RegisterModel(new(ChanceData)) | ||
| 25 | +} | ||
| 26 | + | ||
| 27 | +type ChanceDataImage struct { | ||
| 28 | + Path string `json:"path"` | ||
| 29 | + W int `json:"w"` | ||
| 30 | + H int `json:"h"` | ||
| 31 | +} | ||
| 32 | + | ||
| 33 | +type ChanceDataSpeechs struct { | ||
| 34 | + Path string `json:"path"` | ||
| 35 | + Duration int `json:"duration"` | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +type ChanceDataVideos struct { | ||
| 39 | + Path string | ||
| 40 | + Cover ChanceDataImage `json:"cover"` | ||
| 41 | + Duration int `json:"duration"` | ||
| 42 | +} |
| 1 | package protocol | 1 | package protocol |
| 2 | 2 | ||
| 3 | -import "sort" | 3 | +import ( |
| 4 | + "sort" | ||
| 5 | +) | ||
| 4 | 6 | ||
| 5 | //输入框类型 | 7 | //输入框类型 |
| 6 | const ( | 8 | const ( |
| @@ -11,17 +13,16 @@ const ( | @@ -11,17 +13,16 @@ const ( | ||
| 11 | 13 | ||
| 12 | //InputElement 自定义表单项 | 14 | //InputElement 自定义表单项 |
| 13 | type InputElement struct { | 15 | type InputElement struct { |
| 14 | - Id int `json:"id"` | ||
| 15 | - Sort int `json:"sort"` //排序 | ||
| 16 | - Lable string `json:"lable"` //标题 | ||
| 17 | - InputType string `json:"inputType"` //输入类型 | ||
| 18 | - Required int `json:"required"` //是否必填 | ||
| 19 | - CurrentValue string `json:"-"` //"当前填写的值" | ||
| 20 | - SectionType int8 `json:"sectionType"` | ||
| 21 | - | ||
| 22 | - ValueList string `json:"-"` //输入候选值 value_list | ||
| 23 | - Placeholder string `json:"-"` //帮助用户填写输入字段的提示 Placeholder | ||
| 24 | - Disable bool `json:"-"` //"显示隐藏", | 16 | + Id int `json:"id"` |
| 17 | + Sort int `json:"sort"` //排序 | ||
| 18 | + Lable string `json:"lable"` //标题 | ||
| 19 | + InputType string `json:"inputType"` //输入类型 | ||
| 20 | + Required int `json:"required"` //是否必填 | ||
| 21 | + // CurrentValue string `json:"-"` //"当前填写的值" | ||
| 22 | + SectionType int8 `json:"sectionType"` | ||
| 23 | + // ValueList string `json:"-"` //输入候选值 value_list | ||
| 24 | + // Placeholder string `json:"-"` //帮助用户填写输入字段的提示 Placeholder | ||
| 25 | + // Disable bool `json:"-"` //"显示隐藏", | ||
| 25 | } | 26 | } |
| 26 | 27 | ||
| 27 | //自定义表单 | 28 | //自定义表单 |
| @@ -246,7 +247,7 @@ type ResponseAuditList struct { | @@ -246,7 +247,7 @@ type ResponseAuditList struct { | ||
| 246 | } | 247 | } |
| 247 | 248 | ||
| 248 | type RspAuditList struct { | 249 | type RspAuditList struct { |
| 249 | - Id int64 `json:"id"` //机会的id | 250 | + Id string `json:"id"` //机会的id |
| 250 | Code string `json:"code"` | 251 | Code string `json:"code"` |
| 251 | ChanceType string `json:"chance_type"` //一级分类 | 252 | ChanceType string `json:"chance_type"` //一级分类 |
| 252 | TemplateName string `json:"template_name"` //二级分类 | 253 | TemplateName string `json:"template_name"` //二级分类 |
| @@ -260,3 +261,9 @@ type RspAuditList struct { | @@ -260,3 +261,9 @@ type RspAuditList struct { | ||
| 260 | EnableStatus int `json:"enable_status"` | 261 | EnableStatus int `json:"enable_status"` |
| 261 | EnableStatusName string `json:"enable_status_name"` | 262 | EnableStatusName string `json:"enable_status_name"` |
| 262 | } | 263 | } |
| 264 | + | ||
| 265 | +type ChanceFlowLog struct { | ||
| 266 | + CreateTime string `json:"create_time"` | ||
| 267 | + Content string `json:"content"` | ||
| 268 | + UserrName string `json:"user_name"` | ||
| 269 | +} |
| @@ -67,13 +67,13 @@ type RoleHasUser struct { | @@ -67,13 +67,13 @@ type RoleHasUser struct { | ||
| 67 | 67 | ||
| 68 | //下拉选择框的内容模板 -机会二级分类 | 68 | //下拉选择框的内容模板 -机会二级分类 |
| 69 | type TemplateBase struct { | 69 | type TemplateBase struct { |
| 70 | - TemplateId int64 `orm:"column(template_id)"` | ||
| 71 | - ChanceTypeId int64 `orm:"column(chance_type_id)"` | ||
| 72 | - Name string `orm:"column(name)"` | 70 | + TemplateId int64 `orm:"column(template_id)" json:"template_id"` |
| 71 | + ChanceTypeId int64 `orm:"column(chance_type_id)" json:"chance_type_id"` | ||
| 72 | + Name string `orm:"column(name)" json:"name"` | ||
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | //下拉选择框的内容机会分类 - 机会一级分类 | 75 | //下拉选择框的内容机会分类 - 机会一级分类 |
| 76 | type ChanceTypeBase struct { | 76 | type ChanceTypeBase struct { |
| 77 | - ChanceTypeId int64 `orm:"column(chance_type_id)"` | ||
| 78 | - Name string `orm:"column(name)"` | 77 | + ChanceTypeId int64 `orm:"column(chance_type_id)" json:"chance_type_id"` |
| 78 | + Name string `orm:"column(name)" json:"name"` | ||
| 79 | } | 79 | } |
| @@ -99,6 +99,7 @@ func init() { | @@ -99,6 +99,7 @@ func init() { | ||
| 99 | ), | 99 | ), |
| 100 | beego.NSNamespace("/audit", | 100 | beego.NSNamespace("/audit", |
| 101 | beego.NSRouter("/list", &controllers.AuditController{}, "post:AuditList"), | 101 | beego.NSRouter("/list", &controllers.AuditController{}, "post:AuditList"), |
| 102 | + beego.NSRouter("/list/before", &controllers.AuditController{}, "post:AuditListBefore"), | ||
| 102 | ), | 103 | ), |
| 103 | ) | 104 | ) |
| 104 | 105 |
| 1 | package audit | 1 | package audit |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | + "encoding/json" | ||
| 4 | "fmt" | 5 | "fmt" |
| 5 | "oppmg/common/log" | 6 | "oppmg/common/log" |
| 6 | "oppmg/models" | 7 | "oppmg/models" |
| @@ -115,7 +116,7 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64 | @@ -115,7 +116,7 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64 | ||
| 115 | for _, v := range data { | 116 | for _, v := range data { |
| 116 | t := v.CreateAt.Unix() | 117 | t := v.CreateAt.Unix() |
| 117 | item := protocol.RspAuditList{ | 118 | item := protocol.RspAuditList{ |
| 118 | - Id: v.Id, | 119 | + Id: fmt.Sprint(v.Id), |
| 119 | EnableStatus: v.EnableStatus, | 120 | EnableStatus: v.EnableStatus, |
| 120 | EnableStatusName: models.ChanceEnableStatusMap[v.EnableStatus], | 121 | EnableStatusName: models.ChanceEnableStatusMap[v.EnableStatus], |
| 121 | PublishStatus: v.PublishStatus, | 122 | PublishStatus: v.PublishStatus, |
| @@ -148,4 +149,50 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64 | @@ -148,4 +149,50 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64 | ||
| 148 | return returnData, nil | 149 | return returnData, nil |
| 149 | } | 150 | } |
| 150 | 151 | ||
| 151 | -// 机会管理的列表搜索项数据 | 152 | +type ResponseChanceInfo struct { |
| 153 | + BaseContent []protocol.InputElement `json:"base_content"` | ||
| 154 | + ExtraContent []protocol.InputElement `json:"extra_content"` | ||
| 155 | + ImageData []models.ChanceDataImage `json:"image_data"` | ||
| 156 | + VideoData []models.ChanceDataVideos `json:"video_data"` | ||
| 157 | + SpeechData []models.ChanceDataSpeechs `json:"speech_data"` | ||
| 158 | + FlowLog []protocol.ChanceFlowLog `json:"flow_log"` | ||
| 159 | +} | ||
| 160 | + | ||
| 161 | +//机会详情 | ||
| 162 | +func GetChanceDetail(chanceid int64, companyid int64) (ResponseChanceInfo, error) { | ||
| 163 | + var ( | ||
| 164 | + chanceInfo *models.Chance | ||
| 165 | + err error | ||
| 166 | + returnData = ResponseChanceInfo{ | ||
| 167 | + BaseContent: make([]protocol.InputElement, 0), | ||
| 168 | + ExtraContent: make([]protocol.InputElement, 0), | ||
| 169 | + ImageData: make([]models.ChanceDataImage, 0), | ||
| 170 | + VideoData: make([]models.ChanceDataVideos, 0), | ||
| 171 | + SpeechData: make([]models.ChanceDataSpeechs, 0), | ||
| 172 | + FlowLog: make([]protocol.ChanceFlowLog, 0), | ||
| 173 | + } | ||
| 174 | + ) | ||
| 175 | + chanceInfo, err = models.GetChanceById(chanceid) | ||
| 176 | + if err != nil { | ||
| 177 | + log.Error("获取机会详情失败:%s", err) | ||
| 178 | + return returnData, protocol.NewErrWithMessage("1") | ||
| 179 | + } | ||
| 180 | + if chanceInfo.CompanyId != companyid { | ||
| 181 | + log.Error("机会的公司不匹配") | ||
| 182 | + return returnData, protocol.NewErrWithMessage("1") | ||
| 183 | + } | ||
| 184 | + var ( | ||
| 185 | + chanceContent []protocol.InputElement | ||
| 186 | + ) | ||
| 187 | + json.Unmarshal([]byte(chanceInfo.Content), &chanceContent) | ||
| 188 | + for i := range chanceContent { | ||
| 189 | + if chanceContent[i].SectionType == 1 { | ||
| 190 | + returnData.BaseContent = append(returnData.BaseContent, chanceContent[i]) | ||
| 191 | + } | ||
| 192 | + if chanceContent[i].SectionType == 2 { | ||
| 193 | + returnData.ExtraContent = append(returnData.ExtraContent, chanceContent[i]) | ||
| 194 | + } | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + return returnData, nil | ||
| 198 | +} |
| @@ -159,22 +159,28 @@ func SelectorUserAndDepartment(departid int64, companyId int64) (*protocol.Depar | @@ -159,22 +159,28 @@ func SelectorUserAndDepartment(departid int64, companyId int64) (*protocol.Depar | ||
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | //获取机会二级分类 | 161 | //获取机会二级分类 |
| 162 | -func SelectGetTemplateList() []protocol.TemplateBase { | 162 | +func SelectGetTemplateList(companyid int64) []protocol.TemplateBase { |
| 163 | datasql := `SELECT id AS template_id,chance_type_id,name | 163 | datasql := `SELECT id AS template_id,chance_type_id,name |
| 164 | FROM audit_template | 164 | FROM audit_template |
| 165 | where company_id = ? AND enable_status = 1` | 165 | where company_id = ? AND enable_status = 1` |
| 166 | data := make([]protocol.TemplateBase, 0) | 166 | data := make([]protocol.TemplateBase, 0) |
| 167 | - utils.ExecuteQueryAll(&data, datasql) | 167 | + err := utils.ExecuteQueryAll(&data, datasql, companyid) |
| 168 | + if err != nil { | ||
| 169 | + log.Error("EXECUTE SQL ERR :%s", err) | ||
| 170 | + } | ||
| 168 | return data | 171 | return data |
| 169 | 172 | ||
| 170 | } | 173 | } |
| 171 | 174 | ||
| 172 | //获取机会一级级分类 | 175 | //获取机会一级级分类 |
| 173 | -func SeleteGetChanceTypeList() []protocol.ChanceTypeBase { | 176 | +func SeleteGetChanceTypeList(companyid int64) []protocol.ChanceTypeBase { |
| 174 | datasql := ` SELECT id AS chance_type_id,name | 177 | datasql := ` SELECT id AS chance_type_id,name |
| 175 | FROM chance_type | 178 | FROM chance_type |
| 176 | WHERE company_id = ?` | 179 | WHERE company_id = ?` |
| 177 | data := make([]protocol.ChanceTypeBase, 0) | 180 | data := make([]protocol.ChanceTypeBase, 0) |
| 178 | - utils.ExecuteQueryAll(&data, datasql) | 181 | + err := utils.ExecuteQueryAll(&data, datasql, companyid) |
| 182 | + if err != nil { | ||
| 183 | + log.Error("EXECUTE SQL ERR :%s", err) | ||
| 184 | + } | ||
| 179 | return data | 185 | return data |
| 180 | } | 186 | } |
| @@ -141,13 +141,18 @@ func RoleMenuEdit(companyid int64, roleId int64, menuids []int64) error { | @@ -141,13 +141,18 @@ func RoleMenuEdit(companyid int64, roleId int64, menuids []int64) error { | ||
| 141 | return protocol.NewErrWithMessage("1") | 141 | return protocol.NewErrWithMessage("1") |
| 142 | } | 142 | } |
| 143 | } | 143 | } |
| 144 | - opptionbt, _ := json.Marshal(&PermissionOptionBase{Check: 1}) | 144 | + |
| 145 | for _, v := range addMenu { | 145 | for _, v := range addMenu { |
| 146 | + | ||
| 146 | m := models.RoleMenu{ | 147 | m := models.RoleMenu{ |
| 147 | - RoleId: roleId, | ||
| 148 | - MenuId: v.Id, | ||
| 149 | - Code: v.Code, | ||
| 150 | - Opption: string(opptionbt), | 148 | + RoleId: roleId, |
| 149 | + MenuId: v.Id, | ||
| 150 | + Code: v.Code, | ||
| 151 | + } | ||
| 152 | + if fn, ok := CodePermissionObject[v.Code]; ok { | ||
| 153 | + obj := fn() | ||
| 154 | + optionbt, _ := json.Marshal(obj) | ||
| 155 | + m.Opption = string(optionbt) | ||
| 151 | } | 156 | } |
| 152 | if _, err = o.Insert(&m); err != nil { | 157 | if _, err = o.Insert(&m); err != nil { |
| 153 | log.Error("添加角色和菜单关系失败:%s", err) | 158 | log.Error("添加角色和菜单关系失败:%s", err) |
| @@ -20,7 +20,9 @@ var ( | @@ -20,7 +20,9 @@ var ( | ||
| 20 | ) | 20 | ) |
| 21 | 21 | ||
| 22 | func NewPermissionOptionBase() PermissionOptionObject { | 22 | func NewPermissionOptionBase() PermissionOptionObject { |
| 23 | - return &PermissionOptionBase{} | 23 | + return &PermissionOptionBase{ |
| 24 | + Check: 1, | ||
| 25 | + } | ||
| 24 | } | 26 | } |
| 25 | 27 | ||
| 26 | func (p *PermissionOptionBase) ValidDefault(obj UserObject) bool { | 28 | func (p *PermissionOptionBase) ValidDefault(obj UserObject) bool { |
| @@ -120,6 +122,7 @@ var ( | @@ -120,6 +122,7 @@ var ( | ||
| 120 | 122 | ||
| 121 | func NewOptionOpportunity() PermissionOptionObject { | 123 | func NewOptionOpportunity() PermissionOptionObject { |
| 122 | return &OptionOpportunity{ | 124 | return &OptionOpportunity{ |
| 125 | + Check: OpportunityCheckLv4, | ||
| 123 | CheckMap: make(map[int]int), | 126 | CheckMap: make(map[int]int), |
| 124 | CheckOption: CheckOpp{ | 127 | CheckOption: CheckOpp{ |
| 125 | Departments: []CheckDeparment{}, | 128 | Departments: []CheckDeparment{}, |
-
请 注册 或 登录 后发表评论