作者 唐旭辉

更新bug

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