|
@@ -5,7 +5,6 @@ import ( |
|
@@ -5,7 +5,6 @@ import ( |
5
|
"oppmg/common/log"
|
5
|
"oppmg/common/log"
|
6
|
"oppmg/models"
|
6
|
"oppmg/models"
|
7
|
"oppmg/protocol"
|
7
|
"oppmg/protocol"
|
8
|
- "oppmg/utils"
|
|
|
9
|
"time"
|
8
|
"time"
|
10
|
)
|
9
|
)
|
11
|
|
10
|
|
|
@@ -59,7 +58,6 @@ func RoleDelete(param protocol.RequestRoleDelete) error { |
|
@@ -59,7 +58,6 @@ func RoleDelete(param protocol.RequestRoleDelete) error { |
59
|
log.Error(e.Error())
|
58
|
log.Error(e.Error())
|
60
|
return protocol.NewErrWithMessage("1", e)
|
59
|
return protocol.NewErrWithMessage("1", e)
|
61
|
}
|
60
|
}
|
62
|
-
|
|
|
63
|
return nil
|
61
|
return nil
|
64
|
}
|
62
|
}
|
65
|
|
63
|
|
|
@@ -79,9 +77,15 @@ func RoleEdit(param protocol.RequestRoleEdit) (*protocol.ResponseRoleInfo, error |
|
@@ -79,9 +77,15 @@ func RoleEdit(param protocol.RequestRoleEdit) (*protocol.ResponseRoleInfo, error |
79
|
log.Error(e.Error())
|
77
|
log.Error(e.Error())
|
80
|
return nil, protocol.NewErrWithMessage("1", e)
|
78
|
return nil, protocol.NewErrWithMessage("1", e)
|
81
|
}
|
79
|
}
|
|
|
80
|
+ role.Pid = param.Pid
|
82
|
role.Descript = param.Descript
|
81
|
role.Descript = param.Descript
|
83
|
role.Name = param.Name
|
82
|
role.Name = param.Name
|
84
|
- if err = models.UpdateRoleById(role, []string{"Descript", "Name"}); err != nil {
|
83
|
+ if err = role.ValidatePid(); err != nil {
|
|
|
84
|
+ e := fmt.Errorf("ValidatePid err:%s", err)
|
|
|
85
|
+ log.Error(e.Error())
|
|
|
86
|
+ return nil, protocol.NewErrWithMessage("1", e)
|
|
|
87
|
+ }
|
|
|
88
|
+ if err = models.UpdateRoleById(role, []string{"Descript", "Name", "Pid"}); err != nil {
|
85
|
e := fmt.Errorf("UpdateRoleById err:%s", err)
|
89
|
e := fmt.Errorf("UpdateRoleById err:%s", err)
|
86
|
log.Error(e.Error())
|
90
|
log.Error(e.Error())
|
87
|
return nil, protocol.NewErrWithMessage("1", e)
|
91
|
return nil, protocol.NewErrWithMessage("1", e)
|
|
@@ -99,37 +103,37 @@ func RoleGetOne(param protocol.RequestRoleOne) (*protocol.ResponseRoleInfo, erro |
|
@@ -99,37 +103,37 @@ func RoleGetOne(param protocol.RequestRoleOne) (*protocol.ResponseRoleInfo, erro |
99
|
return nil, nil
|
103
|
return nil, nil
|
100
|
}
|
104
|
}
|
101
|
|
105
|
|
102
|
-func RoleGetByPage(param protocol.RequestRoleList) (*protocol.ResponseRoleList, error) {
|
|
|
103
|
- var (
|
|
|
104
|
- where string = `a.company_id=? and a.delete_at=0`
|
|
|
105
|
- dataSql string = `SELECT a.id,a.name,a.descript,a.create_at,a.update_at
|
|
|
106
|
- FROM role AS a
|
|
|
107
|
- where ` + where
|
|
|
108
|
- countSql string = `SELECT COUNT(*) FROM role as a where ` + where
|
|
|
109
|
- )
|
|
|
110
|
- var (
|
|
|
111
|
- roleList []protocol.ResponseRoleInfo
|
|
|
112
|
- pageinfo protocol.ResponsePageInfo
|
|
|
113
|
- err error
|
|
|
114
|
- )
|
|
|
115
|
- pagequery := utils.NewQueryDataByPage(countSql, dataSql)
|
|
|
116
|
- pagequery.LimitPage(param.PageIndex, param.PageSize)
|
|
|
117
|
- pagequery.AddParam(param.CompanyId)
|
|
|
118
|
- pageinfo, err = pagequery.Query(&roleList)
|
|
|
119
|
- if err != nil {
|
|
|
120
|
- e := fmt.Errorf("SQL EXECUTE err:%s", err)
|
|
|
121
|
- log.Error(e.Error())
|
|
|
122
|
- return nil, protocol.NewErrWithMessage("1", e)
|
|
|
123
|
- }
|
|
|
124
|
- r := &protocol.ResponseRoleList{
|
|
|
125
|
- ResponsePageInfo: pageinfo,
|
|
|
126
|
- Data: roleList,
|
|
|
127
|
- }
|
|
|
128
|
- return r, nil
|
|
|
129
|
-}
|
106
|
+// func RoleGetByPage(param protocol.RequestRoleList) (*protocol.ResponseRoleList, error) {
|
|
|
107
|
+// var (
|
|
|
108
|
+// where string = `a.company_id=? and a.delete_at=0`
|
|
|
109
|
+// dataSql string = `SELECT a.id,a.name,a.descript,a.create_at,a.update_at
|
|
|
110
|
+// FROM role AS a
|
|
|
111
|
+// where ` + where
|
|
|
112
|
+// countSql string = `SELECT COUNT(*) FROM role as a where ` + where
|
|
|
113
|
+// )
|
|
|
114
|
+// var (
|
|
|
115
|
+// roleList []protocol.ResponseRoleInfo
|
|
|
116
|
+// pageinfo protocol.ResponsePageInfo
|
|
|
117
|
+// err error
|
|
|
118
|
+// )
|
|
|
119
|
+// pagequery := utils.NewQueryDataByPage(countSql, dataSql)
|
|
|
120
|
+// pagequery.LimitPage(param.PageIndex, param.PageSize)
|
|
|
121
|
+// pagequery.AddParam(param.CompanyId)
|
|
|
122
|
+// pageinfo, err = pagequery.Query(&roleList)
|
|
|
123
|
+// if err != nil {
|
|
|
124
|
+// e := fmt.Errorf("SQL EXECUTE err:%s", err)
|
|
|
125
|
+// log.Error(e.Error())
|
|
|
126
|
+// return nil, protocol.NewErrWithMessage("1", e)
|
|
|
127
|
+// }
|
|
|
128
|
+// r := &protocol.ResponseRoleList{
|
|
|
129
|
+// ResponsePageInfo: pageinfo,
|
|
|
130
|
+// Data: roleList,
|
|
|
131
|
+// }
|
|
|
132
|
+// return r, nil
|
|
|
133
|
+// }
|
130
|
|
134
|
|
131
|
func GetRoleGroup() error {
|
135
|
func GetRoleGroup() error {
|
132
|
-
|
136
|
+ return nil
|
133
|
}
|
137
|
}
|
134
|
|
138
|
|
135
|
func RoleHasPermission() error {
|
139
|
func RoleHasPermission() error {
|