正在显示
6 个修改的文件
包含
83 行增加
和
17 行删除
@@ -6,6 +6,7 @@ import ( | @@ -6,6 +6,7 @@ import ( | ||
6 | "oppmg/common/log" | 6 | "oppmg/common/log" |
7 | "oppmg/protocol" | 7 | "oppmg/protocol" |
8 | servecommon "oppmg/services/common" | 8 | servecommon "oppmg/services/common" |
9 | + serverbac "oppmg/services/rbac" | ||
9 | ) | 10 | ) |
10 | 11 | ||
11 | //公共接口 | 12 | //公共接口 |
@@ -162,3 +163,23 @@ func (c *CommonController) DefaultImage() { | @@ -162,3 +163,23 @@ func (c *CommonController) DefaultImage() { | ||
162 | msg = protocol.NewReturnResponse(data, nil) | 163 | msg = protocol.NewReturnResponse(data, nil) |
163 | return | 164 | return |
164 | } | 165 | } |
166 | + | ||
167 | +func (c *CommonController) SelectorRoleUser() { | ||
168 | + var msg *protocol.ResponseMessage | ||
169 | + defer func() { | ||
170 | + c.ResposeJson(msg) | ||
171 | + }() | ||
172 | + type Parameter struct { | ||
173 | + RoleId int64 `json:"role_id"` | ||
174 | + } | ||
175 | + var param Parameter | ||
176 | + if err := json.Unmarshal(c.Ctx.Input.RequestBody, ¶m); err != nil { | ||
177 | + log.Error("json 解析失败 err:%s", err) | ||
178 | + msg = protocol.BadRequestParam("1") | ||
179 | + return | ||
180 | + } | ||
181 | + companyid := c.GetCompanyId() | ||
182 | + list, err := serverbac.GetRoleHasRole(param.RoleId, companyid) | ||
183 | + msg = protocol.NewReturnResponse(list, err) | ||
184 | + return | ||
185 | +} |
@@ -30,16 +30,7 @@ func (c *MyController) ResetPassword() { | @@ -30,16 +30,7 @@ func (c *MyController) ResetPassword() { | ||
30 | msg = protocol.BadRequestParam("1") | 30 | msg = protocol.BadRequestParam("1") |
31 | return | 31 | return |
32 | } | 32 | } |
33 | - companyid := c.GetCompanyId() | ||
34 | - userId := c.GetUserId() | ||
35 | - if companyid <= 0 { | ||
36 | - msg = protocol.BadRequestParam("1") | ||
37 | - return | ||
38 | - } | ||
39 | - if userId <= 0 { | ||
40 | - msg = protocol.BadRequestParam("1") | ||
41 | - return | ||
42 | - } | 33 | + |
43 | err := usermy.ResetPasswordBySms(param.Phone, param.NewPwd, param.ConfirmPwd) | 34 | err := usermy.ResetPasswordBySms(param.Phone, param.NewPwd, param.ConfirmPwd) |
44 | msg = protocol.NewReturnResponse(nil, err) | 35 | msg = protocol.NewReturnResponse(nil, err) |
45 | return | 36 | return |
@@ -59,3 +59,8 @@ type UserInfoBase struct { | @@ -59,3 +59,8 @@ type UserInfoBase struct { | ||
59 | Phone string `json:"phone"` | 59 | Phone string `json:"phone"` |
60 | Status int8 `json:"status"` | 60 | Status int8 `json:"status"` |
61 | } | 61 | } |
62 | + | ||
63 | +type RoleHasUser struct { | ||
64 | + UserCompanyId int64 `json:"user_company_id" orm:"column(user_company_id)"` | ||
65 | + Name string `json:"name" orm:"column(nick_name)"` | ||
66 | +} |
@@ -74,6 +74,7 @@ func init() { | @@ -74,6 +74,7 @@ func init() { | ||
74 | beego.NSRouter("/position", &controllers.CommonController{}, "post:SelectorPosition"), | 74 | beego.NSRouter("/position", &controllers.CommonController{}, "post:SelectorPosition"), |
75 | beego.NSRouter("/user_and_department", &controllers.CommonController{}, "post:SelectorUserAndDepart"), | 75 | beego.NSRouter("/user_and_department", &controllers.CommonController{}, "post:SelectorUserAndDepart"), |
76 | beego.NSRouter("/default_image", &controllers.CommonController{}, "post:DefaultImage"), | 76 | beego.NSRouter("/default_image", &controllers.CommonController{}, "post:DefaultImage"), |
77 | + beego.NSRouter("/role/user", &controllers.CommonController{}, "post:SelectorRoleUser"), | ||
77 | ), | 78 | ), |
78 | beego.NSNamespace("/template", | 79 | beego.NSNamespace("/template", |
79 | beego.NSRouter("/add", &controllers.TemplateController{}, "post:TemplateAdd"), | 80 | beego.NSRouter("/add", &controllers.TemplateController{}, "post:TemplateAdd"), |
@@ -91,9 +92,7 @@ func init() { | @@ -91,9 +92,7 @@ func init() { | ||
91 | beego.NSNamespace("/upload", | 92 | beego.NSNamespace("/upload", |
92 | beego.NSRouter("/image", &controllers.UploadController{}, "post:UploadImage"), | 93 | beego.NSRouter("/image", &controllers.UploadController{}, "post:UploadImage"), |
93 | ), | 94 | ), |
94 | - beego.NSNamespace("/my", | ||
95 | - beego.NSRouter("/reset_password", &controllers.MyController{}, "post:ResetPassword"), | ||
96 | - ), | 95 | + |
97 | beego.NSNamespace("/config", | 96 | beego.NSNamespace("/config", |
98 | beego.NSRouter("/score", &controllers.ConfigController{}, "post:ConfigScore"), | 97 | beego.NSRouter("/score", &controllers.ConfigController{}, "post:ConfigScore"), |
99 | beego.NSRouter("/score/get", &controllers.ConfigController{}, "post:GetConfigScore"), | 98 | beego.NSRouter("/score/get", &controllers.ConfigController{}, "post:GetConfigScore"), |
@@ -112,6 +111,7 @@ func init() { | @@ -112,6 +111,7 @@ func init() { | ||
112 | beego.NSRouter("/login_sms", &controllers.AuthController{}, "post:LoginSms"), | 111 | beego.NSRouter("/login_sms", &controllers.AuthController{}, "post:LoginSms"), |
113 | beego.NSRouter("/sms_code", &controllers.AuthController{}, "post:SmsCode"), | 112 | beego.NSRouter("/sms_code", &controllers.AuthController{}, "post:SmsCode"), |
114 | beego.NSRouter("/sms_code/check", &controllers.AuthController{}, "post:SmsCodeCheck"), | 113 | beego.NSRouter("/sms_code/check", &controllers.AuthController{}, "post:SmsCodeCheck"), |
114 | + beego.NSRouter("/reset_password", &controllers.MyController{}, "post:ResetPassword"), | ||
115 | ) | 115 | ) |
116 | nsUcenter := beego.NewNamespace("/ucenter", | 116 | nsUcenter := beego.NewNamespace("/ucenter", |
117 | beego.NSBefore(middleware.LogRequestData), | 117 | beego.NSBefore(middleware.LogRequestData), |
@@ -6,15 +6,17 @@ import ( | @@ -6,15 +6,17 @@ import ( | ||
6 | "oppmg/protocol" | 6 | "oppmg/protocol" |
7 | "oppmg/utils" | 7 | "oppmg/utils" |
8 | "strings" | 8 | "strings" |
9 | + "time" | ||
9 | ) | 10 | ) |
10 | 11 | ||
11 | type SqlData struct { | 12 | type SqlData struct { |
13 | + Id int64 `orm:"column(id)"` | ||
12 | UserId int64 `orm:"column(user_id)"` | 14 | UserId int64 `orm:"column(user_id)"` |
13 | DepartmentId int64 `orm:"column(department_id)"` | 15 | DepartmentId int64 `orm:"column(department_id)"` |
14 | AuditTemplateId int64 `orm:"column(audit_template_id)"` | 16 | AuditTemplateId int64 `orm:"column(audit_template_id)"` |
15 | ChanceTypeId int `orm:"column(chance_type_id)"` | 17 | ChanceTypeId int `orm:"column(chance_type_id)"` |
16 | PublishStatus int `orm:"column(publish_status)"` | 18 | PublishStatus int `orm:"column(publish_status)"` |
17 | - CreateAt string `orm:"column(create_at);type(timestamp)"` | 19 | + CreateAt time.Time `orm:"column(create_at);type(timestamp)"` |
18 | ReviewStatus int `orm:"column(review_status)"` | 20 | ReviewStatus int `orm:"column(review_status)"` |
19 | EnableStatus int `orm:"column(enable_status)"` | 21 | EnableStatus int `orm:"column(enable_status)"` |
20 | DiscoveryScore string `orm:"column(discovery_score)"` | 22 | DiscoveryScore string `orm:"column(discovery_score)"` |
@@ -39,7 +41,7 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | @@ -39,7 +41,7 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | ||
39 | List: make([]protocol.RspAuditList, 0), | 41 | List: make([]protocol.RspAuditList, 0), |
40 | } | 42 | } |
41 | dataStart := (param.PageIndex - 1) * param.PageSize | 43 | dataStart := (param.PageIndex - 1) * param.PageSize |
42 | - datasql.WriteString(`SELECT user_id,department_id,audit_template_id,chance_type_id | 44 | + datasql.WriteString(`SELECT id,user_id,department_id,audit_template_id,chance_type_id |
43 | ,publish_status,create_at,review_status,enable_status | 45 | ,publish_status,create_at,review_status,enable_status |
44 | ,discovery_score,comment_total | 46 | ,discovery_score,comment_total |
45 | FROM chance | 47 | FROM chance |
@@ -60,7 +62,17 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | @@ -60,7 +62,17 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | ||
60 | return returnData, nil | 62 | return returnData, nil |
61 | } | 63 | } |
62 | for _, v := range data { | 64 | for _, v := range data { |
63 | - item := protocol.RspAuditList{} | 65 | + t := v.CreateAt.Unix() |
66 | + item := protocol.RspAuditList{ | ||
67 | + Id: v.Id, | ||
68 | + EnableStatus: v.EnableStatus, | ||
69 | + PublishStatus: v.PublishStatus, | ||
70 | + } | ||
71 | + if t < 0 { | ||
72 | + item.CreateTime = 0 | ||
73 | + } else { | ||
74 | + item.CreateTime = t | ||
75 | + } | ||
64 | if u, err := models.GetUserById(v.UserId); err == nil { | 76 | if u, err := models.GetUserById(v.UserId); err == nil { |
65 | item.UserName = u.NickName | 77 | item.UserName = u.NickName |
66 | } | 78 | } |
@@ -71,7 +83,6 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | @@ -71,7 +83,6 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64) (protocol.Re | ||
71 | item.TemplateName = at.Name | 83 | item.TemplateName = at.Name |
72 | item.Code = at.Code | 84 | item.Code = at.Code |
73 | } | 85 | } |
74 | - | ||
75 | if ct, err := models.GetChanceTypeById(v.ChanceTypeId); err == nil { | 86 | if ct, err := models.GetChanceTypeById(v.ChanceTypeId); err == nil { |
76 | item.ChanceType = ct.Name | 87 | item.ChanceType = ct.Name |
77 | } | 88 | } |
@@ -6,6 +6,7 @@ import ( | @@ -6,6 +6,7 @@ import ( | ||
6 | "oppmg/models" | 6 | "oppmg/models" |
7 | "oppmg/protocol" | 7 | "oppmg/protocol" |
8 | "oppmg/utils" | 8 | "oppmg/utils" |
9 | + "strings" | ||
9 | "time" | 10 | "time" |
10 | ) | 11 | ) |
11 | 12 | ||
@@ -305,3 +306,40 @@ func getRoleGroupByCompany(companyid int64) ([]protocol.RoleInfo, error) { | @@ -305,3 +306,40 @@ func getRoleGroupByCompany(companyid int64) ([]protocol.RoleInfo, error) { | ||
305 | err = utils.ExecuteQueryAll(&roles, datasql, companyid, models.ROLETYPES_GROUP) | 306 | err = utils.ExecuteQueryAll(&roles, datasql, companyid, models.ROLETYPES_GROUP) |
306 | return roles, err | 307 | return roles, err |
307 | } | 308 | } |
309 | + | ||
310 | +func GetRoleHasRole(roleid int64, companyid int64) ([]protocol.RoleHasUser, error) { | ||
311 | + var ( | ||
312 | + roleinfo *models.Role | ||
313 | + err error | ||
314 | + roleuserlist = make([]protocol.RoleHasUser, 0) | ||
315 | + ) | ||
316 | + roleinfo, err = models.GetRoleById(roleid) | ||
317 | + if err != nil { | ||
318 | + log.Error("获取角色数据失败:%s", err) | ||
319 | + return roleuserlist, protocol.NewErrWithMessage("1") | ||
320 | + } | ||
321 | + if roleinfo.CompanyId != companyid { | ||
322 | + log.Error("角色公司不匹配") | ||
323 | + return roleuserlist, protocol.NewErrWithMessage("1") | ||
324 | + } | ||
325 | + var ( | ||
326 | + ucid []string | ||
327 | + datasql string = `SELECT user_company_id FROM user_role | ||
328 | + WHERE company_id=? AND role_id =? AND enable_status = 1` | ||
329 | + datasql2 string = `SELECT a.nick_name,b.id AS user_company_id FROM user AS a,user_company AS b | ||
330 | + WHERE a.id= b.user_id AND b.id IN(?)` | ||
331 | + ) | ||
332 | + err = utils.ExecuteQueryAll(&ucid, datasql, companyid, roleid) | ||
333 | + if err != nil { | ||
334 | + log.Error("获取用户id失败:%s", err) | ||
335 | + return roleuserlist, protocol.NewErrWithMessage("1") | ||
336 | + } | ||
337 | + if len(ucid) == 0 { | ||
338 | + return roleuserlist, nil | ||
339 | + } | ||
340 | + err = utils.ExecuteQueryAll(&roleuserlist, datasql2, strings.Join(ucid, ",")) | ||
341 | + if err != nil { | ||
342 | + log.Error("获取用户时间失败;%s", err) | ||
343 | + } | ||
344 | + return roleuserlist, nil | ||
345 | +} |
-
请 注册 或 登录 后发表评论