正在显示
10 个修改的文件
包含
298 行增加
和
68 行删除
@@ -2,9 +2,9 @@ package controllers | @@ -2,9 +2,9 @@ package controllers | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "encoding/json" | 4 | "encoding/json" |
5 | - "fmt" | 5 | + "oppmg/common/log" |
6 | "oppmg/protocol" | 6 | "oppmg/protocol" |
7 | - serverbac "oppmg/services/rbac" | 7 | + serveaudit "oppmg/services/audit" |
8 | ) | 8 | ) |
9 | 9 | ||
10 | type AuditController struct { | 10 | type AuditController struct { |
@@ -18,22 +18,23 @@ func (c *AuditController) AuditList() { | @@ -18,22 +18,23 @@ func (c *AuditController) AuditList() { | ||
18 | defer func() { | 18 | defer func() { |
19 | c.ResposeJson(msg) | 19 | c.ResposeJson(msg) |
20 | }() | 20 | }() |
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) | 21 | + var param protocol.RequestAuditList |
22 | + if err := json.Unmarshal(c.Ctx.Input.RequestBody, ¶m); err != nil { | ||
23 | + log.Error("json 解析失败", err) | ||
24 | + msg = protocol.BadRequestParam("1") | ||
25 | + return | ||
26 | + } | ||
27 | + uid := c.GetUserId() | ||
28 | + companyId := c.GetCompanyId() | ||
29 | + list, err := serveaudit.GetAuditList(param, companyId, uid) | ||
30 | + msg = protocol.NewReturnResponse(list, err) | ||
30 | return | 31 | return |
31 | } | 32 | } |
32 | 33 | ||
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)) | ||
39 | -} | 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 | +// } |
@@ -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 int `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 int) (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 | +} |
@@ -258,5 +258,5 @@ type RspAuditList struct { | @@ -258,5 +258,5 @@ type RspAuditList struct { | ||
258 | ReviewStatus int `json:"review_status"` //审批状态 | 258 | ReviewStatus int `json:"review_status"` //审批状态 |
259 | ReviewStatusName string `json:"review_status_name"` | 259 | ReviewStatusName string `json:"review_status_name"` |
260 | EnableStatus int `json:"enable_status"` | 260 | EnableStatus int `json:"enable_status"` |
261 | - EnableStatusName int `json:"enable_status_name"` | 261 | + EnableStatusName string `json:"enable_status_name"` |
262 | } | 262 | } |
@@ -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)"` | ||
71 | + ChanceTypeId int64 `orm:"column(chance_type_id)"` | ||
72 | + Name string `orm:"column(name)"` | ||
73 | +} | ||
74 | + | ||
75 | +//下拉选择框的内容机会分类 - 机会一级分类 | ||
76 | +type ChanceTypeBase struct { | ||
77 | + ChanceTypeId int64 `orm:"column(chance_type_id)"` | ||
78 | + Name string `orm:"column(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 | +} |
@@ -130,5 +130,4 @@ func init() { | @@ -130,5 +130,4 @@ func init() { | ||
130 | beego.SetStaticPath("/file/opp", beego.AppConfig.String("file_save_path")) | 130 | beego.SetStaticPath("/file/opp", beego.AppConfig.String("file_save_path")) |
131 | beego.SetStaticPath("/static", "./static") | 131 | beego.SetStaticPath("/static", "./static") |
132 | 132 | ||
133 | - beego.Router("/test", &controllers.AuditController{}, "get:Test") | ||
134 | } | 133 | } |
1 | package audit | 1 | package audit |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "fmt" | ||
4 | "oppmg/common/log" | 5 | "oppmg/common/log" |
5 | "oppmg/models" | 6 | "oppmg/models" |
6 | "oppmg/protocol" | 7 | "oppmg/protocol" |
@@ -21,9 +22,11 @@ type SqlData struct { | @@ -21,9 +22,11 @@ type SqlData struct { | ||
21 | EnableStatus int `orm:"column(enable_status)"` | 22 | EnableStatus int `orm:"column(enable_status)"` |
22 | DiscoveryScore string `orm:"column(discovery_score)"` | 23 | DiscoveryScore string `orm:"column(discovery_score)"` |
23 | CommentTotal string `orm:"column(comment_total)"` | 24 | CommentTotal string `orm:"column(comment_total)"` |
25 | + Code string `orm:"column(code)"` | ||
26 | + TemplateName string `orm:"column(template_name)"` | ||
24 | } | 27 | } |
25 | 28 | ||
26 | -func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.ResponseAuditList, error) { | 29 | +func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64) (protocol.ResponseAuditList, error) { |
27 | 30 | ||
28 | var ( | 31 | var ( |
29 | datasql = strings.Builder{} | 32 | datasql = strings.Builder{} |
@@ -31,7 +34,7 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | @@ -31,7 +34,7 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | ||
31 | data []SqlData | 34 | data []SqlData |
32 | cnt int | 35 | cnt int |
33 | err error | 36 | err error |
34 | - //listdata = make([]protocol.RspAuditList, 0) | 37 | + cond []interface{} |
35 | ) | 38 | ) |
36 | returnData := protocol.ResponseAuditList{ | 39 | returnData := protocol.ResponseAuditList{ |
37 | ResponsePageInfo: protocol.ResponsePageInfo{ | 40 | ResponsePageInfo: protocol.ResponsePageInfo{ |
@@ -40,15 +43,63 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | @@ -40,15 +43,63 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | ||
40 | }, | 43 | }, |
41 | List: make([]protocol.RspAuditList, 0), | 44 | List: make([]protocol.RspAuditList, 0), |
42 | } | 45 | } |
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 ?,? `) | 46 | + datasql.WriteString(`SELECT a.id,a.user_id,a.department_id,a.audit_template_id,a.chance_type_id |
47 | + ,a.publish_status,a.create_at,a.review_status,a.enable_status | ||
48 | + ,a.discovery_score,a.comment_total,b.name AS template_name ,b.code | ||
49 | + FROM chance AS a | ||
50 | + JOIN audit_template AS b on a.audit_template_id = b.id | ||
51 | + where a.company_id=? `) | ||
49 | 52 | ||
50 | - countsql.WriteString(`SELECT count(*) FROM chance`) | ||
51 | - err = utils.ExecuteQueryOne(&cnt, countsql.String()) | 53 | + countsql.WriteString(`SELECT count(*) FROM chance as a |
54 | + JOIN audit_template AS b on a.audit_template_id = b.id | ||
55 | + where a.company_id=? `) | ||
56 | + cond = append(cond, companyid) | ||
57 | + if param.ChanceTypeId > 0 { | ||
58 | + //一级分类过滤 | ||
59 | + cond = append(cond, param.ChanceTypeId) | ||
60 | + s := ` And a.chance_type_id=? ` | ||
61 | + datasql.WriteString(s) | ||
62 | + countsql.WriteString(s) | ||
63 | + } | ||
64 | + if param.TempalteId > 0 { | ||
65 | + cond = append(cond, param.TempalteId) | ||
66 | + s := ` AND a.audit_template_id=? ` | ||
67 | + datasql.WriteString(s) | ||
68 | + countsql.WriteString(s) | ||
69 | + } | ||
70 | + if param.PublishStatus >= 0 { | ||
71 | + cond = append(cond, param.PublishStatus) | ||
72 | + s := ` And a.publish_status=? ` | ||
73 | + datasql.WriteString(s) | ||
74 | + countsql.WriteString(s) | ||
75 | + } | ||
76 | + if param.EnableStatus >= 0 { | ||
77 | + cond = append(cond, param.EnableStatus) | ||
78 | + s := ` AND a.enable_status=? ` | ||
79 | + datasql.WriteString(s) | ||
80 | + countsql.WriteString(s) | ||
81 | + } | ||
82 | + if param.ReviewStatus >= 0 { | ||
83 | + cond = append(cond, param.ReviewStatus) | ||
84 | + s := ` AND a.review_status=? ` | ||
85 | + datasql.WriteString(s) | ||
86 | + countsql.WriteString(s) | ||
87 | + } | ||
88 | + if param.CreateTimeBegin > 0 && param.CreateTimeEnd > 0 { | ||
89 | + cond = append(cond, param.CreateTimeBegin, param.CreateTimeEnd) | ||
90 | + s := ` AND (UNIX_TIMESTAMP(a.create_at) BETWEEN ? AND ? ) ` | ||
91 | + datasql.WriteString(s) | ||
92 | + countsql.WriteString(s) | ||
93 | + } | ||
94 | + if len(param.Code) > 0 { | ||
95 | + cond = append(cond, param.Code) | ||
96 | + s := ` And b.code=? ` | ||
97 | + datasql.WriteString(s) | ||
98 | + countsql.WriteString(s) | ||
99 | + } | ||
100 | + dataStart := (param.PageIndex - 1) * param.PageSize | ||
101 | + datasql.WriteString(fmt.Sprintf(` limit %d,%d `, dataStart, param.PageSize)) | ||
102 | + err = utils.ExecuteQueryOne(&cnt, countsql.String(), cond...) | ||
52 | if err != nil { | 103 | if err != nil { |
53 | log.Error("EXCUTE SQL ERR:%s", err) | 104 | log.Error("EXCUTE SQL ERR:%s", err) |
54 | return returnData, nil | 105 | return returnData, nil |
@@ -56,7 +107,7 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | @@ -56,7 +107,7 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | ||
56 | if cnt <= 0 { | 107 | if cnt <= 0 { |
57 | return returnData, nil | 108 | return returnData, nil |
58 | } | 109 | } |
59 | - err = utils.ExecuteQueryOne(&data, datasql.String(), dataStart, param.PageSize) | 110 | + err = utils.ExecuteQueryAll(&data, datasql.String(), cond...) |
60 | if err != nil { | 111 | if err != nil { |
61 | log.Error("EXCUTE SQL ERR:%s", err) | 112 | log.Error("EXCUTE SQL ERR:%s", err) |
62 | return returnData, nil | 113 | return returnData, nil |
@@ -64,10 +115,17 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | @@ -64,10 +115,17 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | ||
64 | for _, v := range data { | 115 | for _, v := range data { |
65 | t := v.CreateAt.Unix() | 116 | t := v.CreateAt.Unix() |
66 | item := protocol.RspAuditList{ | 117 | item := protocol.RspAuditList{ |
67 | - Id: v.Id, | ||
68 | - EnableStatus: v.EnableStatus, | ||
69 | - PublishStatus: v.PublishStatus, | 118 | + Id: v.Id, |
119 | + EnableStatus: v.EnableStatus, | ||
120 | + EnableStatusName: models.ChanceEnableStatusMap[v.EnableStatus], | ||
121 | + PublishStatus: v.PublishStatus, | ||
122 | + PublishStatusName: models.ChancePublishStatusMap[v.PublishStatus], | ||
123 | + ReviewStatus: v.ReviewStatus, | ||
124 | + ReviewStatusName: models.ChanceReviewStatusMap[v.ReviewStatus], | ||
125 | + Code: v.Code, | ||
126 | + TemplateName: v.TemplateName, | ||
70 | } | 127 | } |
128 | + | ||
71 | if t < 0 { | 129 | if t < 0 { |
72 | item.CreateTime = 0 | 130 | item.CreateTime = 0 |
73 | } else { | 131 | } else { |
@@ -79,15 +137,15 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | @@ -79,15 +137,15 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | ||
79 | if d, err := models.GetDepartmentById(v.DepartmentId); err == nil { | 137 | if d, err := models.GetDepartmentById(v.DepartmentId); err == nil { |
80 | item.Department = d.Name | 138 | item.Department = d.Name |
81 | } | 139 | } |
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 { | 140 | if ct, err := models.GetChanceTypeById(v.ChanceTypeId); err == nil { |
87 | item.ChanceType = ct.Name | 141 | item.ChanceType = ct.Name |
88 | } | 142 | } |
89 | returnData.List = append(returnData.List, item) | 143 | returnData.List = append(returnData.List, item) |
90 | 144 | ||
91 | } | 145 | } |
146 | + returnData.TotalPage = cnt | ||
147 | + returnData.CurrentPage = param.PageIndex | ||
92 | return returnData, nil | 148 | return returnData, nil |
93 | } | 149 | } |
150 | + | ||
151 | +// 机会管理的列表搜索项数据 |
@@ -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,24 @@ func SelectorUserAndDepartment(departid int64, companyId int64) (*protocol.Depar | @@ -157,3 +157,24 @@ 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() []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 | + utils.ExecuteQueryAll(&data, datasql) | ||
168 | + return data | ||
169 | + | ||
170 | +} | ||
171 | + | ||
172 | +//获取机会一级级分类 | ||
173 | +func SeleteGetChanceTypeList() []protocol.ChanceTypeBase { | ||
174 | + datasql := ` SELECT id AS chance_type_id,name | ||
175 | + FROM chance_type | ||
176 | + WHERE company_id = ?` | ||
177 | + data := make([]protocol.ChanceTypeBase, 0) | ||
178 | + utils.ExecuteQueryAll(&data, datasql) | ||
179 | + return data | ||
180 | +} |
-
请 注册 或 登录 后发表评论