作者 唐旭辉

更新bug

... ... @@ -14,4 +14,10 @@
| 删除部门 | 完成 | 2019.11.29 | /v1/company/department | delete |
| 添加职位 | 进行中 | | /v1/company/position | post |
| 编辑职位 | 进行中 | | /v1/company/position | put |
| 删除职位 | 进行中 | | /v1/company/position | delete |
| 删除职位 | 进行中 | | | delete |
| 添加员工 | 未开始 | | | post |
| 编辑员工 | 未开始 | | | put |
| 删除员工 | 未开始 | | | delete |
| 公告管理 | 未开始 | | | |
| 公告管理 | 未开始 | | | |
| 公告管理 | 未开始 | | | |
... ...
... ... @@ -60,6 +60,7 @@ func (t *Role) ValidatePid() error {
// last inserted Id on success.
func AddRole(m *Role) (id int64, err error) {
o := orm.NewOrm()
m.CreateAt = time.Now()
id, err = o.Insert(m)
return
}
... ...
... ... @@ -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 {
... ...