作者 yangfu

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/mmm-go/oppmg into dev

1 -FROM golang:1.13 as builder 1 +FROM 192.168.0.243:5000/mmm/mmm-oppmg:20200110
2 2
3 # ENV GOPROXY https://goproxy.cn 3 # ENV GOPROXY https://goproxy.cn
4 ENV GOPATH /go 4 ENV GOPATH /go
@@ -39,7 +39,7 @@ func (c *AuditController) AuditList() { @@ -39,7 +39,7 @@ func (c *AuditController) AuditList() {
39 uid := c.GetUserId() 39 uid := c.GetUserId()
40 companyId := c.GetCompanyId() 40 companyId := c.GetCompanyId()
41 list, err := serveaudit.GetAuditList(param, companyId, uid) 41 list, err := serveaudit.GetAuditList(param, companyId, uid)
42 - msg = protocol.NewReturnResponse(list, err) 42 + msg = protocol.NewPageDataResponse(list, err)
43 return 43 return
44 } 44 }
45 45
@@ -8,6 +8,8 @@ import ( @@ -8,6 +8,8 @@ import (
8 "oppmg/utils/exceltool" 8 "oppmg/utils/exceltool"
9 "strconv" 9 "strconv"
10 10
  11 + serveauth "oppmg/services/auth"
  12 +
11 "github.com/astaxie/beego" 13 "github.com/astaxie/beego"
12 "github.com/astaxie/beego/context" 14 "github.com/astaxie/beego/context"
13 "github.com/astaxie/beego/validation" 15 "github.com/astaxie/beego/validation"
@@ -28,16 +30,24 @@ func (this *BaseController) Prepare() { @@ -28,16 +30,24 @@ func (this *BaseController) Prepare() {
28 this.Ctx.WriteString("") 30 this.Ctx.WriteString("")
29 return 31 return
30 } 32 }
31 - // p := this.Ctx.Input.GetData("RouterPattern")  
32 - // userid := this.GetUserId()  
33 - // companyid := this.GetCompanyId() 33 + if beego.BConfig.RunMode == "dev" {
  34 + return
  35 + }
  36 + p := fmt.Sprint(this.Ctx.Input.GetData("RouterPattern"))
  37 + userid := this.GetUserId()
  38 + companyid := this.GetCompanyId()
  39 + ok := serveauth.ValidUserPermission(p, userid, companyid)
  40 + if !ok {
  41 + msg := protocol.NewMessage("10080")
  42 + this.ResposeJson(msg)
  43 + return
  44 + }
34 //权限校验 45 //权限校验
35 - 46 + return
36 } 47 }
37 48
38 func (this *BaseController) GetAppHead() (appHead protocol.BaseHeader) { 49 func (this *BaseController) GetAppHead() (appHead protocol.BaseHeader) {
39 appHead.AccessToken = this.Ctx.Input.Header(protocol.HeaderAccessToken) 50 appHead.AccessToken = this.Ctx.Input.Header(protocol.HeaderAccessToken)
40 - //appHead.RefreshToken = this.Ctx.Input.Header(protocol.HeaderRefreshToken)  
41 return 51 return
42 52
43 } 53 }
  1 +package models
  2 +
  3 +import (
  4 + "time"
  5 +
  6 + "github.com/astaxie/beego/orm"
  7 +)
  8 +
  9 +type AuditFlowProcess struct {
  10 + Id int64 `orm:"column(id);pk" description:"唯一标识"`
  11 + ChanceId int64 `orm:"column(chance_id)" description:"实例id,关联chance表id"`
  12 + Uid int64 `orm:"column(uid)" description:"用户id(审批人)"`
  13 + Level int `orm:"column(level)" description:"审批步骤"`
  14 + IsActive int8 `orm:"column(is_active)" description:"是否激活"`
  15 + ApproveTime time.Time `orm:"column(approve_time);type(timestamp);null" description:"审批时间"`
  16 + BasicScore float64 `orm:"column(basic_score);null;digits(4);decimals(1)" description:"基础评分"`
  17 + ExtraScore float64 `orm:"column(extra_score);null;digits(4);decimals(1)" description:"附加评分"`
  18 + ValueScore float64 `orm:"column(value_score);null;digits(4);decimals(1)" description:"价值评分"`
  19 + DiscoveryScore float64 `orm:"column(discovery_score);null;digits(4);decimals(0)" description:"发现评分"`
  20 + ReviewStatus int8 `orm:"column(review_status)" description:"审核状态 审核状态 0:待处理 1:待审核 2:被退回 3:已通过 4:提交 "`
  21 + AuditFlowType int `orm:"column(audit_flow_type)" description:"审核流类型 1.部门长 2.指定成员 3.指定角色 4.特殊审核人"`
  22 + FlowType int `orm:"column(flow_type)" description:"审批类型 1:正常审核 2:特殊审核"`
  23 + ActionType int `orm:"column(action_type)" description:"审批执行方式【1:or】【2:and】"`
  24 + CreateAt time.Time `orm:"column(create_at);type(timestamp)" description:"创建时间"`
  25 + UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"`
  26 + EnableStatus int8 `orm:"column(enable_status)" description:"有效状态 0:无效 1:有效 (被驳回以后,未完成的审核置为无效)"`
  27 + ApproveData string `orm:"column(approve_data);size(500);null" description:"审核数据 json{公开状态 公开对象 分数}"`
  28 + UserName string `orm:"column(user_name);size(50);null" description:"用户名-冗余"`
  29 + RoleName string `orm:"column(role_name);size(50);null" description:"角色名-冗余"`
  30 + RoleId int `orm:"column(role_id);null" description:"角色id-冗余"`
  31 + ApproveMessage string `orm:"column(approve_message);size(255);null" description:"审核消息-冗余"`
  32 + TemplateId int `orm:"column(template_id);null" description:"模板编号"`
  33 +}
  34 +
  35 +func (t *AuditFlowProcess) TableName() string {
  36 + return "audit_flow_process"
  37 +}
  38 +
  39 +func init() {
  40 + orm.RegisterModel(new(AuditFlowProcess))
  41 +}
  42 +
  43 +//有效状态 0:无效 1:有效 (被驳回以后,未完成的审核置为无效)
  44 +const (
  45 + AuditFlowProcessEnableYes int = 1
  46 + AuditFlowProcessEnableNo int = 0
  47 +)
  48 +
  49 +//审核状态 审核状态 0:待处理 1:待审核 2:被退回 3:已通过 4:提交
  50 +const (
  51 + AuditFlowProcessReviewWait int = 0
  52 + AuditFlowProcessReviewIng int = 1
  53 + AuditFlowProcessReviewBack int = 2
  54 + AuditFlowProcessReviewPass int = 3
  55 + AuditFlowProcessReviewCommit int = 4
  56 +)
  57 +
  58 +// GetAuditFlowProcessById retrieves AuditFlowProcess by Id. Returns error if
  59 +// Id doesn't exist
  60 +func GetAuditFlowProcessById(id int64) (v *AuditFlowProcess, err error) {
  61 + o := orm.NewOrm()
  62 + v = &AuditFlowProcess{Id: id}
  63 + if err = o.Read(v); err == nil {
  64 + return v, nil
  65 + }
  66 + return nil, err
  67 +}
