Merge branch 'dev' of http://gitlab.fjmaimaimai.com/mmm-go/oppmg into dev
正在显示
13 个修改的文件
包含
449 行增加
和
87 行删除
@@ -2,9 +2,11 @@ package controllers | @@ -2,9 +2,11 @@ package controllers | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "encoding/json" | 4 | "encoding/json" |
5 | - "fmt" | 5 | + "oppmg/common/log" |
6 | + "oppmg/models" | ||
6 | "oppmg/protocol" | 7 | "oppmg/protocol" |
7 | - serverbac "oppmg/services/rbac" | 8 | + serveaudit "oppmg/services/audit" |
9 | + servecommon "oppmg/services/common" | ||
8 | ) | 10 | ) |
9 | 11 | ||
10 | type AuditController struct { | 12 | type AuditController struct { |
@@ -18,22 +20,42 @@ func (c *AuditController) AuditList() { | @@ -18,22 +20,42 @@ func (c *AuditController) AuditList() { | ||
18 | defer func() { | 20 | defer func() { |
19 | c.ResposeJson(msg) | 21 | c.ResposeJson(msg) |
20 | }() | 22 | }() |
21 | - // var request *protocol.ConfigScoreRequest | ||
22 | - // if err := json.Unmarshal(this.Ctx.Input.RequestBody, &request); err != nil { | ||
23 | - // log.Error("json 解析失败", err) | ||
24 | - // msg = protocol.BadRequestParam("1") | ||
25 | - // return | ||
26 | - // } | ||
27 | - // uid := this.GetUserId() | ||
28 | - // companyId := this.GetCompanyId() | ||
29 | - msg = protocol.NewReturnResponse(nil, nil) | 23 | + var param protocol.RequestAuditList |
24 | + if err := json.Unmarshal(c.Ctx.Input.RequestBody, ¶m); err != nil { | ||
25 | + log.Error("json 解析失败", err) | ||
26 | + msg = protocol.BadRequestParam("1") | ||
27 | + return | ||
28 | + } | ||
29 | + uid := c.GetUserId() | ||
30 | + companyId := c.GetCompanyId() | ||
31 | + list, err := serveaudit.GetAuditList(param, companyId, uid) | ||
32 | + msg = protocol.NewReturnResponse(list, err) | ||
30 | return | 33 | return |
31 | } | 34 | } |
32 | 35 | ||
33 | -func (c *AuditController) Test() { | ||
34 | - data, err := serverbac.GetUserPermission(11) | ||
35 | - fmt.Println(err) | ||
36 | - bt, err := json.Marshal(data) | ||
37 | - fmt.Println(err) | ||
38 | - fmt.Println(string(bt)) | 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 | ||
39 | } | 61 | } |
@@ -43,8 +43,8 @@ func (this *BaseController) GetAppHead() (appHead protocol.BaseHeader) { | @@ -43,8 +43,8 @@ func (this *BaseController) GetAppHead() (appHead protocol.BaseHeader) { | ||
43 | func (this *BaseController) Finish() { | 43 | func (this *BaseController) Finish() { |
44 | strByte, _ := json.Marshal(this.Data["json"]) | 44 | strByte, _ := json.Marshal(this.Data["json"]) |
45 | length := len(strByte) | 45 | length := len(strByte) |
46 | - if length > 5000 { | ||
47 | - log.Info(fmt.Sprintf("<====Send to client: RspBodyData: %s......", string(strByte[:5000]))) | 46 | + if length > 1000 { |
47 | + log.Info(fmt.Sprintf("<====Send to client: RspBodyData: %s......", string(strByte[:1000]))) | ||
48 | } else { | 48 | } else { |
49 | log.Info(fmt.Sprintf("<====Send to client: RspBodyData: %s", string(strByte))) | 49 | log.Info(fmt.Sprintf("<====Send to client: RspBodyData: %s", string(strByte))) |
50 | } | 50 | } |
models/chance.go
0 → 100644
1 | +package models | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "time" | ||
6 | + | ||
7 | + "github.com/astaxie/beego/orm" | ||
8 | +) | ||
9 | + | ||
10 | +type Chance struct { | ||
11 | + Id int64 `orm:"column(id);pk" description:"id 主键"` | ||
12 | + UserId int64 `orm:"column(user_id)" description:"表user_company.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 机会类型 "` | ||
15 | + CompanyId int64 `orm:"column(company_id)" description:"表company.id 公司编号"` | ||
16 | + AuditTemplateId int64 `orm:"column(audit_template_id)" description:"表audit_template.id 所属审批模板编号"` | ||
17 | + AuditTemplateConfig string `orm:"column(audit_template_config);size(255);null" description:"模板配置 (存旧的配置信息,对新改动的不影响)"` | ||
18 | + Content string `orm:"column(content)" description:"格式化后的文本内容"` | ||
19 | + SourceContent string `orm:"column(source_content)" description:"原始表单内容 json"` | ||
20 | + ViewTotal int `orm:"column(view_total)" description:"查看总数"` | ||
21 | + CommentTotal int `orm:"column(comment_total)" description:"评论总数"` | ||
22 | + ZanTotal int `orm:"column(zan_total)" description:"点赞总数"` | ||
23 | + ReviewStatus int8 `orm:"column(review_status)" description:"审核状态 0:待处理 1:待审核 2:被退回 3:已通过 "` | ||
24 | + EnableStatus int8 `orm:"column(enable_status)" description:"有效状态 0:无效 1:有效 "` | ||
25 | + UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"` | ||
26 | + CreateAt time.Time `orm:"column(create_at);type(timestamp)" description:"创建时间"` | ||
27 | + BasicScore float64 `orm:"column(basic_score);null;digits(4);decimals(1)" description:"基础评分"` | ||
28 | + ExtraScore float64 `orm:"column(extra_score);null;digits(4);decimals(1)" description:"附加评分"` | ||
29 | + ValueScore float64 `orm:"column(value_score);null;digits(4);decimals(1)" description:"价值评分"` | ||
30 | + DiscoveryScore float64 `orm:"column(discovery_score);null;digits(4);decimals(1)" description:"发现得分(发现得分=基础评分*系数 + 附加评分*系数 + 价值评分*系数)"` | ||
31 | + PublishStatus int `orm:"column(publish_status)" description:"公开状态 -1 未公开、1部门公开、2公司公开"` | ||
32 | + AuditLevel int `orm:"column(audit_level)" description:"当前审批步骤"` | ||
33 | + ApproveData string `orm:"column(approve_data);size(500);null" description:"公开数据 (公开状态 公开对象)"` | ||
34 | +} | ||
35 | + | ||
36 | +func (t *Chance) TableName() string { | ||
37 | + return "chance" | ||
38 | +} | ||
39 | + | ||
40 | +func init() { | ||
41 | + orm.RegisterModel(new(Chance)) | ||
42 | +} | ||
43 | + | ||
44 | +// 公开状态 0未设置、1部门公开、2公司公开 | ||
45 | +const ( | ||
46 | + ChancePublishStatus0 int = 0 | ||
47 | + ChancePublishStatus1 int = 1 | ||
48 | + ChancePublishStatus2 int = 2 | ||
49 | +) | ||
50 | + | ||
51 | +var ChancePublishStatusMap = map[int]string{ | ||
52 | + ChancePublishStatus0: "未设置", | ||
53 | + ChancePublishStatus1: "部门公开", | ||
54 | + ChancePublishStatus2: "公司公开", | ||
55 | +} | ||
56 | + | ||
57 | +// 审核状态 0:待处理 1:待审核 2:被退回 3:已通过 | ||
58 | +const ( | ||
59 | + ChanceReviewStatusWait int = 0 | ||
60 | + ChanceReviewStatusIng int = 1 | ||
61 | + ChanceReviewStatusNo int = 2 | ||
62 | + ChanceReviewStatusYes int = 3 | ||
63 | +) | ||
64 | + | ||
65 | +var ChanceReviewStatusMap = map[int]string{ | ||
66 | + ChanceReviewStatusWait: "待处理", | ||
67 | + ChanceReviewStatusIng: "待审核", | ||
68 | + ChanceReviewStatusNo: "被退回", | ||
69 | + ChanceReviewStatusYes: "已通过", | ||
70 | +} | ||
71 | + | ||
72 | +//有效状态 0:无效 1:有效 | ||
73 | +const ( | ||
74 | + ChanceEnableStatusYes int = 1 | ||
75 | + ChanceEnableStatusNo int = 0 | ||
76 | +) | ||
77 | + | ||
78 | +var ChanceEnableStatusMap = map[int]string{ | ||
79 | + 0: "无效", | ||
80 | + 1: "有效", | ||
81 | +} | ||
82 | + | ||
83 | +// AddChance insert a new Chance into database and returns | ||
84 | +// last inserted Id on success. | ||
85 | +func AddChance(m *Chance) (id int64, err error) { | ||
86 | + o := orm.NewOrm() | ||
87 | + id, err = o.Insert(m) | ||
88 | + return | ||
89 | +} | ||
90 | + | ||
91 | +// GetChanceById retrieves Chance by Id. Returns error if | ||
92 | +// Id doesn't exist | ||
93 | +func GetChanceById(id int64) (v *Chance, err error) { | ||
94 | + o := orm.NewOrm() | ||
95 | + v = &Chance{Id: id} | ||
96 | + if err = o.Read(v); err == nil { | ||
97 | + return v, nil | ||
98 | + } | ||
99 | + return nil, err | ||
100 | +} | ||
101 | + | ||
102 | +// UpdateChance updates Chance by Id and returns error if | ||
103 | +// the record to be updated doesn't exist | ||
104 | +func UpdateChanceById(m *Chance, col []string) (err error) { | ||
105 | + o := orm.NewOrm() | ||
106 | + var num int64 | ||
107 | + if num, err = o.Update(m, col...); err == nil { | ||
108 | + fmt.Println("Number of records updated in database:", num) | ||
109 | + } | ||
110 | + return | ||
111 | +} |
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"` //二级分类 |
@@ -258,5 +259,11 @@ type RspAuditList struct { | @@ -258,5 +259,11 @@ type RspAuditList struct { | ||
258 | ReviewStatus int `json:"review_status"` //审批状态 | 259 | ReviewStatus int `json:"review_status"` //审批状态 |
259 | ReviewStatusName string `json:"review_status_name"` | 260 | ReviewStatusName string `json:"review_status_name"` |
260 | EnableStatus int `json:"enable_status"` | 261 | EnableStatus int `json:"enable_status"` |
261 | - EnableStatusName int `json:"enable_status_name"` | 262 | + EnableStatusName string `json:"enable_status_name"` |
263 | +} | ||
264 | + | ||
265 | +type ChanceFlowLog struct { | ||
266 | + CreateTime string `json:"create_time"` | ||
267 | + Content string `json:"content"` | ||
268 | + UserrName string `json:"user_name"` | ||
262 | } | 269 | } |
@@ -64,3 +64,16 @@ type RoleHasUser struct { | @@ -64,3 +64,16 @@ type RoleHasUser struct { | ||
64 | UserCompanyId int64 `json:"user_company_id" orm:"column(user_company_id)"` | 64 | UserCompanyId int64 `json:"user_company_id" orm:"column(user_company_id)"` |
65 | Name string `json:"name" orm:"column(nick_name)"` | 65 | Name string `json:"name" orm:"column(nick_name)"` |
66 | } | 66 | } |
67 | + | ||
68 | +//下拉选择框的内容模板 -机会二级分类 | ||
69 | +type TemplateBase struct { | ||
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 | +} | ||
74 | + | ||
75 | +//下拉选择框的内容机会分类 - 机会一级分类 | ||
76 | +type ChanceTypeBase struct { | ||
77 | + ChanceTypeId int64 `orm:"column(chance_type_id)" json:"chance_type_id"` | ||
78 | + Name string `orm:"column(name)" json:"name"` | ||
79 | +} |
@@ -75,5 +75,21 @@ type ResponseRoleMenus struct { | @@ -75,5 +75,21 @@ type ResponseRoleMenus struct { | ||
75 | MenuId []int64 `json:"menu_ids"` | 75 | MenuId []int64 `json:"menu_ids"` |
76 | } | 76 | } |
77 | 77 | ||
78 | -// type ResponseRolePermission struct { | ||
79 | -// } | 78 | +type ResponseUserHasMenu struct { |
79 | + Id int64 `json:"id" orm:"column(id)"` | ||
80 | + Name string `json:"name" orm:"column(name)"` | ||
81 | + Icon string `json:"icon" orm:"column(icon)"` | ||
82 | + ParentId int64 `json:"parent_id" orm:"column(parent_id)"` | ||
83 | + SeniorStatus int8 `json:"senior_status" orm:"column(senior_status)"` | ||
84 | + Code string `json:"code" orm:"column(code)"` | ||
85 | + Sort int `json:"sort" orm:"column(sort)"` | ||
86 | + Status int `json:"status" orm:"column(status)"` | ||
87 | +} | ||
88 | + | ||
89 | +func (c *ResponseUserHasMenu) StatusYes() { | ||
90 | + c.Status = 1 | ||
91 | +} | ||
92 | + | ||
93 | +func (c *ResponseUserHasMenu) StatusNo() { | ||
94 | + c.Status = 0 | ||
95 | +} |
@@ -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 | ||
@@ -130,5 +131,4 @@ func init() { | @@ -130,5 +131,4 @@ func init() { | ||
130 | beego.SetStaticPath("/file/opp", beego.AppConfig.String("file_save_path")) | 131 | beego.SetStaticPath("/file/opp", beego.AppConfig.String("file_save_path")) |
131 | beego.SetStaticPath("/static", "./static") | 132 | beego.SetStaticPath("/static", "./static") |
132 | 133 | ||
133 | - beego.Router("/test", &controllers.AuditController{}, "get:Test") | ||
134 | } | 134 | } |
1 | package audit | 1 | package audit |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "encoding/json" | ||
5 | + "fmt" | ||
4 | "oppmg/common/log" | 6 | "oppmg/common/log" |
5 | "oppmg/models" | 7 | "oppmg/models" |
6 | "oppmg/protocol" | 8 | "oppmg/protocol" |
@@ -21,9 +23,11 @@ type SqlData struct { | @@ -21,9 +23,11 @@ type SqlData struct { | ||
21 | EnableStatus int `orm:"column(enable_status)"` | 23 | EnableStatus int `orm:"column(enable_status)"` |
22 | DiscoveryScore string `orm:"column(discovery_score)"` | 24 | DiscoveryScore string `orm:"column(discovery_score)"` |
23 | CommentTotal string `orm:"column(comment_total)"` | 25 | CommentTotal string `orm:"column(comment_total)"` |
26 | + Code string `orm:"column(code)"` | ||
27 | + TemplateName string `orm:"column(template_name)"` | ||
24 | } | 28 | } |
25 | 29 | ||
26 | -func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.ResponseAuditList, error) { | 30 | +func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64) (protocol.ResponseAuditList, error) { |
27 | 31 | ||
28 | var ( | 32 | var ( |
29 | datasql = strings.Builder{} | 33 | datasql = strings.Builder{} |
@@ -31,7 +35,7 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | @@ -31,7 +35,7 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | ||
31 | data []SqlData | 35 | data []SqlData |
32 | cnt int | 36 | cnt int |
33 | err error | 37 | err error |
34 | - //listdata = make([]protocol.RspAuditList, 0) | 38 | + cond []interface{} |
35 | ) | 39 | ) |
36 | returnData := protocol.ResponseAuditList{ | 40 | returnData := protocol.ResponseAuditList{ |
37 | ResponsePageInfo: protocol.ResponsePageInfo{ | 41 | ResponsePageInfo: protocol.ResponsePageInfo{ |
@@ -40,15 +44,63 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | @@ -40,15 +44,63 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | ||
40 | }, | 44 | }, |
41 | List: make([]protocol.RspAuditList, 0), | 45 | List: make([]protocol.RspAuditList, 0), |
42 | } | 46 | } |
43 | - dataStart := (param.PageIndex - 1) * param.PageSize | ||
44 | - datasql.WriteString(`SELECT id,user_id,department_id,audit_template_id,chance_type_id | ||
45 | - ,publish_status,create_at,review_status,enable_status | ||
46 | - ,discovery_score,comment_total | ||
47 | - FROM chance | ||
48 | - limit ?,? `) | 47 | + datasql.WriteString(`SELECT a.id,a.user_id,a.department_id,a.audit_template_id,a.chance_type_id |
48 | + ,a.publish_status,a.create_at,a.review_status,a.enable_status | ||
49 | + ,a.discovery_score,a.comment_total,b.name AS template_name ,b.code | ||
50 | + FROM chance AS a | ||
51 | + JOIN audit_template AS b on a.audit_template_id = b.id | ||
52 | + where a.company_id=? `) | ||
49 | 53 | ||
50 | - countsql.WriteString(`SELECT count(*) FROM chance`) | ||
51 | - err = utils.ExecuteQueryOne(&cnt, countsql.String()) | 54 | + countsql.WriteString(`SELECT count(*) FROM chance as a |
55 | + JOIN audit_template AS b on a.audit_template_id = b.id | ||
56 | + where a.company_id=? `) | ||
57 | + cond = append(cond, companyid) | ||
58 | + if param.ChanceTypeId > 0 { | ||
59 | + //一级分类过滤 | ||
60 | + cond = append(cond, param.ChanceTypeId) | ||
61 | + s := ` And a.chance_type_id=? ` | ||
62 | + datasql.WriteString(s) | ||
63 | + countsql.WriteString(s) | ||
64 | + } | ||
65 | + if param.TempalteId > 0 { | ||
66 | + cond = append(cond, param.TempalteId) | ||
67 | + s := ` AND a.audit_template_id=? ` | ||
68 | + datasql.WriteString(s) | ||
69 | + countsql.WriteString(s) | ||
70 | + } | ||
71 | + if param.PublishStatus >= 0 { | ||
72 | + cond = append(cond, param.PublishStatus) | ||
73 | + s := ` And a.publish_status=? ` | ||
74 | + datasql.WriteString(s) | ||
75 | + countsql.WriteString(s) | ||
76 | + } | ||
77 | + if param.EnableStatus >= 0 { | ||
78 | + cond = append(cond, param.EnableStatus) | ||
79 | + s := ` AND a.enable_status=? ` | ||
80 | + datasql.WriteString(s) | ||
81 | + countsql.WriteString(s) | ||
82 | + } | ||
83 | + if param.ReviewStatus >= 0 { | ||
84 | + cond = append(cond, param.ReviewStatus) | ||
85 | + s := ` AND a.review_status=? ` | ||
86 | + datasql.WriteString(s) | ||
87 | + countsql.WriteString(s) | ||
88 | + } | ||
89 | + if param.CreateTimeBegin > 0 && param.CreateTimeEnd > 0 { | ||
90 | + cond = append(cond, param.CreateTimeBegin, param.CreateTimeEnd) | ||
91 | + s := ` AND (UNIX_TIMESTAMP(a.create_at) BETWEEN ? AND ? ) ` | ||
92 | + datasql.WriteString(s) | ||
93 | + countsql.WriteString(s) | ||
94 | + } | ||
95 | + if len(param.Code) > 0 { | ||
96 | + cond = append(cond, param.Code) | ||
97 | + s := ` And b.code=? ` | ||
98 | + datasql.WriteString(s) | ||
99 | + countsql.WriteString(s) | ||
100 | + } | ||
101 | + dataStart := (param.PageIndex - 1) * param.PageSize | ||
102 | + datasql.WriteString(fmt.Sprintf(` limit %d,%d `, dataStart, param.PageSize)) | ||
103 | + err = utils.ExecuteQueryOne(&cnt, countsql.String(), cond...) | ||
52 | if err != nil { | 104 | if err != nil { |
53 | log.Error("EXCUTE SQL ERR:%s", err) | 105 | log.Error("EXCUTE SQL ERR:%s", err) |
54 | return returnData, nil | 106 | return returnData, nil |
@@ -56,7 +108,7 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | @@ -56,7 +108,7 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | ||
56 | if cnt <= 0 { | 108 | if cnt <= 0 { |
57 | return returnData, nil | 109 | return returnData, nil |
58 | } | 110 | } |
59 | - err = utils.ExecuteQueryOne(&data, datasql.String(), dataStart, param.PageSize) | 111 | + err = utils.ExecuteQueryAll(&data, datasql.String(), cond...) |
60 | if err != nil { | 112 | if err != nil { |
61 | log.Error("EXCUTE SQL ERR:%s", err) | 113 | log.Error("EXCUTE SQL ERR:%s", err) |
62 | return returnData, nil | 114 | return returnData, nil |
@@ -64,10 +116,17 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | @@ -64,10 +116,17 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | ||
64 | for _, v := range data { | 116 | for _, v := range data { |
65 | t := v.CreateAt.Unix() | 117 | t := v.CreateAt.Unix() |
66 | item := protocol.RspAuditList{ | 118 | item := protocol.RspAuditList{ |
67 | - Id: v.Id, | ||
68 | - EnableStatus: v.EnableStatus, | ||
69 | - PublishStatus: v.PublishStatus, | 119 | + Id: fmt.Sprint(v.Id), |
120 | + EnableStatus: v.EnableStatus, | ||
121 | + EnableStatusName: models.ChanceEnableStatusMap[v.EnableStatus], | ||
122 | + PublishStatus: v.PublishStatus, | ||
123 | + PublishStatusName: models.ChancePublishStatusMap[v.PublishStatus], | ||
124 | + ReviewStatus: v.ReviewStatus, | ||
125 | + ReviewStatusName: models.ChanceReviewStatusMap[v.ReviewStatus], | ||
126 | + Code: v.Code, | ||
127 | + TemplateName: v.TemplateName, | ||
70 | } | 128 | } |
129 | + | ||
71 | if t < 0 { | 130 | if t < 0 { |
72 | item.CreateTime = 0 | 131 | item.CreateTime = 0 |
73 | } else { | 132 | } else { |
@@ -79,15 +138,61 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | @@ -79,15 +138,61 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | ||
79 | if d, err := models.GetDepartmentById(v.DepartmentId); err == nil { | 138 | if d, err := models.GetDepartmentById(v.DepartmentId); err == nil { |
80 | item.Department = d.Name | 139 | item.Department = d.Name |
81 | } | 140 | } |
82 | - if at, err := models.GetAuditTemplateById(v.AuditTemplateId); err == nil { | ||
83 | - item.TemplateName = at.Name | ||
84 | - item.Code = at.Code | ||
85 | - } | ||
86 | if ct, err := models.GetChanceTypeById(v.ChanceTypeId); err == nil { | 141 | if ct, err := models.GetChanceTypeById(v.ChanceTypeId); err == nil { |
87 | item.ChanceType = ct.Name | 142 | item.ChanceType = ct.Name |
88 | } | 143 | } |
89 | returnData.List = append(returnData.List, item) | 144 | returnData.List = append(returnData.List, item) |
90 | 145 | ||
91 | } | 146 | } |
147 | + returnData.TotalPage = cnt | ||
148 | + returnData.CurrentPage = param.PageIndex | ||
149 | + return returnData, nil | ||
150 | +} | ||
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 | + | ||
92 | return returnData, nil | 197 | return returnData, nil |
93 | } | 198 | } |
@@ -332,16 +332,27 @@ func UserHasCompanys(userid int64) ([]protocol.MeCompany, error) { | @@ -332,16 +332,27 @@ func UserHasCompanys(userid int64) ([]protocol.MeCompany, error) { | ||
332 | return mecompanys, nil | 332 | return mecompanys, nil |
333 | } | 333 | } |
334 | 334 | ||
335 | -func GetUserHasMenu(userid, companyid int64) ([]protocol.PermissionItem, error) { | 335 | +func GetUserHasMenu(userid, companyid int64) ([]protocol.ResponseUserHasMenu, error) { |
336 | var ( | 336 | var ( |
337 | - list = make([]protocol.PermissionItem, 0) | 337 | + list = make([]protocol.ResponseUserHasMenu, 0) |
338 | err error | 338 | err error |
339 | companyinfo *models.Company | 339 | companyinfo *models.Company |
340 | ucompany *models.UserCompany | 340 | ucompany *models.UserCompany |
341 | ) | 341 | ) |
342 | + const datasql string = `SELECT id,name,icon,parent_id,senior_status,sort,code | ||
343 | + FROM menu WHERE enabled=1 ORDER BY sort ` | ||
344 | + err = utils.ExecuteQueryAll(&list, datasql) | ||
345 | + if err != nil { | ||
346 | + log.Error("EXECUTE SQL err:%s", err) | ||
347 | + return nil, protocol.NewErrWithMessage("1") | ||
348 | + } | ||
342 | companyinfo, err = models.GetCompanyById(companyid) | 349 | companyinfo, err = models.GetCompanyById(companyid) |
343 | if companyinfo.AdminId == userid { | 350 | if companyinfo.AdminId == userid { |
344 | - return getAdminHasMenu() | 351 | + //主管人员 |
352 | + for i := range list { | ||
353 | + list[i].StatusYes() | ||
354 | + } | ||
355 | + return list, nil | ||
345 | } | 356 | } |
346 | //非主管人员 | 357 | //非主管人员 |
347 | ucompany, err = models.GetUserCompanyBy(userid, companyid) | 358 | ucompany, err = models.GetUserCompanyBy(userid, companyid) |
@@ -349,43 +360,43 @@ func GetUserHasMenu(userid, companyid int64) ([]protocol.PermissionItem, error) | @@ -349,43 +360,43 @@ func GetUserHasMenu(userid, companyid int64) ([]protocol.PermissionItem, error) | ||
349 | log.Error("user_company数据获取失败:%s", err) | 360 | log.Error("user_company数据获取失败:%s", err) |
350 | return list, protocol.NewErrWithMessage("1") | 361 | return list, protocol.NewErrWithMessage("1") |
351 | } | 362 | } |
352 | - const datasql string = `SELECT DISTINCT(a.menu_id) | 363 | + const datasql2 string = `SELECT DISTINCT(a.menu_id) |
353 | FROM role_menu AS a | 364 | FROM role_menu AS a |
354 | JOIN user_role AS b ON a.role_id = b.role_id | 365 | JOIN user_role AS b ON a.role_id = b.role_id |
355 | JOIN role AS c ON a.role_id = c.id | 366 | JOIN role AS c ON a.role_id = c.id |
356 | WHERE b.user_company_id=? AND c.delete_at =0 ` | 367 | WHERE b.user_company_id=? AND c.delete_at =0 ` |
357 | - var menuids []string | 368 | + var menuids []int64 |
358 | err = utils.ExecuteQueryAll(&menuids, datasql, ucompany.Id) | 369 | err = utils.ExecuteQueryAll(&menuids, datasql, ucompany.Id) |
359 | if err != nil { | 370 | if err != nil { |
360 | log.Error("EXECUTE SQL err:%s", err) | 371 | log.Error("EXECUTE SQL err:%s", err) |
361 | return nil, protocol.NewErrWithMessage("1") | 372 | return nil, protocol.NewErrWithMessage("1") |
362 | } | 373 | } |
363 | - datasql2 := `SELECT id,name,icon,parent_id,senior_status,sort,code | ||
364 | - FROM menu WHERE enabled=1 AND id in(%s) ORDER BY sort` | ||
365 | - datasql2 = fmt.Sprintf(datasql2, strings.Join(menuids, ",")) | ||
366 | - err = utils.ExecuteQueryAll(&list, datasql2) | ||
367 | - if err != nil { | ||
368 | - log.Error("EXECUTE SQL err:%s", err) | ||
369 | - return nil, protocol.NewErrWithMessage("1") | 374 | + for i := range list { |
375 | + for _, v := range menuids { | ||
376 | + if list[i].Id == v { | ||
377 | + list[i].StatusYes() | ||
378 | + break | ||
379 | + } | ||
380 | + } | ||
370 | } | 381 | } |
371 | return list, nil | 382 | return list, nil |
372 | } | 383 | } |
373 | 384 | ||
374 | //主管拥有全部的菜单 | 385 | //主管拥有全部的菜单 |
375 | -func getAdminHasMenu() ([]protocol.PermissionItem, error) { | ||
376 | - const datasql string = `SELECT id,name,icon,parent_id,senior_status,sort,code | ||
377 | - FROM menu WHERE enabled=1 ORDER BY sort ` | ||
378 | - var ( | ||
379 | - list = make([]protocol.PermissionItem, 0) | ||
380 | - err error | ||
381 | - ) | ||
382 | - err = utils.ExecuteQueryAll(&list, datasql) | ||
383 | - if err != nil { | ||
384 | - log.Error("EXECUTE SQL err:%s", err) | ||
385 | - return nil, protocol.NewErrWithMessage("1") | ||
386 | - } | ||
387 | - return list, nil | ||
388 | -} | 386 | +// func getAdminHasMenu() ([]protocol.PermissionItem, error) { |
387 | +// const datasql string = `SELECT id,name,icon,parent_id,senior_status,sort,code | ||
388 | +// FROM menu WHERE enabled=1 ORDER BY sort ` | ||
389 | +// var ( | ||
390 | +// list = make([]protocol.PermissionItem, 0) | ||
391 | +// err error | ||
392 | +// ) | ||
393 | +// err = utils.ExecuteQueryAll(&list, datasql) | ||
394 | +// if err != nil { | ||
395 | +// log.Error("EXECUTE SQL err:%s", err) | ||
396 | +// return nil, protocol.NewErrWithMessage("1") | ||
397 | +// } | ||
398 | +// return list, nil | ||
399 | +// } | ||
389 | 400 | ||
390 | func LoginAuthBySmsCode(phone string, code string) (protocol.LoginAuthToken, error) { | 401 | func LoginAuthBySmsCode(phone string, code string) (protocol.LoginAuthToken, error) { |
391 | var ( | 402 | var ( |
@@ -157,3 +157,30 @@ func SelectorUserAndDepartment(departid int64, companyId int64) (*protocol.Depar | @@ -157,3 +157,30 @@ func SelectorUserAndDepartment(departid int64, companyId int64) (*protocol.Depar | ||
157 | departsUser.Departments = departbase | 157 | departsUser.Departments = departbase |
158 | return &departsUser, nil | 158 | return &departsUser, nil |
159 | } | 159 | } |
160 | + | ||
161 | +//获取机会二级分类 | ||
162 | +func SelectGetTemplateList(companyid int64) []protocol.TemplateBase { | ||
163 | + datasql := `SELECT id AS template_id,chance_type_id,name | ||
164 | + FROM audit_template | ||
165 | + where company_id = ? AND enable_status = 1` | ||
166 | + data := make([]protocol.TemplateBase, 0) | ||
167 | + err := utils.ExecuteQueryAll(&data, datasql, companyid) | ||
168 | + if err != nil { | ||
169 | + log.Error("EXECUTE SQL ERR :%s", err) | ||
170 | + } | ||
171 | + return data | ||
172 | + | ||
173 | +} | ||
174 | + | ||
175 | +//获取机会一级级分类 | ||
176 | +func SeleteGetChanceTypeList(companyid int64) []protocol.ChanceTypeBase { | ||
177 | + datasql := ` SELECT id AS chance_type_id,name | ||
178 | + FROM chance_type | ||
179 | + WHERE company_id = ?` | ||
180 | + data := make([]protocol.ChanceTypeBase, 0) | ||
181 | + err := utils.ExecuteQueryAll(&data, datasql, companyid) | ||
182 | + if err != nil { | ||
183 | + log.Error("EXECUTE SQL ERR :%s", err) | ||
184 | + } | ||
185 | + return data | ||
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) |
@@ -251,7 +256,7 @@ func GetSetOpportunity(roleid int64, companyid int64) (*OptionOpportunity, error | @@ -251,7 +256,7 @@ func GetSetOpportunity(roleid int64, companyid int64) (*OptionOpportunity, error | ||
251 | log.Error("获取部门失败GetDepartmentById(%d):%s", v.Id, err) | 256 | log.Error("获取部门失败GetDepartmentById(%d):%s", v.Id, err) |
252 | continue | 257 | continue |
253 | } | 258 | } |
254 | - if d.DeleteAt.Unix() <= 0 { | 259 | + if d.DeleteAt.Unix() > 0 { |
255 | //部门已被删除 | 260 | //部门已被删除 |
256 | continue | 261 | continue |
257 | } | 262 | } |
@@ -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{}, |
-
请 注册 或 登录 后发表评论