...
|
...
|
@@ -5,7 +5,6 @@ import ( |
|
|
"oppmg/common/log"
|
|
|
"oppmg/models"
|
|
|
"oppmg/protocol"
|
|
|
"oppmg/utils"
|
|
|
"time"
|
|
|
)
|
|
|
|
...
|
...
|
@@ -59,7 +58,6 @@ func RoleDelete(param protocol.RequestRoleDelete) error { |
|
|
log.Error(e.Error())
|
|
|
return protocol.NewErrWithMessage("1", e)
|
|
|
}
|
|
|
|
|
|
return nil
|
|
|
}
|
|
|
|
...
|
...
|
@@ -79,9 +77,15 @@ func RoleEdit(param protocol.RequestRoleEdit) (*protocol.ResponseRoleInfo, error |
|
|
log.Error(e.Error())
|
|
|
return nil, protocol.NewErrWithMessage("1", e)
|
|
|
}
|
|
|
role.Pid = param.Pid
|
|
|
role.Descript = param.Descript
|
|
|
role.Name = param.Name
|
|
|
if err = models.UpdateRoleById(role, []string{"Descript", "Name"}); err != nil {
|
|
|
if err = role.ValidatePid(); err != nil {
|
|
|
e := fmt.Errorf("ValidatePid err:%s", err)
|
|
|
log.Error(e.Error())
|
|
|
return nil, protocol.NewErrWithMessage("1", e)
|
|
|
}
|
|
|
if err = models.UpdateRoleById(role, []string{"Descript", "Name", "Pid"}); err != nil {
|
|
|
e := fmt.Errorf("UpdateRoleById err:%s", err)
|
|
|
log.Error(e.Error())
|
|
|
return nil, protocol.NewErrWithMessage("1", e)
|
...
|
...
|
@@ -99,37 +103,37 @@ func RoleGetOne(param protocol.RequestRoleOne) (*protocol.ResponseRoleInfo, erro |
|
|
return nil, nil
|
|
|
}
|
|
|
|
|
|
func RoleGetByPage(param protocol.RequestRoleList) (*protocol.ResponseRoleList, error) {
|
|
|
var (
|
|
|
where string = `a.company_id=? and a.delete_at=0`
|
|
|
dataSql string = `SELECT a.id,a.name,a.descript,a.create_at,a.update_at
|
|
|
FROM role AS a
|
|
|
where ` + where
|
|
|
countSql string = `SELECT COUNT(*) FROM role as a where ` + where
|
|
|
)
|
|
|
var (
|
|
|
roleList []protocol.ResponseRoleInfo
|
|
|
pageinfo protocol.ResponsePageInfo
|
|
|
err error
|
|
|
)
|
|
|
pagequery := utils.NewQueryDataByPage(countSql, dataSql)
|
|
|
pagequery.LimitPage(param.PageIndex, param.PageSize)
|
|
|
pagequery.AddParam(param.CompanyId)
|
|
|
pageinfo, err = pagequery.Query(&roleList)
|
|
|
if err != nil {
|
|
|
e := fmt.Errorf("SQL EXECUTE err:%s", err)
|
|
|
log.Error(e.Error())
|
|
|
return nil, protocol.NewErrWithMessage("1", e)
|
|
|
}
|
|
|
r := &protocol.ResponseRoleList{
|
|
|
ResponsePageInfo: pageinfo,
|
|
|
Data: roleList,
|
|
|
}
|
|
|
return r, nil
|
|
|
}
|
|
|
// func RoleGetByPage(param protocol.RequestRoleList) (*protocol.ResponseRoleList, error) {
|
|
|
// var (
|
|
|
// where string = `a.company_id=? and a.delete_at=0`
|
|
|
// dataSql string = `SELECT a.id,a.name,a.descript,a.create_at,a.update_at
|
|
|
// FROM role AS a
|
|
|
// where ` + where
|
|
|
// countSql string = `SELECT COUNT(*) FROM role as a where ` + where
|
|
|
// )
|
|
|
// var (
|
|
|
// roleList []protocol.ResponseRoleInfo
|
|
|
// pageinfo protocol.ResponsePageInfo
|
|
|
// err error
|
|
|
// )
|
|
|
// pagequery := utils.NewQueryDataByPage(countSql, dataSql)
|
|
|
// pagequery.LimitPage(param.PageIndex, param.PageSize)
|
|
|
// pagequery.AddParam(param.CompanyId)
|
|
|
// pageinfo, err = pagequery.Query(&roleList)
|
|
|
// if err != nil {
|
|
|
// e := fmt.Errorf("SQL EXECUTE err:%s", err)
|
|
|
// log.Error(e.Error())
|
|
|
// return nil, protocol.NewErrWithMessage("1", e)
|
|
|
// }
|
|
|
// r := &protocol.ResponseRoleList{
|
|
|
// ResponsePageInfo: pageinfo,
|
|
|
// Data: roleList,
|
|
|
// }
|
|
|
// return r, nil
|
|
|
// }
|
|
|
|
|
|
func GetRoleGroup() error {
|
|
|
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func RoleHasPermission() error {
|
...
|
...
|
|