@@ -24,6 +24,7 @@ type Bulletin struct { @@ -24,6 +24,7 @@ type Bulletin struct {
24 //AllowCondition int8 `orm:"column(allow_condition);null" description:"关闭条件 (1(bit 0):公告内容查看完 2(bit 1):回答完问题)"` 24 //AllowCondition int8 `orm:"column(allow_condition);null" description:"关闭条件 (1(bit 0):公告内容查看完 2(bit 1):回答完问题)"`
25 CompanyId int64 `orm:"column(company_id);null" description:"公司Id"` 25 CompanyId int64 `orm:"column(company_id);null" description:"公司Id"`
26 Status int8 `orm:"column(status)" description:"状态 1-下架 2-上架"` 26 Status int8 `orm:"column(status)" description:"状态 1-下架 2-上架"`
  27 + AllPeople int8 `orm:"column(all_people);null" description:"是否是所有人 0:否 1:是"`
27 } 28 }
28 29
29 func (t *Bulletin) TableName() string { 30 func (t *Bulletin) TableName() string {
@@ -31,6 +31,7 @@ type Chance struct { @@ -31,6 +31,7 @@ type Chance struct {
31 PublishStatus int `orm:"column(publish_status)" description:"公开状态 -1 未公开、1部门公开、2公司公开"` 31 PublishStatus int `orm:"column(publish_status)" description:"公开状态 -1 未公开、1部门公开、2公司公开"`
32 AuditLevel int `orm:"column(audit_level)" description:"当前审批步骤"` 32 AuditLevel int `orm:"column(audit_level)" description:"当前审批步骤"`
33 ApproveData string `orm:"column(approve_data);size(500);null" description:"公开数据 (公开状态 公开对象)"` 33 ApproveData string `orm:"column(approve_data);size(500);null" description:"公开数据 (公开状态 公开对象)"`
  34 + Code string `orm:"column(code)" description:"机会编码"`
34 } 35 }
35 36
36 func (t *Chance) TableName() string { 37 func (t *Chance) TableName() string {
@@ -143,3 +143,15 @@ func GetUserCompanyReal(ids []int64) ([]UserCompany, error) { @@ -143,3 +143,15 @@ func GetUserCompanyReal(ids []int64) ([]UserCompany, error) {
143 All(&data) 143 All(&data)
144 return data, err 144 return data, err
145 } 145 }
  146 +
  147 +//获取公司的所有人员
  148 +func GetUserCompanyAll(companyId int64) (v []*UserCompany, err error) {
  149 + o := orm.NewOrm()
  150 + sql := `select a.*,b.nick_name from (
  151 +select id,user_id from user_company where company_id=? and enable=1
  152 +)a inner join user b on a.user_id = b.id`
  153 + if _, err = o.Raw(sql, companyId).QueryRows(&v); err == nil {
  154 + return v, nil
  155 + }
  156 + return nil, err
  157 +}
@@ -263,6 +263,8 @@ type RspAuditList struct { @@ -263,6 +263,8 @@ type RspAuditList struct {
263 ReviewStatusName string `json:"review_status_name"` 263 ReviewStatusName string `json:"review_status_name"`
264 EnableStatus int8 `json:"enable_status"` 264 EnableStatus int8 `json:"enable_status"`
265 EnableStatusName string `json:"enable_status_name"` 265 EnableStatusName string `json:"enable_status_name"`
  266 + DiscoveryScore string `json:"discovery_score"`
  267 + CommentTotal string `json:"comment_total"`
266 } 268 }
267 269
268 type ChanceFlowLog struct { 270 type ChanceFlowLog struct {
@@ -20,7 +20,7 @@ type BulletinReleaseRequest struct { @@ -20,7 +20,7 @@ type BulletinReleaseRequest struct {
20 //AllowCondition int `json:"allow_condition"` 20 //AllowCondition int `json:"allow_condition"`
21 QuestionSwitch int `json:"question_switch"` 21 QuestionSwitch int `json:"question_switch"`
22 Receiver []VisibleObject `json:"receiver"` 22 Receiver []VisibleObject `json:"receiver"`
23 - SendToAll int `json:"send_to_all"` //所有人 1:是 0:否 23 + AllPeo int8 `json:"allPeo"` //所有人 1:是 0:否
24 Question Question `json:"question"` 24 Question Question `json:"question"`
25 Cover Cover `json:"cover"` 25 Cover Cover `json:"cover"`
26 IsPublish int `json:"is_publish"` //是否直接发布 0:否 1:直接发布 26 IsPublish int `json:"is_publish"` //是否直接发布 0:否 1:直接发布
@@ -70,6 +70,7 @@ type GetBulletinResponse struct { @@ -70,6 +70,7 @@ type GetBulletinResponse struct {
70 Title string `json:"title" valid:"Required"` 70 Title string `json:"title" valid:"Required"`
71 Content string `json:"content" valid:"Required"` 71 Content string `json:"content" valid:"Required"`
72 AllowClose int `json:"allow_close"` 72 AllowClose int `json:"allow_close"`
  73 + AllPeo int8 `json:"allPeo"` //所有人 1:是 0:否
73 //AllowCondition int `json:"allow_condition"` 74 //AllowCondition int `json:"allow_condition"`
74 QuestionSwitch int `json:"question_switch"` 75 QuestionSwitch int `json:"question_switch"`
75 Receiver []VisibleObject `json:"receiver" valid:"Required"` 76 Receiver []VisibleObject `json:"receiver" valid:"Required"`
@@ -90,10 +91,12 @@ type UpdateBulletinRequest struct { @@ -90,10 +91,12 @@ type UpdateBulletinRequest struct {
90 Content string `json:"content" valid:"Required"` 91 Content string `json:"content" valid:"Required"`
91 AllowClose int `json:"allow_close"` 92 AllowClose int `json:"allow_close"`
92 //AllowCondition int `json:"allow_condition"` 93 //AllowCondition int `json:"allow_condition"`
  94 + AllPeo int8 `json:"allPeo"` //所有人 1:是 0:否
93 QuestionSwitch int `json:"question_switch"` 95 QuestionSwitch int `json:"question_switch"`
94 - Receiver []VisibleObject `json:"receiver" valid:"Required"` 96 + Receiver []VisibleObject `json:"receiver"`
95 Question Question `json:"question"` 97 Question Question `json:"question"`
96 Cover Cover `json:"cover" valid:"Required"` 98 Cover Cover `json:"cover" valid:"Required"`
  99 + IsPublish int `json:"is_publish"` //是否直接发布 0:否 1:直接发布
97 } 100 }
98 type UpdateBulletinResponse struct { 101 type UpdateBulletinResponse struct {
99 } 102 }
@@ -22,6 +22,7 @@ var errmessge ErrorMap = map[string]string{ @@ -22,6 +22,7 @@ var errmessge ErrorMap = map[string]string{
22 "10012": "超过10级的职位限制,请重新选择", 22 "10012": "超过10级的职位限制,请重新选择",
23 "10013": "同一级职位名称不允许重复", 23 "10013": "同一级职位名称不允许重复",
24 "10014": "职位名称最多10个字符", 24 "10014": "职位名称最多10个字符",
  25 + "10015": "上级职位不能选择当前职位及其下级职位",
25 //安全认证相关 26 //安全认证相关
26 "10020": "验证码过期", 27 "10020": "验证码过期",
27 "10021": "账号或密码不正确", 28 "10021": "账号或密码不正确",
@@ -33,6 +34,7 @@ var errmessge ErrorMap = map[string]string{ @@ -33,6 +34,7 @@ var errmessge ErrorMap = map[string]string{
33 "10027": "无操作权限", 34 "10027": "无操作权限",
34 "10028": "验证码错误", 35 "10028": "验证码错误",
35 "10029": "获取验证码失败", 36 "10029": "获取验证码失败",
  37 + "10080": "无操作权限",
36 38
37 //用户相关 39 //用户相关
38 "10031": "无效角色", 40 "10031": "无效角色",
@@ -47,6 +49,8 @@ var errmessge ErrorMap = map[string]string{ @@ -47,6 +49,8 @@ var errmessge ErrorMap = map[string]string{
47 "10071": "不能删除主管理员", 49 "10071": "不能删除主管理员",
48 "10072": "不能禁用主管理员", 50 "10072": "不能禁用主管理员",
49 "10073": "角色组已存在", 51 "10073": "角色组已存在",
  52 + "10074": "删除失败,存在需要用户审批的单子",
  53 + "10075": "禁用失败,存在需要用户审批的单子",
50 //部门相关 54 //部门相关
51 "10041": "无效的主管设置", 55 "10041": "无效的主管设置",
52 "10042": "上级部门不能选择当前部门及其子部门", 56 "10042": "上级部门不能选择当前部门及其子部门",
@@ -76,6 +80,7 @@ var errmessge ErrorMap = map[string]string{ @@ -76,6 +80,7 @@ var errmessge ErrorMap = map[string]string{
76 "10276": "最多选择1个角色", 80 "10276": "最多选择1个角色",
77 "10277": "最多一个小数", 81 "10277": "最多一个小数",
78 "10278": "公告标题大于30个字符", 82 "10278": "公告标题大于30个字符",
  83 + "10279": "该子分类名称已存在",
79 84
80 "10170": "请选择指定成员", 85 "10170": "请选择指定成员",
81 "10171": "请选择审批人类别", 86 "10171": "请选择审批人类别",
@@ -90,6 +95,8 @@ var errmessge ErrorMap = map[string]string{ @@ -90,6 +95,8 @@ var errmessge ErrorMap = map[string]string{
90 //评分配置相关 95 //评分配置相关
91 "12101": "分值范围不符合要求", 96 "12101": "分值范围不符合要求",
92 "12102": "评分规则不符合要求", 97 "12102": "评分规则不符合要求",
  98 + //权限配置相关
  99 + "10091": "至少选择一个特定部门",
93 } 100 }
94 101
95 //错误码转换 ,兼容需要 102 //错误码转换 ,兼容需要
@@ -135,6 +135,8 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64 @@ -135,6 +135,8 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64
135 ReviewStatus: v.ReviewStatus, 135 ReviewStatus: v.ReviewStatus,
136 ReviewStatusName: models.ChanceReviewStatusMap[v.ReviewStatus], 136 ReviewStatusName: models.ChanceReviewStatusMap[v.ReviewStatus],
137 Code: v.Code, 137 Code: v.Code,
  138 + DiscoveryScore: v.DiscoveryScore,
  139 + CommentTotal: v.CommentTotal,
138 } 140 }
139 141
140 if t < 0 { 142 if t < 0 {
@@ -35,7 +35,7 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs @@ -35,7 +35,7 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs
35 return 35 return
36 } 36 }
37 if _, err = models.GetAuditTemplateByName(companyId, request.Template.Name); err == nil { 37 if _, err = models.GetAuditTemplateByName(companyId, request.Template.Name); err == nil {
38 - err = protocol.NewErrWithMessage("10271") 38 + err = protocol.NewErrWithMessage("10279")
39 return 39 return
40 } 40 }
41 orm := orm2.NewOrm() 41 orm := orm2.NewOrm()
@@ -111,6 +111,8 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs @@ -111,6 +111,8 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs
111 flowConfig.ToRole = jsonAssertMarsh(getIdsFrom(config.ToRole)) 111 flowConfig.ToRole = jsonAssertMarsh(getIdsFrom(config.ToRole))
112 flowConfig.ToUser = jsonAssertMarsh(getIdsFrom(config.ToUser)) 112 flowConfig.ToUser = jsonAssertMarsh(getIdsFrom(config.ToUser))
113 flowConfig.ActionType = config.AcitonType 113 flowConfig.ActionType = config.AcitonType
  114 + //flowConfig.FlowType = config.ProcessType
  115 + //flowConfig.AuditFlowType = config.ApproveType
114 flowConfig.CreateAt = time.Now() 116 flowConfig.CreateAt = time.Now()
115 flowConfig.AuditGroupId = int64(config.GroupId) 117 flowConfig.AuditGroupId = int64(config.GroupId)
116 flowConfig.ConfigData = jsonAssertMarsh(config) 118 flowConfig.ConfigData = jsonAssertMarsh(config)
@@ -160,10 +162,12 @@ func TemplateUpdate(uid, companyId int64, request *protocol.TemplateUpdateReques @@ -160,10 +162,12 @@ func TemplateUpdate(uid, companyId int64, request *protocol.TemplateUpdateReques
160 log.Error("template_id:%v 不存在 ,err:%v", request.Template.Id, err.Error()) 162 log.Error("template_id:%v 不存在 ,err:%v", request.Template.Id, err.Error())
161 return 163 return
162 } 164 }
  165 + if template.Name != request.Template.Name {
163 if _, err = models.GetAuditTemplateByName(companyId, request.Template.Name); err == nil { 166 if _, err = models.GetAuditTemplateByName(companyId, request.Template.Name); err == nil {
164 - err = protocol.NewErrWithMessage("10271") 167 + err = protocol.NewErrWithMessage("10279")
165 return 168 return
166 } 169 }
  170 + }
167 orm := orm2.NewOrm() 171 orm := orm2.NewOrm()
168 //模板 172 //模板
169 { 173 {
@@ -218,7 +222,7 @@ func TemplateUpdate(uid, companyId int64, request *protocol.TemplateUpdateReques @@ -218,7 +222,7 @@ func TemplateUpdate(uid, companyId int64, request *protocol.TemplateUpdateReques
218 for i := range request.AuditFlowConfig.ProcessConfig { 222 for i := range request.AuditFlowConfig.ProcessConfig {
219 config := request.AuditFlowConfig.ProcessConfig[i] 223 config := request.AuditFlowConfig.ProcessConfig[i]
220 flowConfig := &models.AuditFlowConfig{ 224 flowConfig := &models.AuditFlowConfig{
221 - AuditFlowType: config.ProcessType, 225 + //AuditFlowType: config.ApproveType,
222 } 226 }
223 if config.ProcessType == models.FlowTypeNormal { 227 if config.ProcessType == models.FlowTypeNormal {
224 flowConfig.Level = normalLevel 228 flowConfig.Level = normalLevel
@@ -231,6 +235,8 @@ func TemplateUpdate(uid, companyId int64, request *protocol.TemplateUpdateReques @@ -231,6 +235,8 @@ func TemplateUpdate(uid, companyId int64, request *protocol.TemplateUpdateReques
231 flowConfig.ToRole = jsonAssertMarsh(getIdsFrom(config.ToRole)) 235 flowConfig.ToRole = jsonAssertMarsh(getIdsFrom(config.ToRole))
232 flowConfig.ToUser = jsonAssertMarsh(getIdsFrom(config.ToUser)) 236 flowConfig.ToUser = jsonAssertMarsh(getIdsFrom(config.ToUser))
233 flowConfig.ActionType = config.AcitonType 237 flowConfig.ActionType = config.AcitonType
  238 + flowConfig.FlowType = config.ProcessType
  239 + flowConfig.AuditFlowType = config.ApproveType
234 flowConfig.CreateAt = time.Now() 240 flowConfig.CreateAt = time.Now()
235 flowConfig.AuditGroupId = int64(config.GroupId) 241 flowConfig.AuditGroupId = int64(config.GroupId)
236 flowConfig.ConfigData = jsonAssertMarsh(config) 242 flowConfig.ConfigData = jsonAssertMarsh(config)
@@ -143,30 +143,6 @@ func ChangeLoginToken(userid, companyid int64) (protocol.LoginAuthToken, error) @@ -143,30 +143,6 @@ func ChangeLoginToken(userid, companyid int64) (protocol.LoginAuthToken, error)
143 return logintoken, nil 143 return logintoken, nil
144 } 144 }
145 145
146 -// func RefreshLoginToken(refreshtoken string) (protocol.LoginAuthToken, error) {  
147 -// var (  
148 -// logintoken protocol.LoginAuthToken  
149 -// mtoken *MyToken  
150 -// err error  
151 -// storetoken redisdata.RedisLoginToken  
152 -// )  
153 -// mtoken, err = ValidJWTToken(refreshtoken)  
154 -// if err != nil {  
155 -// log.Debug("token失效 err:%s", err)  
156 -// return logintoken, protocol.NewErrWithMessage("10024")  
157 -// }  
158 -// storetoken, err = redisdata.GetLoginToken(mtoken.UID, mtoken.CompanyID)  
159 -// if err != nil {  
160 -// log.Error("redis err:%s", err)  
161 -// return logintoken, protocol.NewErrWithMessage("10024")  
162 -// }  
163 -// if storetoken.RefreshToken != refreshtoken {  
164 -// return logintoken, protocol.NewErrWithMessage("10024")  
165 -// }  
166 -// logintoken, _ = GenerateAuthToken(mtoken.UID, mtoken.CompanyID)  
167 -// return logintoken, nil  
168 -// }  
169 -  
170 func LoginAuthByUCenter(account, password string) (protocol.LoginAuthToken, error) { 146 func LoginAuthByUCenter(account, password string) (protocol.LoginAuthToken, error) {
171 var ( 147 var (
172 err error 148 err error
@@ -239,7 +215,7 @@ func LoginAuthByUCenter(account, password string) (protocol.LoginAuthToken, erro @@ -239,7 +215,7 @@ func LoginAuthByUCenter(account, password string) (protocol.LoginAuthToken, erro
239 log.Error("更新用户数据失败:%s", err) 215 log.Error("更新用户数据失败:%s", err)
240 } 216 }
241 217
242 - InitPermission(usercompanyid) 218 + InitPermission(usercompanyid, userdata.Id)
243 return logintoken, err 219 return logintoken, err
244 } 220 }
245 221
@@ -392,22 +368,6 @@ func GetUserHasMenu(userid, companyid int64) ([]protocol.ResponseUserHasMenu, er @@ -392,22 +368,6 @@ func GetUserHasMenu(userid, companyid int64) ([]protocol.ResponseUserHasMenu, er
392 return list, nil 368 return list, nil
393 } 369 }
394 370
395 -//主管拥有全部的菜单  
396 -// func getAdminHasMenu() ([]protocol.PermissionItem, error) {  
397 -// const datasql string = `SELECT id,name,icon,parent_id,senior_status,sort,code  
398 -// FROM menu WHERE enabled=1 ORDER BY sort `  
399 -// var (  
400 -// list = make([]protocol.PermissionItem, 0)  
401 -// err error  
402 -// )  
403 -// err = utils.ExecuteQueryAll(&list, datasql)  
404 -// if err != nil {  
405 -// log.Error("EXECUTE SQL err:%s", err)  
406 -// return nil, protocol.NewErrWithMessage("1")  
407 -// }  
408 -// return list, nil  
409 -// }  
410 -  
411 func LoginAuthBySmsCode(phone string, code string) (protocol.LoginAuthToken, error) { 371 func LoginAuthBySmsCode(phone string, code string) (protocol.LoginAuthToken, error) {
412 var ( 372 var (
413 err error 373 err error
@@ -477,7 +437,7 @@ func LoginAuthBySmsCode(phone string, code string) (protocol.LoginAuthToken, err @@ -477,7 +437,7 @@ func LoginAuthBySmsCode(phone string, code string) (protocol.LoginAuthToken, err
477 if err != nil { 437 if err != nil {
478 log.Error("更新用户数据失败:%s", err) 438 log.Error("更新用户数据失败:%s", err)
479 } 439 }
480 - InitPermission(usercompanyid) 440 + InitPermission(usercompanyid, userdata.Id)
481 return logintoken, err 441 return logintoken, err
482 } 442 }
483 443
@@ -508,7 +468,7 @@ func SmsCodeCheck(phone string, code string) error { @@ -508,7 +468,7 @@ func SmsCodeCheck(phone string, code string) error {
508 } 468 }
509 469
510 //InitPermission 登录时权限初始化 470 //InitPermission 登录时权限初始化
511 -func InitPermission(usercompanyid int64) error { 471 +func InitPermission(usercompanyid int64, usercompamyid int64) error {
512 var ( 472 var (
513 err error 473 err error
514 permissionMap map[string]serverbac.PermissionOptionObject 474 permissionMap map[string]serverbac.PermissionOptionObject
@@ -518,7 +478,8 @@ func InitPermission(usercompanyid int64) error { @@ -518,7 +478,8 @@ func InitPermission(usercompanyid int64) error {
518 log.Error("获取用户的权限失败") 478 log.Error("获取用户的权限失败")
519 return err 479 return err
520 } 480 }
521 - err = redisdata.SetUserPermission(permissionMap, usercompanyid) 481 +
  482 + err = redisdata.SetUserPermission(permissionMap, usercompamyid)
522 if err != nil { 483 if err != nil {
523 log.Error("缓存用户权限失败:%s", err) 484 log.Error("缓存用户权限失败:%s", err)
524 } 485 }
@@ -536,9 +497,18 @@ func ValidUserPermission(urlPath string, userid int64, companyid int64) bool { @@ -536,9 +497,18 @@ func ValidUserPermission(urlPath string, userid int64, companyid int64) bool {
536 if !ok { 497 if !ok {
537 return true 498 return true
538 } 499 }
  500 + companyinfo, err := models.GetCompanyById(companyid)
  501 + if err != nil {
  502 + log.Error("获取公司数据失败")
  503 + return false
  504 + }
  505 + if companyinfo.AdminId == userid {
  506 + return true
  507 + }
  508 +
539 permissionObj, err = redisdata.GetUserPermission(userid, permissionbase.CodeName) 509 permissionObj, err = redisdata.GetUserPermission(userid, permissionbase.CodeName)
540 if err != nil { 510 if err != nil {
541 - log.Error("未取到权限数据") 511 + log.Error("未取到权限数据 err:%s", err)
542 return false 512 return false
543 } 513 }
544 ok = permissionObj.GetValidFunc(permissionbase.ActionName) 514 ok = permissionObj.GetValidFunc(permissionbase.ActionName)
@@ -45,6 +45,7 @@ func BulletinRelease(uid, companyId int64, request *protocol.BulletinReleaseRequ @@ -45,6 +45,7 @@ func BulletinRelease(uid, companyId int64, request *protocol.BulletinReleaseRequ
45 CreateAt: time.Now(), 45 CreateAt: time.Now(),
46 UpdateAt: time.Now(), 46 UpdateAt: time.Now(),
47 Status: status, 47 Status: status,
  48 + AllPeople: request.AllPeo,
48 } 49 }
49 50
50 orm := orm2.NewOrm() 51 orm := orm2.NewOrm()
@@ -85,7 +86,7 @@ func BulletinRelease(uid, companyId int64, request *protocol.BulletinReleaseRequ @@ -85,7 +86,7 @@ func BulletinRelease(uid, companyId int64, request *protocol.BulletinReleaseRequ
85 } 86 }
86 //TODO:发送公告消息 87 //TODO:发送公告消息
87 if request.IsPublish == 1 { 88 if request.IsPublish == 1 {
88 - if err = sendBulletinUserMsg(orm, request.Receiver, companyId, int64(id), bulletin.Title); err != nil { 89 + if err = sendBulletinUserMsg(orm, request.Receiver, companyId, int64(id), bulletin.Title, request.AllPeo); err != nil {
89 log.Error(err.Error()) 90 log.Error(err.Error())
90 orm.Rollback() 91 orm.Rollback()
91 return 92 return
@@ -136,14 +137,24 @@ func getBulletinReceiverIds(orm orm2.Ormer, receivers []protocol.VisibleObject, @@ -136,14 +137,24 @@ func getBulletinReceiverIds(orm orm2.Ormer, receivers []protocol.VisibleObject,
136 } 137 }
137 138
138 //发送公告消息 139 //发送公告消息
139 -func sendBulletinUserMsg(orm orm2.Ormer, receivers []protocol.VisibleObject, companyId int64, sourceId int64, message string) (err error) { 140 +func sendBulletinUserMsg(orm orm2.Ormer, receivers []protocol.VisibleObject, companyId int64, sourceId int64, message string, allPeople int8) (err error) {
140 var ( 141 var (
141 ids []int64 142 ids []int64
142 sended = make(map[int64]int64) 143 sended = make(map[int64]int64)
143 ) 144 )
  145 + if allPeople == 1 {
  146 + if userCompanys, e := models.GetUserCompanyAll(companyId); e == nil {
  147 + for i := range userCompanys {
  148 + ids = append(ids, userCompanys[i].Id)
  149 + }
  150 + } else {
  151 + log.Error("%v %v", companyId, e.Error())
  152 + }
  153 + } else {
144 if ids, err = getBulletinReceiverIds(orm, receivers, companyId, sourceId, message); err != nil { 154 if ids, err = getBulletinReceiverIds(orm, receivers, companyId, sourceId, message); err != nil {
145 return 155 return
146 } 156 }
  157 + }
147 for i := range ids { 158 for i := range ids {
148 if _, ok := sended[ids[i]]; ok { 159 if _, ok := sended[ids[i]]; ok {
149 continue 160 continue
@@ -256,6 +267,7 @@ func GetBulletin(id int, companyId int64, request *protocol.GetBulletinRequest) @@ -256,6 +267,7 @@ func GetBulletin(id int, companyId int64, request *protocol.GetBulletinRequest)
256 Title: bulletin.Title, 267 Title: bulletin.Title,
257 Content: bulletin.Content, 268 Content: bulletin.Content,
258 AllowClose: int(bulletin.AllowClose), 269 AllowClose: int(bulletin.AllowClose),
  270 + AllPeo: bulletin.AllPeople,
259 //AllowCondition: int(bulletin.AllowCondition), 271 //AllowCondition: int(bulletin.AllowCondition),
260 Cover: protocol.Cover(bulletin.Cover), 272 Cover: protocol.Cover(bulletin.Cover),
261 Question: protocol.Question{ 273 Question: protocol.Question{
@@ -326,7 +338,11 @@ func UpdateBulletin(companyId int64, request *protocol.UpdateBulletinRequest) (r @@ -326,7 +338,11 @@ func UpdateBulletin(companyId int64, request *protocol.UpdateBulletinRequest) (r
326 bulletin.QuestionSwitch = int8(request.QuestionSwitch) 338 bulletin.QuestionSwitch = int8(request.QuestionSwitch)
327 //bulletin.AllowCondition = int8(request.AllowCondition) 339 //bulletin.AllowCondition = int8(request.AllowCondition)
328 bulletin.AllowClose = int8(request.AllowClose) 340 bulletin.AllowClose = int8(request.AllowClose)
  341 + bulletin.AllPeople = request.AllPeo
329 bulletin.UpdateAt = time.Now() 342 bulletin.UpdateAt = time.Now()
  343 + if request.IsPublish == 1 && bulletin.Status == protocol.BulletinUnRelease {
  344 + bulletin.Status = protocol.BulletinRelease
  345 + }
330 if err = models.UpdateBulletinById(bulletin); err != nil { 346 if err = models.UpdateBulletinById(bulletin); err != nil {
331 log.Error(err.Error()) 347 log.Error(err.Error())
332 return 348 return
@@ -377,6 +393,14 @@ func UpdateBulletin(companyId int64, request *protocol.UpdateBulletinRequest) (r @@ -377,6 +393,14 @@ func UpdateBulletin(companyId int64, request *protocol.UpdateBulletinRequest) (r
377 } 393 }
378 394
379 } 395 }
  396 + orm := orm2.NewOrm()
  397 + if request.IsPublish == 1 && bulletin.Status == protocol.BulletinUnRelease {
  398 + if err = sendBulletinUserMsg(orm, request.Receiver, companyId, int64(bulletin.Id), bulletin.Title, request.AllPeo); err != nil {
  399 + log.Error(err.Error())
  400 + orm.Rollback()
  401 + return
  402 + }
  403 + }
380 return 404 return
381 } 405 }
382 406
@@ -419,7 +443,7 @@ func OperateBulletin(companyId int64, request *protocol.OperateBulletinRequest) @@ -419,7 +443,7 @@ func OperateBulletin(companyId int64, request *protocol.OperateBulletinRequest)
419 } 443 }
420 if request.CmdType == protocol.BulletinRelease { //上架 444 if request.CmdType == protocol.BulletinRelease { //上架
421 status = protocol.BulletinRelease 445 status = protocol.BulletinRelease
422 - if err = sendBulletinUserMsg(orm, receiver, companyId, int64(bulletin.Id), bulletin.Title); err != nil { 446 + if err = sendBulletinUserMsg(orm, receiver, companyId, int64(bulletin.Id), bulletin.Title, bulletin.AllPeople); err != nil {
423 log.Error(err.Error()) 447 log.Error(err.Error())
424 orm.Rollback() 448 orm.Rollback()
425 return 449 return
@@ -213,7 +213,7 @@ func positionRelationUpdate(positionUpdate *models.Position, newparent *models.P @@ -213,7 +213,7 @@ func positionRelationUpdate(positionUpdate *models.Position, newparent *models.P
213 o.Rollback() 213 o.Rollback()
214 e := fmt.Errorf("departSubset[i].Id == newparent.Id") 214 e := fmt.Errorf("departSubset[i].Id == newparent.Id")
215 log.Error(e.Error()) 215 log.Error(e.Error())
216 - return protocol.NewErrWithMessage("1", e) 216 + return protocol.NewErrWithMessage("10015", e)
217 } 217 }
218 //重建关系树 218 //重建关系树
219 s := strings.TrimPrefix(positionSubset[i].Relation, oldRelation) 219 s := strings.TrimPrefix(positionSubset[i].Relation, oldRelation)
@@ -465,7 +465,14 @@ func UserDelete(userCompanyids []int64, companyid int64) error { @@ -465,7 +465,14 @@ func UserDelete(userCompanyids []int64, companyid int64) error {
465 log.Error("获取用户数据失败:%s", err) 465 log.Error("获取用户数据失败:%s", err)
466 return protocol.NewErrWithMessage("1") 466 return protocol.NewErrWithMessage("1")
467 } 467 }
468 - 468 + exist := o.QueryTable(&models.AuditFlowProcess{}).
  469 + Filter("uid__in", userCompanyids).
  470 + Filter("enable_status", models.AuditFlowProcessEnableYes).
  471 + Filter("review_status__in", models.AuditFlowProcessReviewWait, models.AuditFlowProcessReviewIng).
  472 + Exist()
  473 + if exist {
  474 + return protocol.NewErrWithMessage("10074")
  475 + }
469 var ( 476 var (
470 ids []int64 477 ids []int64
471 ) 478 )
@@ -657,6 +664,14 @@ func UserForbid(userCompanyids []int64, companyid int64) error { @@ -657,6 +664,14 @@ func UserForbid(userCompanyids []int64, companyid int64) error {
657 log.Error("获取用户数据失败:%s", err) 664 log.Error("获取用户数据失败:%s", err)
658 return protocol.NewErrWithMessage("1") 665 return protocol.NewErrWithMessage("1")
659 } 666 }
  667 + exist := o.QueryTable(&models.AuditFlowProcess{}).
  668 + Filter("uid__in", userCompanyids).
  669 + Filter("enable_status", models.AuditFlowProcessEnableYes).
  670 + Filter("review_status__in", models.AuditFlowProcessReviewWait, models.AuditFlowProcessReviewIng).
  671 + Exist()
  672 + if exist {
  673 + return protocol.NewErrWithMessage("10075")
  674 + }
660 var ( 675 var (
661 ids []int64 676 ids []int64
662 ) 677 )
@@ -173,6 +173,13 @@ func UpdateSetOpportunity(param OptionOpportunity, roleid int64, companyid int64 @@ -173,6 +173,13 @@ func UpdateSetOpportunity(param OptionOpportunity, roleid int64, companyid int64
173 err error 173 err error
174 menuinfo *models.Menu 174 menuinfo *models.Menu
175 ) 175 )
  176 +
  177 + if param.Check == OpportunityCheckLv3 {
  178 + if len(param.CheckOption.Departments) == 0 {
  179 + return protocol.NewErrWithMessage("10091")
  180 + }
  181 + }
  182 +
176 menuinfo, err = models.GetMenuByCode(M_SYSTEM_OPPORTUNITY) 183 menuinfo, err = models.GetMenuByCode(M_SYSTEM_OPPORTUNITY)
177 if err != nil { 184 if err != nil {
178 log.Error("获取菜单数据失败GetMenuByCode(%s):%s", M_SYSTEM_OPPORTUNITY, err) 185 log.Error("获取菜单数据失败GetMenuByCode(%s):%s", M_SYSTEM_OPPORTUNITY, err)
@@ -53,9 +53,9 @@ var RouterPermission = map[string]PermissionBase{ @@ -53,9 +53,9 @@ var RouterPermission = map[string]PermissionBase{
53 "/v1/rbac/role_group/add": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE_ROLE, ActionName: "default"}, 53 "/v1/rbac/role_group/add": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE_ROLE, ActionName: "default"},
54 "/v1/rbac/role_group/edit": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE_ROLE, ActionName: "default"}, 54 "/v1/rbac/role_group/edit": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE_ROLE, ActionName: "default"},
55 "/v1/rbac/role_group/delete": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE_ROLE, ActionName: "default"}, 55 "/v1/rbac/role_group/delete": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE_ROLE, ActionName: "default"},
  56 + "/v1/rbac/role/menu": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE_ROLE, ActionName: "default"},
56 "/v1/rbac/menu/list": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE_ROLE, ActionName: "default"}, 57 "/v1/rbac/menu/list": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE_ROLE, ActionName: "default"},
57 - "/v1/rbac/menu": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE_ROLE, ActionName: "default"},  
58 - "/v1/rbac/menu/edit": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE_ROLE, ActionName: "default"}, 58 + "/v1/rbac/role/menu/edit": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE_ROLE, ActionName: "default"},
59 "/v1/rbac/menu/opportunity": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE_ROLE, ActionName: "default"}, 59 "/v1/rbac/menu/opportunity": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE_ROLE, ActionName: "default"},
60 "/v1/rbac/menu/opportunity/edit": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE_ROLE, ActionName: "default"}, 60 "/v1/rbac/menu/opportunity/edit": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE_ROLE, ActionName: "default"},
61 "/v1/user/list": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE, ActionName: "default"}, 61 "/v1/user/list": PermissionBase{CodeName: M_ENTERPRISE_EMPLOYEE, ActionName: "default"},
@@ -84,6 +84,9 @@ var RouterPermission = map[string]PermissionBase{ @@ -84,6 +84,9 @@ var RouterPermission = map[string]PermissionBase{
84 "/v1/template/deleteCategory": PermissionBase{CodeName: M_SYSTEM_OPPORTUNITY_TEMPLATE, ActionName: "default"}, 84 "/v1/template/deleteCategory": PermissionBase{CodeName: M_SYSTEM_OPPORTUNITY_TEMPLATE, ActionName: "default"},
85 "/v1/config/score": PermissionBase{CodeName: M_SYSTEM_RATING, ActionName: "default"}, 85 "/v1/config/score": PermissionBase{CodeName: M_SYSTEM_RATING, ActionName: "default"},
86 "/v1/config/score/get": PermissionBase{CodeName: M_SYSTEM_RATING, ActionName: "default"}, 86 "/v1/config/score/get": PermissionBase{CodeName: M_SYSTEM_RATING, ActionName: "default"},
  87 + "/v1/audit/list": PermissionBase{CodeName: M_SYSTEM_OPPORTUNITY, ActionName: "check"},
  88 + "/v1/audit/info": PermissionBase{CodeName: M_SYSTEM_OPPORTUNITY, ActionName: "check"},
  89 + "/v1/audit/allow_forbid": PermissionBase{CodeName: M_SYSTEM_OPPORTUNITY, ActionName: "close_chance"},
87 } 90 }
88 91
89 type CodeToObject func() PermissionOptionObject 92 type CodeToObject func() PermissionOptionObject
@@ -143,3 +146,26 @@ func GetUserPermission(userCompanyid int64) (map[string]PermissionOptionObject, @@ -143,3 +146,26 @@ func GetUserPermission(userCompanyid int64) (map[string]PermissionOptionObject,
143 } 146 }
144 return objMap, nil 147 return objMap, nil
145 } 148 }
  149 +
  150 +// func ValidUserPermission(urlPath string, userid int64, companyid int64) bool {
  151 +// var (
  152 +// err error
  153 +// permissionbase PermissionBase
  154 +// ok bool = false
  155 +// permissionObj PermissionOptionObject
  156 +// )
  157 +// permissionbase, ok = RouterPermission[urlPath]
  158 +// if !ok {
  159 +// return true
  160 +// }
  161 +// permissionObj, err = redisdata.GetUserPermission(userid, permissionbase.CodeName)
  162 +// if err != nil {
  163 +// log.Error("未取到权限数据")
  164 +// return false
  165 +// }
  166 +// ok = permissionObj.GetValidFunc(permissionbase.ActionName)
  167 +// if ok {
  168 +// return true
  169 +// }
  170 +// return false
  171 +// }
@@ -135,7 +135,16 @@ func NewOptionOpportunity() PermissionOptionObject { @@ -135,7 +135,16 @@ func NewOptionOpportunity() PermissionOptionObject {
135 func (p *OptionOpportunity) GetValidFunc(k string) bool { 135 func (p *OptionOpportunity) GetValidFunc(k string) bool {
136 m := map[string]func() bool{ 136 m := map[string]func() bool{
137 "check": p.ValidCheck, 137 "check": p.ValidCheck,
  138 + "edit_sorce": p.ValidEditSorce,
  139 + "close_chance": p.ValidCloseChance,
  140 + "edit_public_status": p.ValidEditPublicStatus,
138 } 141 }
  142 + /*
  143 + EditSorce int `json:"edit_sorce"`
  144 + EditPublicStatus int `json:"edit_public_status"`
  145 + CloseChance int `json:"close_chance"`
  146 + EditChance int `json:"edit_chance"`
  147 + */
139 if fn, ok := m[k]; ok { 148 if fn, ok := m[k]; ok {
140 b := fn() 149 b := fn()
141 return b 150 return b
@@ -217,6 +226,13 @@ func (p *OptionOpportunity) ValidEditPublicStatus() bool { @@ -217,6 +226,13 @@ func (p *OptionOpportunity) ValidEditPublicStatus() bool {
217 return false 226 return false
218 } 227 }
219 228
  229 +func (p *OptionOpportunity) ValidCloseChance() bool {
  230 + if p.CloseChance > 0 {
  231 + return true
  232 + }
  233 + return false
  234 +}
  235 +
220 // //StringUnmarshal PermissionOptionBase 接口实现 236 // //StringUnmarshal PermissionOptionBase 接口实现
221 // func (p *OptionOpportunity) StringUnmarshal(s string) error { 237 // func (p *OptionOpportunity) StringUnmarshal(s string) error {
222 // err := json.Unmarshal([]byte(s), p) 238 // err := json.Unmarshal([]byte(s), p)
@@ -100,8 +100,8 @@ func GetCaptchAuth(phone string) (string, error) { @@ -100,8 +100,8 @@ func GetCaptchAuth(phone string) (string, error) {
100 return r, err 100 return r, err
101 } 101 }
102 102
103 -func SetUserPermission(objMap map[string]rbac.PermissionOptionObject, usercompanyid int64) error {  
104 - key := GetKeyUserPermission(usercompanyid) 103 +func SetUserPermission(objMap map[string]rbac.PermissionOptionObject, userid int64) error {
  104 + key := GetKeyUserPermission(userid)
105 client := redis.GetRedis() 105 client := redis.GetRedis()
106 for k := range objMap { 106 for k := range objMap {
107 s, err := json.Marshal(objMap[k]) 107 s, err := json.Marshal(objMap[k])