作者 唐旭辉

bug fix

... ... @@ -34,3 +34,14 @@ func GetRoleMenuByRole(roleid int64) ([]RoleMenu, error) {
}
return list, err
}
func GetRoleMenuByCode(roleId int64, code string) (*RoleMenu, error) {
// data := []RoleMenu{}
// o := orm.NewOrm()
// _, err := o.QueryTable(&Role{}).
// Filter("role_id", roleId).
// Filter("code", code).
// All(&data)
return nil, nil
}
... ...
... ... @@ -44,8 +44,8 @@ var errmessge ErrorMap = map[string]string{
"10037": "用户的部门必填",
"10038": "用户的角色必填",
"10039": "用户已存在",
"10071": "不能删除主管",
"10072": "不能禁用主管",
"10071": "不能删除主管理员",
"10072": "不能禁用主管理员",
//部门相关
"10041": "无效的主管设置",
"10042": "上级部门不能选择当前部门及其子部门",
... ...
... ... @@ -21,12 +21,6 @@ type RequestRoleEdit struct {
RequestRoleAdd
}
//RequestRoleOne 获取一个角色数据
// type RequestRoleOne struct {
// CompanyID int `json:"company_id"`
// RoleID int `json:"role_id"`
// }
//ResponseRoleInfo 响应数据
type ResponseRoleInfo struct {
ID int64 `json:"id"`
... ... @@ -81,5 +75,5 @@ type ResponseRoleMenus struct {
MenuId []int64 `json:"menu_ids"`
}
type ResponseRolePermission struct {
}
// type ResponseRolePermission struct {
// }
... ...
... ... @@ -158,3 +158,32 @@ func RoleMenuEdit(companyid int64, roleId int64, menuids []int64) error {
o.Commit()
return nil
}
//机会管理高级设置
func UpdateSetOpportunity() error {
return nil
}
//机会管理高级设置
func GetSetOpportunity(roleid int64, companyid int64) (*OptionOpportunity, error) {
setting := &OptionOpportunity{
CheckOption: CheckOpp{
Departments: []CheckDeparment{},
},
}
var (
//code = M_SYSTEM_OPPORTUNITY
roleInfo *models.Role
err error
)
roleInfo, err = models.GetRoleById(roleid)
if err != nil {
log.Error("获取角色数据失败:%s", err)
return setting, protocol.NewErrWithMessage("1")
}
if roleInfo.CompanyId != companyid {
log.Error("角色公司不匹配")
return setting, protocol.NewErrWithMessage("1")
}
return setting, nil
}
... ...
package rbac
import "encoding/json"
type UserObject struct {
UserId int64 `json:"user_id"`
CompanyId int64 `json:"company_id"`
... ... @@ -39,20 +37,20 @@ func (p *PermissionOptionBase) GetValidFunc(k string) func(UserObject) bool {
return nil
}
//StringUnmarshal PermissionOptionBase 接口实现
func (p *PermissionOptionBase) StringUnmarshal(s string) error {
err := json.Unmarshal([]byte(s), p)
return err
}
//ObjectMarshal PermissionOptionBase 接口实现
func (p *PermissionOptionBase) ObjectMarshal() string {
bt, err := json.Marshal(p)
if err != nil {
return ""
}
return string(bt)
}
// //StringUnmarshal PermissionOptionBase 接口实现
// func (p *PermissionOptionBase) StringUnmarshal(s string) error {
// err := json.Unmarshal([]byte(s), p)
// return err
// }
// //ObjectMarshal PermissionOptionBase 接口实现
// func (p *PermissionOptionBase) ObjectMarshal() string {
// bt, err := json.Marshal(p)
// if err != nil {
// return ""
// }
// return string(bt)
// }
/*
机会管理模块
... ... @@ -60,17 +58,19 @@ CheckOpp
CheckDeparment
OptionOpportunity
*/
//CheckOpp 特殊的查看条件设定
type CheckOpp struct {
Departments []CheckDeparment `json:"departments"`
}
//CheckDeparment 特殊的查看条件设定中关于部门的设定
type CheckDeparment struct {
Id int64 `json:"id"`
Wait int `json:"wail"`
OpenAll int `json:"open_all"`
OpenDepart int `json:"open_depart"`
Id int64 `json:"id"`
Name string `json:"name,omitempty"`
Wait int `json:"wail"`
OpenAll int `json:"open_all"`
OpenDepart int `json:"open_depart"`
}
//CheckOpp 特殊的查看条件设定
type CheckOpp struct {
Departments []CheckDeparment `json:"departments"`
}
//OptionOpportunity 机会管理 高级权限设置
... ... @@ -82,25 +82,36 @@ type OptionOpportunity struct {
CloseChance int `json:"close_chance"`
}
/*
机会管理高级设置中的 check
1:禁止查看所有机会:禁止查看所有机会(除自己提交过的机会及可执行审核操作的机会)
2:仅查看自己部门和公开机会:查看对自己部门公开的机会+公司公开的机会
3:特定部门的机会:自由配置选定部门的待审核、公司公开、部门公开的机会+查看对自己部门公开的机会
4:查看所有机会:查看所有部门的待审核机会、公开机会及部门公开机会
*/
const (
OpportunityCheckLv1 int = 1
OpportunityCheckLv2 int = 2
OpportunityCheckLv3 int = 3
OpportunityCheckLv4 int = 4
)
var (
_ PermissionOptionObject = &OptionOpportunity{}
)
func NewOptionOpportunity() PermissionOptionObject {
return &OptionOpportunity{}
}
func (p *OptionOpportunity) ValidDefault(obj UserObject) bool {
if p.Check == 1 {
return true
return &OptionOpportunity{
CheckOption: CheckOpp{
Departments: []CheckDeparment{},
},
}
return false
}
//GetValidFunc PermissionOptionBase 接口实现
func (p *OptionOpportunity) GetValidFunc(k string) func(UserObject) bool {
m := map[string]func(UserObject) bool{
"default": p.ValidDefault,
"check": p.ValidCheck,
}
if _, ok := m[k]; ok {
return m[k]
... ... @@ -108,17 +119,37 @@ func (p *OptionOpportunity) GetValidFunc(k string) func(UserObject) bool {
return nil
}
//StringUnmarshal PermissionOptionBase 接口实现
func (p *OptionOpportunity) StringUnmarshal(s string) error {
err := json.Unmarshal([]byte(s), p)
return err
func (p *OptionOpportunity) ValidCheck(obj UserObject) bool {
if p.Check > 0 {
return true
}
return false
}
//ObjectMarshal PermissionOptionBase 接口实现
func (p *OptionOpportunity) ObjectMarshal() string {
bt, err := json.Marshal(p)
if err != nil {
return ""
func (p *OptionOpportunity) ValidEditSorce(obj UserObject) bool {
if p.EditSorce > 0 {
return true
}
return false
}
func (p *OptionOpportunity) ValidEditPublicStatus(obj UserObject) bool {
if p.EditPublicStatus > 0 {
return true
}
return string(bt)
return false
}
// //StringUnmarshal PermissionOptionBase 接口实现
// func (p *OptionOpportunity) StringUnmarshal(s string) error {
// err := json.Unmarshal([]byte(s), p)
// return err
// }
// //ObjectMarshal PermissionOptionBase 接口实现
// func (p *OptionOpportunity) ObjectMarshal() string {
// bt, err := json.Marshal(p)
// if err != nil {
// return ""
// }
// return string(bt)
// }
... ...
... ... @@ -26,8 +26,7 @@ func RequestUCenterLogin(account, password string) (*ResponseLogin, error) {
log.Error("解析统一用户中心响应失败 err:%s", err)
return nil, protocol.NewErrWithMessage("1")
}
if !(uclientReturn.Code == ResponseCode0 &&
uclientReturn.Msg == ResponseMsgOk) {
if !(uclientReturn.Code == ResponseCode0) {
return nil, protocol.NewErrWithMessage("10052")
}
return uclientReturn, nil
... ... @@ -58,8 +57,7 @@ func RequestUCenterAddUser(phone string, nickname string, avatar string) (*Respo
log.Error("解析统一用户中心响应失败 err:%s", err)
return nil, protocol.NewErrWithMessage("1")
}
if !(ucenterReturn.Code == ResponseCode0 &&
ucenterReturn.Msg == ResponseMsgOk) {
if !(ucenterReturn.Code == ResponseCode0) {
return nil, protocol.NewErrWithMessage("10052")
}
return ucenterReturn, nil
... ... @@ -85,8 +83,7 @@ func RequestUCenterSmsCode(phone string) error {
log.Error("解析统一用户中心响应失败 err:%s", err)
return protocol.NewErrWithMessage("1")
}
if !(ucenterReturn.Code == ResponseCode0 &&
ucenterReturn.Msg == ResponseMsgOk) {
if !(ucenterReturn.Code == ResponseCode0) {
return protocol.NewErrWithMessage("10052")
}
return nil
... ... @@ -105,17 +102,16 @@ func RequestUCenterLoginSms(phone string, captcha string) (*ResponseLoginSms, er
log.Error("统一用户中心请求失败 err:%s", err)
return nil, protocol.NewErrWithMessage("1")
}
var ucenterReturn *ResponseLoginSms
err = json.Unmarshal(btBody, ucenterReturn)
var ucenterReturn ResponseLoginSms
err = json.Unmarshal(btBody, &ucenterReturn)
if err != nil {
log.Error("解析统一用户中心响应失败 err:%s", err)
return nil, protocol.NewErrWithMessage("1")
}
if !(ucenterReturn.Code == ResponseCode0 &&
ucenterReturn.Msg == ResponseMsgOk) {
if !(ucenterReturn.Code == ResponseCode0) {
return nil, protocol.NewErrWithMessage("10052")
}
return ucenterReturn, nil
return &ucenterReturn, nil
}
func RequestUCenterSmsCodeCheck(phone string, captcha string) (*ResponseSmsCodeCheck, error) {
... ... @@ -135,8 +131,7 @@ func RequestUCenterSmsCodeCheck(phone string, captcha string) (*ResponseSmsCodeC
log.Error("解析统一用户中心响应失败 err:%s", err)
return nil, protocol.NewErrWithMessage("1")
}
if !(ucenterReturn.Code == ResponseCode0 &&
ucenterReturn.Msg == ResponseMsgOk) {
if !(ucenterReturn.Code == ResponseCode0) {
return nil, protocol.NewErrWithMessage("10026")
}
return ucenterReturn, nil
... ... @@ -161,8 +156,7 @@ func RequestUCenterRestPassword(phone, newPwd, confirmPwd, certificate string) e
log.Error("解析统一用户中心响应失败 err:%s", err)
return protocol.NewErrWithMessage("1")
}
if !(ucenterReturn.Code == ResponseCode0 &&
ucenterReturn.Msg == ResponseMsgOk) {
if !(ucenterReturn.Code == ResponseCode0) {
return protocol.NewErrWithMessage("10052")
}
... ...
... ... @@ -12,8 +12,7 @@ import (
)
const (
ResponseCode0 int = 0
ResponseMsgOk string = "ok"
ResponseCode0 int = 0
)
type IUCenterParam interface {
... ...