作者 唐旭辉

日常提交

@@ -26,6 +26,7 @@ type MyConfig struct { @@ -26,6 +26,7 @@ type MyConfig struct {
26 var MConfig *MyConfig 26 var MConfig *MyConfig
27 27
28 func RestMyConfig() *MyConfig { 28 func RestMyConfig() *MyConfig {
  29 + fmt.Println("初始化config")
29 mysqlHost := beego.AppConfig.String("mysql_host") 30 mysqlHost := beego.AppConfig.String("mysql_host")
30 mysqlPort := beego.AppConfig.String("mysql_port") 31 mysqlPort := beego.AppConfig.String("mysql_port")
31 mysqlUser := beego.AppConfig.String("mysql_user") 32 mysqlUser := beego.AppConfig.String("mysql_user")
@@ -2,6 +2,7 @@ package log @@ -2,6 +2,7 @@ package log
2 2
3 import ( 3 import (
4 "encoding/json" 4 "encoding/json"
  5 + "fmt"
5 6
6 "github.com/astaxie/beego/logs" 7 "github.com/astaxie/beego/logs"
7 ) 8 )
@@ -67,6 +68,7 @@ func (config LoggerFile) Name() string { @@ -67,6 +68,7 @@ func (config LoggerFile) Name() string {
67 var logger *logs.BeeLogger 68 var logger *logs.BeeLogger
68 69
69 func ResetLog(config SetLoggerConfig, funcCall bool) { 70 func ResetLog(config SetLoggerConfig, funcCall bool) {
  71 + fmt.Println("初始化log")
70 logger = logs.GetBeeLogger() 72 logger = logs.GetBeeLogger()
71 out := config.Name() 73 out := config.Name()
72 logconf := config.MarshalString() 74 logconf := config.MarshalString()
@@ -2,6 +2,7 @@ package redis @@ -2,6 +2,7 @@ package redis
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "oppmg/common/log"
5 6
6 "github.com/go-redis/redis" 7 "github.com/go-redis/redis"
7 ) 8 )
@@ -18,6 +19,7 @@ const ( @@ -18,6 +19,7 @@ const (
18 var RedisClient *redis.Client 19 var RedisClient *redis.Client
19 20
20 func SetRedis(addr string, password string, db int) { 21 func SetRedis(addr string, password string, db int) {
  22 + log.Info("初始化redis")
21 RedisClient = redis.NewClient(&redis.Options{ 23 RedisClient = redis.NewClient(&redis.Options{
22 Addr: addr, 24 Addr: addr,
23 Password: password, 25 Password: password,
1 #app的名称 1 #app的名称
2 appname = ability 2 appname = ability
3 #运行模式 3 #运行模式
4 -runmode =${ProRunMode||dev} 4 +runmode =${ProRunMode||local}
5 #是否自动渲染页面 5 #是否自动渲染页面
6 autorender = false 6 autorender = false
7 #是否复制请求body 7 #是否复制请求body
@@ -2,32 +2,34 @@ @@ -2,32 +2,34 @@
2 config_name = "local" 2 config_name = "local"
3 #----beego的默认配置 开始--- 3 #----beego的默认配置 开始---
4 #端口号 4 #端口号
5 -httpport = 8081 5 +httpport = 8080
6 #开启应用内监控 6 #开启应用内监控
7 -EnableAdmin = true 7 +EnableAdmin = false
8 AdminPort = 8088 8 AdminPort = 8088
9 -##---beego的默认配置 结束--- 9 +#---beego的默认配置 结束---
10 10
11 #---自定义配置 开始---- 11 #---自定义配置 开始----
12 -#数据库连接  
13 -# sqlconn = "root:root@tcp(127.0.0.1:3306)/ability_display?charset=utf8&loc=Asia%2FShanghai" 12 +##数据库连接
  13 +# sqlconn ="${MYSQL_CONN||root:sutianxia2015@tcp(115.29.205.99:3306)/opportunity?charset=utf8&loc=Asia%2FShanghai}"
14 mysql_user = "${MYSQL_USER||root}" 14 mysql_user = "${MYSQL_USER||root}"
15 mysql_password = "${MYSQL_PASSWORD||sutianxia2015}" 15 mysql_password = "${MYSQL_PASSWORD||sutianxia2015}"
16 mysql_host = "${MYSQL_HOST||115.29.205.99}" 16 mysql_host = "${MYSQL_HOST||115.29.205.99}"
17 mysql_port = "${MYSQL_PORT||3306}" 17 mysql_port = "${MYSQL_PORT||3306}"
18 mysql_db_name = "${MYSQL_DB_NAME||opportunity}" 18 mysql_db_name = "${MYSQL_DB_NAME||opportunity}"
19 -#redis相关配置 19 +##redis相关配置
20 redis_add_port = "127.0.0.1:6379" 20 redis_add_port = "127.0.0.1:6379"
21 redis_auth = "" 21 redis_auth = ""
22 -#log相关配置  
23 -#out_put:"console","file" 22 +##log相关配置
  23 +##out_put:"console","file"
24 log_output = "file" 24 log_output = "file"
25 -#  
26 -log_filename = "./log/ability.log"  
27 -# maxlines =  
28 -# maxsize =  
29 -# daily =  
30 -# maxdays =  
31 -# rotate =  
32 -log_level = "debug" 25 +log_filename = "${aliyun_logs_access||ability.log}"
  26 +log_level = "${LOG_LEVEL||error}"
  27 +
  28 +##统一用户中心相关配置
  29 +ucenter_check_alt = "rsF0pL!6DwjBO735"
  30 +ucenter_base_url = "http://suplus-ucenter-dev.fjmaimaimai.com"
  31 +ucenter_app_key = "39aefef9e22744a3b2d2d3791824ae7b"
  32 +ucenter_secret = "39aefef9e22744a3b2d2d3791824ae7b"
  33 +# 审批流程修改 消息发布
  34 +message_publish = "audit_change"
33 #---自定义配置 结束---- 35 #---自定义配置 结束----
@@ -96,7 +96,7 @@ func (c *AuthController) ChangeCompany() { @@ -96,7 +96,7 @@ func (c *AuthController) ChangeCompany() {
96 return 96 return
97 } 97 }
98 98
99 -//me 99 +//Me
100 //@router /me [get] 100 //@router /me [get]
101 func (c *AuthController) Me() { 101 func (c *AuthController) Me() {
102 var msg *protocol.ResponseMessage 102 var msg *protocol.ResponseMessage
@@ -56,12 +56,15 @@ func (c *CommonController) SelectorRole() { @@ -56,12 +56,15 @@ func (c *CommonController) SelectorRole() {
56 var roles []protocol.RoleBase 56 var roles []protocol.RoleBase
57 switch param.For { 57 switch param.For {
58 case "user": 58 case "user":
  59 + //编辑用户时
59 list := servecommon.SelectorRoleAll(companyid) 60 list := servecommon.SelectorRoleAll(companyid)
60 roles = servecommon.FilterRoleAll(userid, companyid, list) 61 roles = servecommon.FilterRoleAll(userid, companyid, list)
61 case "role": 62 case "role":
  63 + //编辑角色时
62 list := servecommon.SelectorRoleAll(companyid) 64 list := servecommon.SelectorRoleAll(companyid)
63 roles = servecommon.FilterRoleGroup(userid, companyid, list) 65 roles = servecommon.FilterRoleGroup(userid, companyid, list)
64 case "all": 66 case "all":
  67 + //无特殊规则时
65 roles = servecommon.SelectorRoleAll(companyid) 68 roles = servecommon.SelectorRoleAll(companyid)
66 default: 69 default:
67 roles = servecommon.SelectorRoleAll(companyid) 70 roles = servecommon.SelectorRoleAll(companyid)
@@ -362,3 +362,6 @@ func (c *CompanyController) UserList() { @@ -362,3 +362,6 @@ func (c *CompanyController) UserList() {
362 msg = protocol.NewPageDataResponse(result, err) 362 msg = protocol.NewPageDataResponse(result, err)
363 return 363 return
364 } 364 }
  365 +
  366 +//Regist
  367 +// func
@@ -30,13 +30,14 @@ func (c *RbacController) RoleAdd() { @@ -30,13 +30,14 @@ func (c *RbacController) RoleAdd() {
30 msg = protocol.BadRequestParam("1") 30 msg = protocol.BadRequestParam("1")
31 return 31 return
32 } 32 }
  33 + param.Types = models.ROLETYPES_ROLE
33 param.CompanyID = c.GetCompanyId() 34 param.CompanyID = c.GetCompanyId()
34 if param.CompanyID <= 0 { 35 if param.CompanyID <= 0 {
35 log.Error("param.CompanyID <= 0") 36 log.Error("param.CompanyID <= 0")
36 msg = protocol.BadRequestParam("1") 37 msg = protocol.BadRequestParam("1")
37 return 38 return
38 } 39 }
39 - param.Types = models.ROLETYPES_ROLE 40 +
40 r, err := serverbac.RoleAdd(param) 41 r, err := serverbac.RoleAdd(param)
41 msg = protocol.NewReturnResponse(r, err) 42 msg = protocol.NewReturnResponse(r, err)
42 return 43 return
@@ -87,6 +87,8 @@ spec: @@ -87,6 +87,8 @@ spec:
87 value: "stdout" 87 value: "stdout"
88 - name: aliyun_logs_access 88 - name: aliyun_logs_access
89 value: "/opt/logs/oppmg.log" 89 value: "/opt/logs/oppmg.log"
  90 + - name: aliyun_logs_access
  91 + value: "/var/www/opp/file"
90 volumes: 92 volumes:
91 - name: accesslogs 93 - name: accesslogs
92 emptyDir: {} 94 emptyDir: {}
@@ -20,7 +20,6 @@ type Department struct { @@ -20,7 +20,6 @@ type Department struct {
20 Relation string `orm:"column(relation);size(1024)" description:"父子级关系树"` 20 Relation string `orm:"column(relation);size(1024)" description:"父子级关系树"`
21 DeleteAt time.Time `orm:"column(delete_at);type(timestamp)" description:"删除时间"` 21 DeleteAt time.Time `orm:"column(delete_at);type(timestamp)" description:"删除时间"`
22 UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"` 22 UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"`
23 - Member int `orm:"column(member)" description:"成员数量"`  
24 Manages string `orm:"column(managers)" description:"部门负责人id列表 json 数组 []"` 23 Manages string `orm:"column(managers)" description:"部门负责人id列表 json 数组 []"`
25 } 24 }
26 25
@@ -18,7 +18,6 @@ type Position struct { @@ -18,7 +18,6 @@ type Position struct {
18 UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"` 18 UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"`
19 DeleteAt time.Time `orm:"column(delete_at);type(timestamp)" description:"删除时间"` 19 DeleteAt time.Time `orm:"column(delete_at);type(timestamp)" description:"删除时间"`
20 EnableStatus string `orm:"column(enable_status);size(255)" description:"有效状态 1:有效 0:无效"` 20 EnableStatus string `orm:"column(enable_status);size(255)" description:"有效状态 1:有效 0:无效"`
21 - Member int `orm:"column(member)"`  
22 } 21 }
23 22
24 func (t *Position) TableName() string { 23 func (t *Position) TableName() string {
1 -package models  
2 -  
3 -import (  
4 - "fmt"  
5 -  
6 - "github.com/astaxie/beego/orm"  
7 -)  
8 -  
9 -type RoleRelated struct {  
10 - Id int `orm:"column(id);pk"`  
11 - RoleId int64 `orm:"column(role_id)"`  
12 - UserId int64 `orm:"column(user_id)"`  
13 -}  
14 -  
15 -func (t *RoleRelated) TableName() string {  
16 - return "role_related"  
17 -}  
18 -  
19 -func init() {  
20 - orm.RegisterModel(new(RoleRelated))  
21 -}  
22 -  
23 -// AddRoleRelated insert a new RoleRelated into database and returns  
24 -// last inserted Id on success.  
25 -func AddRoleRelated(m *RoleRelated) (id int64, err error) {  
26 - o := orm.NewOrm()  
27 - id, err = o.Insert(m)  
28 - return  
29 -}  
30 -  
31 -// GetRoleRelatedById retrieves RoleRelated by Id. Returns error if  
32 -// Id doesn't exist  
33 -func GetRoleRelatedById(id int) (v *RoleRelated, err error) {  
34 - o := orm.NewOrm()  
35 - v = &RoleRelated{Id: id}  
36 - if err = o.Read(v); err == nil {  
37 - return v, nil  
38 - }  
39 - return nil, err  
40 -}  
41 -  
42 -// UpdateRoleRelated updates RoleRelated by Id and returns error if  
43 -// the record to be updated doesn't exist  
44 -func UpdateRoleRelatedById(m *RoleRelated) (err error) {  
45 - o := orm.NewOrm()  
46 - v := RoleRelated{Id: m.Id}  
47 - // ascertain id exists in the database  
48 - if err = o.Read(&v); err == nil {  
49 - var num int64  
50 - if num, err = o.Update(m); err == nil {  
51 - fmt.Println("Number of records updated in database:", num)  
52 - }  
53 - }  
54 - return  
55 -}  
56 -  
57 -// DeleteRoleRelated deletes RoleRelated by Id and returns error if  
58 -// the record to be deleted doesn't exist  
59 -func DeleteRoleRelated(id int) (err error) {  
60 - o := orm.NewOrm()  
61 - v := RoleRelated{Id: id}  
62 - // ascertain id exists in the database  
63 - if err = o.Read(&v); err == nil {  
64 - var num int64  
65 - if num, err = o.Delete(&RoleRelated{Id: id}); err == nil {  
66 - fmt.Println("Number of records deleted in database:", num)  
67 - }  
68 - }  
69 - return  
70 -}  
71 -  
72 -func CountRoleRelatedByUser(roleid int64) (int64, error) {  
73 - var (  
74 - cnt int64  
75 - err error  
76 - )  
77 - o := orm.NewOrm()  
78 - cnt, err = o.QueryTable(&RoleRelated{}).  
79 - Filter("role_id", roleid).  
80 - Count()  
81 - return cnt, err  
82 -}  
@@ -59,6 +59,7 @@ func AddUserCompany(m *UserCompany, o orm.Ormer) (id int64, err error) { @@ -59,6 +59,7 @@ func AddUserCompany(m *UserCompany, o orm.Ormer) (id int64, err error) {
59 m.CreateAt = time.Now() 59 m.CreateAt = time.Now()
60 m.DeleteAt = time.Unix(0, 0) 60 m.DeleteAt = time.Unix(0, 0)
61 m.UpdateAt = time.Now() 61 m.UpdateAt = time.Now()
  62 + m.Enable = USERCOMPANY_ENABLE_YES
62 id, err = o.Insert(m) 63 id, err = o.Insert(m)
63 return 64 return
64 } 65 }
@@ -81,8 +82,10 @@ func UpdateUserCompanyById(m *UserCompany) (err error) { @@ -81,8 +82,10 @@ func UpdateUserCompanyById(m *UserCompany) (err error) {
81 func GetUserCompanyBy(userid int64, companyId int64) (*UserCompany, error) { 82 func GetUserCompanyBy(userid int64, companyId int64) (*UserCompany, error) {
82 o := orm.NewOrm() 83 o := orm.NewOrm()
83 var data []*UserCompany 84 var data []*UserCompany
84 - _, err := o.QueryTable(&UserCompany{}).Filter("UserId", userid).  
85 - Filter("CompanyId", companyId). 85 + _, err := o.QueryTable(&UserCompany{}).
  86 + Filter("user_id", userid).
  87 + Filter("company_id", companyId).
  88 + Filter("delete_at", 0).
86 All(&data) 89 All(&data)
87 if err != nil { 90 if err != nil {
88 return nil, err 91 return nil, err
@@ -96,8 +99,9 @@ func GetUserCompanyBy(userid int64, companyId int64) (*UserCompany, error) { @@ -96,8 +99,9 @@ func GetUserCompanyBy(userid int64, companyId int64) (*UserCompany, error) {
96 func ExistUserCompany(userid int64, companyId int64) bool { 99 func ExistUserCompany(userid int64, companyId int64) bool {
97 o := orm.NewOrm() 100 o := orm.NewOrm()
98 ok := o.QueryTable(&UserCompany{}). 101 ok := o.QueryTable(&UserCompany{}).
99 - Filter("UserId", userid).  
100 - Filter("CompanyId", companyId). 102 + Filter("user_id", userid).
  103 + Filter("company_id", companyId).
  104 + Filter("delete_at", 0).
101 Exist() 105 Exist()
102 return ok 106 return ok
103 } 107 }
@@ -105,8 +109,8 @@ func ExistUserCompany(userid int64, companyId int64) bool { @@ -105,8 +109,8 @@ func ExistUserCompany(userid int64, companyId int64) bool {
105 func EnableUserCompany(userid int64, companyid int64) error { 109 func EnableUserCompany(userid int64, companyid int64) error {
106 o := orm.NewOrm() 110 o := orm.NewOrm()
107 _, err := o.QueryTable(&UserCompany{}). 111 _, err := o.QueryTable(&UserCompany{}).
108 - Filter("UserId", userid).  
109 - Filter("CompanyId", companyid).Update(orm.Params{ 112 + Filter("user_id", userid).
  113 + Filter("company_id", companyid).Update(orm.Params{
110 "enable": USERCOMPANY_ENABLE_YES, 114 "enable": USERCOMPANY_ENABLE_YES,
111 "delete_at": 0, 115 "delete_at": 0,
112 }) 116 })
@@ -8,12 +8,13 @@ import ( @@ -8,12 +8,13 @@ import (
8 ) 8 )
9 9
10 type UserDepartment struct { 10 type UserDepartment struct {
11 - Id int64 `orm:"column(id);auto" description:"主键"`  
12 - UserId int64 `orm:"column(user_id)" description:"用户id"`  
13 - CompanyId int64 `orm:"column(company_id)" description:"公司id"`  
14 - DepartmentId int64 `orm:"column(department_id)" description:"部门id"`  
15 - CreateTime time.Time `orm:"column(create_time);type(timestamp);null" description:"创建时间"`  
16 - EnableStatus int8 `orm:"column(enable_status)" description:"是否有效"` 11 + Id int64 `orm:"column(id);auto" description:"主键"`
  12 + UserId int64 `orm:"column(user_id)" description:"用户id"`
  13 + CompanyId int64 `orm:"column(company_id)" description:"公司id"`
  14 + DepartmentId int64 `orm:"column(department_id)" description:"部门id"`
  15 + CreateTime time.Time `orm:"column(create_time);type(timestamp);null" description:"创建时间"`
  16 + EnableStatus int8 `orm:"column(enable_status)" description:"是否有效"`
  17 + UserCompanyId int64 `orm:"column(user_company_id)"`
17 } 18 }
18 19
19 func (t *UserDepartment) TableName() string { 20 func (t *UserDepartment) TableName() string {
@@ -98,3 +99,16 @@ func GetUserDepartment(userid, companyid int64) ([]*UserDepartment, error) { @@ -98,3 +99,16 @@ func GetUserDepartment(userid, companyid int64) ([]*UserDepartment, error) {
98 All(&result) 99 All(&result)
99 return result, err 100 return result, err
100 } 101 }
  102 +
  103 +func CountUserDepartByDepart(departid int64) (int64, error) {
  104 + var (
  105 + cnt int64
  106 + err error
  107 + )
  108 + o := orm.NewOrm()
  109 + cnt, err = o.QueryTable(&UserDepartment{}).
  110 + Filter("department_id", departid).
  111 + Filter("enable_status", 1).
  112 + Count()
  113 + return cnt, err
  114 +}
@@ -8,12 +8,13 @@ import ( @@ -8,12 +8,13 @@ import (
8 ) 8 )
9 9
10 type UserPosition struct { 10 type UserPosition struct {
11 - Id int64 `orm:"column(id);pk" description:"唯一键值"`  
12 - UserId int64 `orm:"column(user_id)" description:"表user.id 用户编号"`  
13 - PositionId int64 `orm:"column(position_id)" description:"表position.id 职位编号"`  
14 - CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间"`  
15 - CompanyId int64 `orm:"column(company_id)" description:"表company.id 公司编号"`  
16 - EnableStatus int8 `orm:"column(enable_status);null" description:"是否有效 1:有效 2:无效"` 11 + Id int64 `orm:"column(id);pk" description:"唯一键值"`
  12 + UserId int64 `orm:"column(user_id)" description:"表user.id 用户编号"`
  13 + PositionId int64 `orm:"column(position_id)" description:"表position.id 职位编号"`
  14 + CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间"`
  15 + CompanyId int64 `orm:"column(company_id)" description:"表company.id 公司编号"`
  16 + EnableStatus int8 `orm:"column(enable_status);null" description:"是否有效 1:有效 2:无效"`
  17 + UserCompanyId int64 `orm:"column(user_company_id)"`
17 } 18 }
18 19
19 func (t *UserPosition) TableName() string { 20 func (t *UserPosition) TableName() string {
@@ -73,3 +74,16 @@ func GetUserPosition(userid, companyid int64) ([]*UserPosition, error) { @@ -73,3 +74,16 @@ func GetUserPosition(userid, companyid int64) ([]*UserPosition, error) {
73 All(&result) 74 All(&result)
74 return result, err 75 return result, err
75 } 76 }
  77 +
  78 +func CountUserPositionByPosition(positionid int64) (int64, error) {
  79 + var (
  80 + cnt int64
  81 + err error
  82 + )
  83 + o := orm.NewOrm()
  84 + cnt, err = o.QueryTable(&UserPosition{}).
  85 + Filter("position_id", positionid).
  86 + Filter("enable_status", 1).
  87 + Count()
  88 + return cnt, err
  89 +}
@@ -7,11 +7,12 @@ import ( @@ -7,11 +7,12 @@ import (
7 ) 7 )
8 8
9 type UserRole struct { 9 type UserRole struct {
10 - Id int `orm:"column(id);pk"`  
11 - RoleId int64 `orm:"column(role_id)"`  
12 - UserId int64 `orm:"column(user_id)"`  
13 - EnableStatus int8 `orm:"column(enable_status)" description:"是否有效"`  
14 - CompanyId int64 `orm:"column(company_id)" description:"表company.id 公司编号"` 10 + Id int `orm:"column(id);pk"`
  11 + RoleId int64 `orm:"column(role_id)"`
  12 + UserId int64 `orm:"column(user_id)"`
  13 + EnableStatus int8 `orm:"column(enable_status)" description:"是否有效"`
  14 + CompanyId int64 `orm:"column(company_id)" description:"表company.id 公司编号"`
  15 + UserCompanyId int64 `orm:"column(user_company_id)"`
15 } 16 }
16 17
17 func (t *UserRole) TableName() string { 18 func (t *UserRole) TableName() string {
@@ -71,3 +72,16 @@ func GetUserRole(userid, companyid int64) ([]*UserRole, error) { @@ -71,3 +72,16 @@ func GetUserRole(userid, companyid int64) ([]*UserRole, error) {
71 All(&result) 72 All(&result)
72 return result, err 73 return result, err
73 } 74 }
  75 +
  76 +func CountUserRoleByRole(roleid int64) (int64, error) {
  77 + var (
  78 + cnt int64
  79 + err error
  80 + )
  81 + o := orm.NewOrm()
  82 + cnt, err = o.QueryTable(&UserRole{}).
  83 + Filter("role_id", roleid).
  84 + Filter("enable_status", 1).
  85 + Count()
  86 + return cnt, err
  87 +}
@@ -36,12 +36,12 @@ type ResponseDepartmentInfo struct { @@ -36,12 +36,12 @@ type ResponseDepartmentInfo struct {
36 Name string `json:"name"` //部门名字 36 Name string `json:"name"` //部门名字
37 ParantID int64 `json:"parant_id"` //父级部门Id 37 ParantID int64 `json:"parant_id"` //父级部门Id
38 Manages []DepartmentManager `json:"manages"` //部门管理员 38 Manages []DepartmentManager `json:"manages"` //部门管理员
39 - Member int `json:"member"` //成员数 39 + Member int64 `json:"member"` //成员数
40 } 40 }
41 41
42 //ResponseDepartmentList .... 42 //ResponseDepartmentList ....
43 type ResponseDepartmentList struct { 43 type ResponseDepartmentList struct {
44 - List []ResponseDepartmentInfo 44 + List []ResponseDepartmentInfo `json:"list"`
45 } 45 }
46 46
47 //RequestPositionAdd 添加职位 47 //RequestPositionAdd 添加职位
@@ -100,10 +100,10 @@ type ResponseUserList struct { @@ -100,10 +100,10 @@ type ResponseUserList struct {
100 } 100 }
101 101
102 type UserListItem struct { 102 type UserListItem struct {
103 - UserId int64 `json:"user_id" orm:"column(user_id)"`  
104 - NickName string `json:"nick_name" orm:"column(nick_name)"`  
105 - Positions string `json:"positions" orm:"-"`  
106 - Roles string `json:"roles" orm:"-"`  
107 - Departments string `json:"departments" orm:"-"`  
108 - Enable int8 `json:"enable" orm:"column(enable)"` 103 + UserCompanydId int64 `json:"user_company_id" orm:"column(user_company_id)"`
  104 + NickName string `json:"nick_name" orm:"column(nick_name)"`
  105 + Positions string `json:"positions" orm:"-"`
  106 + Roles string `json:"roles" orm:"-"`
  107 + Departments string `json:"departments" orm:"-"`
  108 + Enable int8 `json:"enable" orm:"column(enable)"`
109 } 109 }
@@ -26,6 +26,7 @@ var errmessge ErrorMap = map[string]string{ @@ -26,6 +26,7 @@ var errmessge ErrorMap = map[string]string{
26 "10036": "请输入正确的手机格式", 26 "10036": "请输入正确的手机格式",
27 "10037": "用户的部门必填", 27 "10037": "用户的部门必填",
28 "10038": "用户的角色必填", 28 "10038": "用户的角色必填",
  29 + "10039": "用户已存在",
29 } 30 }
30 31
31 //错误码转换 ,兼容需要 32 //错误码转换 ,兼容需要
@@ -6,7 +6,7 @@ type RequestRoleAdd struct { @@ -6,7 +6,7 @@ type RequestRoleAdd struct {
6 Pid int64 `json:"pid"` 6 Pid int64 `json:"pid"`
7 Name string `json:"name"` 7 Name string `json:"name"`
8 Types int8 `json:"types"` 8 Types int8 `json:"types"`
9 - Descript string `json:"descript"` 9 + // Descript string `json:"descript"`
10 } 10 }
11 11
12 //RequestRoleDelete 删除一个角色数据 12 //RequestRoleDelete 删除一个角色数据
@@ -14,13 +14,13 @@ func init() { @@ -14,13 +14,13 @@ func init() {
14 beego.NSBefore(middleware.LogRequestData), 14 beego.NSBefore(middleware.LogRequestData),
15 //beego.NSBefore(middleware.AuthToken), 15 //beego.NSBefore(middleware.AuthToken),
16 beego.NSNamespace("/department", 16 beego.NSNamespace("/department",
17 - beego.NSRouter("/list", &controllers.CompanyController{}, "get:DepartmentList"), 17 + beego.NSRouter("/list", &controllers.CompanyController{}, "post:DepartmentList"),
18 beego.NSRouter("/add", &controllers.CompanyController{}, "post:DepartmentAdd"), 18 beego.NSRouter("/add", &controllers.CompanyController{}, "post:DepartmentAdd"),
19 beego.NSRouter("/edit", &controllers.CompanyController{}, "post:DepartmentUpdate"), 19 beego.NSRouter("/edit", &controllers.CompanyController{}, "post:DepartmentUpdate"),
20 beego.NSRouter("/delete", &controllers.CompanyController{}, "post:DepartmentDelete"), 20 beego.NSRouter("/delete", &controllers.CompanyController{}, "post:DepartmentDelete"),
21 ), 21 ),
22 beego.NSNamespace("position", 22 beego.NSNamespace("position",
23 - beego.NSRouter("/list", &controllers.CompanyController{}, "get:PositionList"), 23 + beego.NSRouter("/list", &controllers.CompanyController{}, "post:PositionList"),
24 beego.NSRouter("/add", &controllers.CompanyController{}, "post:PositionAdd"), 24 beego.NSRouter("/add", &controllers.CompanyController{}, "post:PositionAdd"),
25 beego.NSRouter("/edit", &controllers.CompanyController{}, "post:PositionEdit"), 25 beego.NSRouter("/edit", &controllers.CompanyController{}, "post:PositionEdit"),
26 beego.NSRouter("/delete", &controllers.CompanyController{}, "post:PositionDelete"), 26 beego.NSRouter("/delete", &controllers.CompanyController{}, "post:PositionDelete"),
@@ -32,9 +32,9 @@ func init() { @@ -32,9 +32,9 @@ func init() {
32 beego.NSRouter("/role_group/add", &controllers.RbacController{}, "post:RoleGroupAdd"), 32 beego.NSRouter("/role_group/add", &controllers.RbacController{}, "post:RoleGroupAdd"),
33 beego.NSRouter("/role_group/edit", &controllers.RbacController{}, "post:RoleGroupUpdate"), 33 beego.NSRouter("/role_group/edit", &controllers.RbacController{}, "post:RoleGroupUpdate"),
34 beego.NSRouter("/role_group/delete", &controllers.RbacController{}, "post:RoleGroupDelete"), 34 beego.NSRouter("/role_group/delete", &controllers.RbacController{}, "post:RoleGroupDelete"),
35 - beego.NSRouter("/role", &controllers.RbacController{}, "get:RoleList"), 35 + beego.NSRouter("/role/list", &controllers.RbacController{}, "post:RoleList"),
36 ), 36 ),
37 - beego.NSNamespace("/user/", 37 + beego.NSNamespace("/user",
38 beego.NSRouter("/list", &controllers.CompanyController{}, "post:UserList"), 38 beego.NSRouter("/list", &controllers.CompanyController{}, "post:UserList"),
39 beego.NSRouter("/add", &controllers.CompanyController{}, "post:UserAdd"), 39 beego.NSRouter("/add", &controllers.CompanyController{}, "post:UserAdd"),
40 beego.NSRouter("/edit", &controllers.CompanyController{}, "post:UserEdit"), 40 beego.NSRouter("/edit", &controllers.CompanyController{}, "post:UserEdit"),
@@ -42,7 +42,8 @@ func init() { @@ -42,7 +42,8 @@ func init() {
42 ), 42 ),
43 beego.NSNamespace("/auth", 43 beego.NSNamespace("/auth",
44 beego.NSRouter("/change_company", &controllers.AuthController{}, "post:ChangeCompany"), 44 beego.NSRouter("/change_company", &controllers.AuthController{}, "post:ChangeCompany"),
45 - beego.NSRouter("/refresh_token", &controllers.AuthController{}, "get:RefreshToken"), 45 + beego.NSRouter("/refresh_token", &controllers.AuthController{}, "post:RefreshToken"),
  46 + beego.NSRouter("/me", &controllers.AuthController{}, "post:Me"),
46 ), 47 ),
47 beego.NSNamespace("/bulletin", 48 beego.NSNamespace("/bulletin",
48 beego.NSRouter("/add", &controllers.BulletinController{}, "post:BulletinRelease"), 49 beego.NSRouter("/add", &controllers.BulletinController{}, "post:BulletinRelease"),
@@ -50,7 +51,7 @@ func init() { @@ -50,7 +51,7 @@ func init() {
50 beego.NSRouter("/get", &controllers.BulletinController{}, "post:GetBulletin"), 51 beego.NSRouter("/get", &controllers.BulletinController{}, "post:GetBulletin"),
51 beego.NSRouter("/update", &controllers.BulletinController{}, "post:UpdateBulletin"), 52 beego.NSRouter("/update", &controllers.BulletinController{}, "post:UpdateBulletin"),
52 ), 53 ),
53 - beego.NSNamespace("common", 54 + beego.NSNamespace("/common",
54 beego.NSRouter("/department", &controllers.CommonController{}, "post:SelectorDepartment"), 55 beego.NSRouter("/department", &controllers.CommonController{}, "post:SelectorDepartment"),
55 beego.NSRouter("/role", &controllers.CommonController{}, "post:SelectorRole"), 56 beego.NSRouter("/role", &controllers.CommonController{}, "post:SelectorRole"),
56 beego.NSRouter("/position", &controllers.CommonController{}, "post:SelectorPosition"), 57 beego.NSRouter("/position", &controllers.CommonController{}, "post:SelectorPosition"),
@@ -45,7 +45,6 @@ func DepartmentAdd(param protocol.RequestDepartmentAdd) (protocol.ResponseDepart @@ -45,7 +45,6 @@ func DepartmentAdd(param protocol.RequestDepartmentAdd) (protocol.ResponseDepart
45 CreateAt: time.Now(), 45 CreateAt: time.Now(),
46 UpdateAt: time.Now(), 46 UpdateAt: time.Now(),
47 ParentId: param.ParentID, 47 ParentId: param.ParentID,
48 - Member: 0,  
49 } 48 }
50 departmentAdd.SetManages(param.Managers) 49 departmentAdd.SetManages(param.Managers)
51 o := orm.NewOrm() 50 o := orm.NewOrm()
@@ -207,61 +206,6 @@ func departmentRelationUpdate(departUpdate *models.Department, newparent *models @@ -207,61 +206,6 @@ func departmentRelationUpdate(departUpdate *models.Department, newparent *models
207 return nil 206 return nil
208 } 207 }
209 208
210 -//DepartmentDelete 部门删除,删除整个分枝  
211 -// func DepartmentDelete(param protocol.RequestDepartmentDelete) error {  
212 -// var (  
213 -// departDelete *models.Department  
214 -// err error  
215 -// )  
216 -// departDelete, err = models.GetDepartmentById(param.ID)  
217 -// if err != nil {  
218 -// e := fmt.Errorf("GetDepartmentById err:%s", err)  
219 -// log.Error(e.Error())  
220 -// return protocol.NewErrWithMessage("1", e)  
221 -// }  
222 -// if departDelete.CompanyId != param.CompanyID {  
223 -// e := fmt.Errorf("departDelete.CompanyId != param.CompanyID")  
224 -// log.Error(e.Error())  
225 -// return protocol.NewErrWithMessage("1", e)  
226 -// }  
227 -// const (  
228 -// //获取部门子集 锁数据 select ... for update,  
229 -// dataSql0 string = `SELECT id,relation,member FROM department WHERE relation LIKE ? AND delete_at = 0 FOR UPDATE`  
230 -// dataSql2 string = `update department set delete_at=? where relation LIKE ?`  
231 -// )  
232 -// var (  
233 -// departSubset []models.Department  
234 -// relationLike string = departDelete.Relation + "%"  
235 -// nowTime string = time.Now().String()  
236 -// )  
237 -// o := orm.NewOrm()  
238 -// o.Begin()  
239 -// err = utils.ExecuteQueryAllWithOrmer(o, &departSubset, dataSql0, relationLike)  
240 -// if err != nil {  
241 -// o.Rollback()  
242 -// e := fmt.Errorf("")  
243 -// log.Error(e.Error())  
244 -// return protocol.NewErrWithMessage("1", e)  
245 -// }  
246 -// for _, v := range departSubset {  
247 -// if v.Member > 0 {  
248 -// o.Rollback()  
249 -// e := fmt.Errorf("Member > 0 ")  
250 -// log.Error(e.Error())  
251 -// return protocol.NewErrWithMessage("1", e)  
252 -// }  
253 -// }  
254 -// err = utils.ExecuteSQLWithOrmer(o, dataSql2, nowTime, relationLike)  
255 -// if err != nil {  
256 -// o.Rollback()  
257 -// e := fmt.Errorf("EXECUTE SQL err:%s", err)  
258 -// log.Error(e.Error())  
259 -// return protocol.NewErrWithMessage("1", e)  
260 -// }  
261 -// o.Commit()  
262 -// return nil  
263 -// }  
264 -  
265 func DepartmentDelete(param protocol.RequestDepartmentDelete) error { 209 func DepartmentDelete(param protocol.RequestDepartmentDelete) error {
266 //检查是否可以被删除 210 //检查是否可以被删除
267 var ( 211 var (
@@ -301,7 +245,12 @@ func DepartmentDelete(param protocol.RequestDepartmentDelete) error { @@ -301,7 +245,12 @@ func DepartmentDelete(param protocol.RequestDepartmentDelete) error {
301 return protocol.NewErrWithMessage("1", e) 245 return protocol.NewErrWithMessage("1", e)
302 } 246 }
303 for _, subset := range departSubset { 247 for _, subset := range departSubset {
304 - if subset.Member > 0 { 248 + cnt, err := models.CountUserDepartByDepart(subset.Id)
  249 + if err != nil {
  250 + log.Error("CountUserDepartByDepart err:%s", err)
  251 + return protocol.NewErrWithMessage("1")
  252 + }
  253 + if cnt > 0 {
305 e := fmt.Errorf("user in department,relation:%s", subset.Relation) 254 e := fmt.Errorf("user in department,relation:%s", subset.Relation)
306 log.Error(e.Error()) 255 log.Error(e.Error())
307 return protocol.NewErrWithMessage("1", e) 256 return protocol.NewErrWithMessage("1", e)
@@ -347,9 +296,13 @@ func DepartmentListAll(companyId int64) ([]protocol.ResponseDepartmentInfo, erro @@ -347,9 +296,13 @@ func DepartmentListAll(companyId int64) ([]protocol.ResponseDepartmentInfo, erro
347 return nil, protocol.NewErrWithMessage("1", err) 296 return nil, protocol.NewErrWithMessage("1", err)
348 } 297 }
349 for _, v := range departmodels { 298 for _, v := range departmodels {
  299 + cnt, err := models.CountUserDepartByDepart(v.Id)
  300 + if err != nil {
  301 + log.Error("CountUserDepartByDepart err:%s", err)
  302 + }
350 depart := protocol.ResponseDepartmentInfo{ 303 depart := protocol.ResponseDepartmentInfo{
351 ID: v.Id, CompanyID: v.CompanyId, 304 ID: v.Id, CompanyID: v.CompanyId,
352 - Name: v.Name, Member: v.Member, 305 + Name: v.Name, Member: cnt,
353 ParantID: v.ParentId, 306 ParantID: v.ParentId,
354 } 307 }
355 var manage []protocol.DepartmentManager 308 var manage []protocol.DepartmentManager
@@ -218,7 +218,7 @@ func PositionDelete(param protocol.RequestPositionDelete) error { @@ -218,7 +218,7 @@ func PositionDelete(param protocol.RequestPositionDelete) error {
218 var p *models.Position 218 var p *models.Position
219 p, err := models.GetPositionById(id) 219 p, err := models.GetPositionById(id)
220 if err != nil { 220 if err != nil {
221 - e := fmt.Errorf("GetPositionById(%d)", id) 221 + e := fmt.Errorf("GetPositionById(%d) err:%s", id, err)
222 log.Error(e.Error()) 222 log.Error(e.Error())
223 return protocol.NewErrWithMessage("1", e) 223 return protocol.NewErrWithMessage("1", e)
224 } 224 }
@@ -240,10 +240,15 @@ func PositionDelete(param protocol.RequestPositionDelete) error { @@ -240,10 +240,15 @@ func PositionDelete(param protocol.RequestPositionDelete) error {
240 return protocol.NewErrWithMessage("1", e) 240 return protocol.NewErrWithMessage("1", e)
241 } 241 }
242 for _, subset := range positionsubset { 242 for _, subset := range positionsubset {
243 - if subset.Member > 0 { 243 + cnt, err := models.CountUserPositionByPosition(subset.Id)
  244 + if err != nil {
  245 + log.Error("CountUserPositionByPosition err:%s", err)
  246 + return protocol.NewErrWithMessage("1")
  247 + }
  248 + if cnt > 0 {
244 e := fmt.Errorf("user in position,relation:%s", subset.Relation) 249 e := fmt.Errorf("user in position,relation:%s", subset.Relation)
245 log.Error(e.Error()) 250 log.Error(e.Error())
246 - return protocol.NewErrWithMessage("1", e) 251 + return protocol.NewErrWithMessage("10011", e)
247 } 252 }
248 if _, ok := toDelete[subset.Id]; ok { 253 if _, ok := toDelete[subset.Id]; ok {
249 delete(toDelete, subset.Id) 254 delete(toDelete, subset.Id)
@@ -6,6 +6,7 @@ import ( @@ -6,6 +6,7 @@ import (
6 "oppmg/models" 6 "oppmg/models"
7 "oppmg/protocol" 7 "oppmg/protocol"
8 "oppmg/utils" 8 "oppmg/utils"
  9 + "strings"
9 "time" 10 "time"
10 11
11 "github.com/astaxie/beego/orm" 12 "github.com/astaxie/beego/orm"
@@ -16,6 +17,11 @@ func UserAdd(param protocol.RequestUserAdd) error { @@ -16,6 +17,11 @@ func UserAdd(param protocol.RequestUserAdd) error {
16 userm *models.User 17 userm *models.User
17 err error 18 err error
18 ) 19 )
  20 + //校验用户
  21 + err = validCompanyUser(param.CompanyId, param.Phone)
  22 + if err != nil {
  23 + return err
  24 + }
19 //校验角色 25 //校验角色
20 err = validCompanyRole(param.CompanyId, param.Roles) 26 err = validCompanyRole(param.CompanyId, param.Roles)
21 if err != nil { 27 if err != nil {
@@ -134,6 +140,23 @@ func validCompanyPosition(companyid int64, positionid []int64) error { @@ -134,6 +140,23 @@ func validCompanyPosition(companyid int64, positionid []int64) error {
134 return nil 140 return nil
135 } 141 }
136 142
  143 +func validCompanyUser(companyid int64, phone string) error {
  144 + userdata, err := models.GetUserByPhone(phone)
  145 + if err == orm.ErrNoRows {
  146 + return nil
  147 + }
  148 + if err != nil {
  149 + log.Error("database operate fail:%s", err)
  150 + return protocol.NewErrWithMessage("1")
  151 + }
  152 +
  153 + ok := models.ExistUserCompany(userdata.Id, companyid)
  154 + if ok {
  155 + protocol.NewErrWithMessage("10039")
  156 + }
  157 + return nil
  158 +}
  159 +
137 //registUser 注册用户 160 //registUser 注册用户
138 func registUser(userIn *models.User, companyid int64, o orm.Ormer) error { 161 func registUser(userIn *models.User, companyid int64, o orm.Ormer) error {
139 var ( 162 var (
@@ -163,15 +186,15 @@ func registUser(userIn *models.User, companyid int64, o orm.Ormer) error { @@ -163,15 +186,15 @@ func registUser(userIn *models.User, companyid int64, o orm.Ormer) error {
163 CompanyId: companyid, 186 CompanyId: companyid,
164 UserId: userIn.Id, 187 UserId: userIn.Id,
165 } 188 }
166 - ok := models.ExistUserCompany(usrData.Id, companyid)  
167 - if !ok {  
168 - _, err = models.AddUserCompany(musercompany, o)  
169 - if err != nil {  
170 - return err  
171 - } 189 + // ok := models.ExistUserCompany(usrData.Id, companyid)
  190 + // if !ok {
  191 + _, err = models.AddUserCompany(musercompany, o)
  192 + if err != nil {
  193 + return err
172 } 194 }
173 - err = models.EnableUserCompany(usrData.Id, companyid)  
174 - return err 195 + // }
  196 + // err = models.EnableUserCompany(usrData.Id, companyid)
  197 + return nil
175 } 198 }
176 199
177 func editUserDepart(userid int64, companyid int64, departids []int64, o orm.Ormer) error { 200 func editUserDepart(userid int64, companyid int64, departids []int64, o orm.Ormer) error {
@@ -257,7 +280,7 @@ func editUserRole(userid int64, companyid int64, roleids []int64, o orm.Ormer) e @@ -257,7 +280,7 @@ func editUserRole(userid int64, companyid int64, roleids []int64, o orm.Ormer) e
257 addRoleIds []int64 280 addRoleIds []int64
258 ) 281 )
259 dataSql := `SELECT role_id FROM user_role WHERE enable_status=1 AND company_id=? AND user_id=?` 282 dataSql := `SELECT role_id FROM user_role WHERE enable_status=1 AND company_id=? AND user_id=?`
260 - dataSql2 := `UPDATE user_position SET enable_status = 2 WHERE company_id =? AND user_id=? AND role_id=?` 283 + dataSql2 := `UPDATE user_role SET enable_status = 2 WHERE company_id =? AND user_id=? AND role_id=?`
261 datasql3 := `INSERT INTO user_role (user_id,role_id,company_id,enable_status) VALUES (?,?,?,?)` 284 datasql3 := `INSERT INTO user_role (user_id,role_id,company_id,enable_status) VALUES (?,?,?,?)`
262 err = utils.ExecuteQueryAllWithOrmer(o, &oldRoleIds, dataSql, companyid, userid) 285 err = utils.ExecuteQueryAllWithOrmer(o, &oldRoleIds, dataSql, companyid, userid)
263 if err != nil { 286 if err != nil {
@@ -291,6 +314,10 @@ func UserEdit(param protocol.RequestUserEdit) error { @@ -291,6 +314,10 @@ func UserEdit(param protocol.RequestUserEdit) error {
291 userm *models.User 314 userm *models.User
292 err error 315 err error
293 ) 316 )
  317 + err = validCompanyUser(param.CompanyId, param.Phone)
  318 + if err != nil {
  319 + return err
  320 + }
294 //校验角色 321 //校验角色
295 err = validCompanyRole(param.CompanyId, param.Roles) 322 err = validCompanyRole(param.CompanyId, param.Roles)
296 if err != nil { 323 if err != nil {
@@ -322,6 +349,7 @@ func UserEdit(param protocol.RequestUserEdit) error { @@ -322,6 +349,7 @@ func UserEdit(param protocol.RequestUserEdit) error {
322 // log.Error("registUser err:%s", err) 349 // log.Error("registUser err:%s", err)
323 // return protocol.NewErrWithMessage("1") 350 // return protocol.NewErrWithMessage("1")
324 // } 351 // }
  352 + // TODO 用户数据更新
325 //添加角色 353 //添加角色
326 err = editUserRole(userm.Id, param.CompanyId, param.Roles, o) 354 err = editUserRole(userm.Id, param.CompanyId, param.Roles, o)
327 if err != nil { 355 if err != nil {
@@ -371,7 +399,7 @@ func UserDelete(userid, companyid int64) error { @@ -371,7 +399,7 @@ func UserDelete(userid, companyid int64) error {
371 399
372 func UserList(param protocol.RequestUserList) (protocol.ResponseUserList, error) { 400 func UserList(param protocol.RequestUserList) (protocol.ResponseUserList, error) {
373 401
374 - datasql := `SELECT a.company_id,a.user_id,a.enable, b.phone,b.nick_name 402 + datasql := `SELECT a.id as user_company_id,a.company_id,a.user_id,a.enable, b.phone,b.nick_name
375 FROM user_company AS a 403 FROM user_company AS a
376 LEFT JOIN user AS b ON a.user_id = b.id 404 LEFT JOIN user AS b ON a.user_id = b.id
377 WHERE a.company_id=? AND a.delete_at = 0 ` 405 WHERE a.company_id=? AND a.delete_at = 0 `
@@ -404,20 +432,77 @@ func UserList(param protocol.RequestUserList) (protocol.ResponseUserList, error) @@ -404,20 +432,77 @@ func UserList(param protocol.RequestUserList) (protocol.ResponseUserList, error)
404 log.Error(e.Error()) 432 log.Error(e.Error())
405 return responseData, protocol.NewErrWithMessage("0") 433 return responseData, protocol.NewErrWithMessage("0")
406 } 434 }
407 - // for k, v := range result {  
408 - // positions, _ := models.GetUserPosition(v.UserId, param.Companyid)  
409 - // departments, _ := models.GetUserDepartment(v.UserId, param.Companyid)  
410 - // roles, _ := models.GetUserRole(v.UserId, param.Companyid)  
411 - // } 435 + for k, v := range result {
  436 + var (
  437 + pname []string
  438 + dname []string
  439 + rname []string
  440 + )
  441 + positions := GetUserPosition(v.UserCompanydId)
  442 + for i := range positions {
  443 + pname = append(pname, positions[i].Name)
  444 + }
  445 + departments := GetUserDepartment(v.UserCompanydId)
  446 + for i := range departments {
  447 + dname = append(dname, departments[i].Name)
  448 + }
  449 + roles := GetUserRole(v.UserCompanydId)
  450 + for i := range roles {
  451 + rname = append(rname, roles[i].Name)
  452 + }
  453 + result[k].Departments = strings.Join(dname, ",")
  454 + result[k].Positions = strings.Join(pname, ",")
  455 + result[k].Roles = strings.Join(rname, ",")
  456 + }
412 responseData.ResponsePageInfo = pageInfo 457 responseData.ResponsePageInfo = pageInfo
413 responseData.List = result 458 responseData.List = result
414 return responseData, nil 459 return responseData, nil
415 } 460 }
416 461
417 -func GetUserDepartment(user int64, companyid int64) {  
418 - 462 +func GetUserDepartment(usercompanyid int64) []protocol.DepartmentBase {
  463 + const datasql string = `SELECT b.name,b.parent_id,b.id FROM user_department AS a
  464 + JOIN department AS b ON a.department_id = b.id
  465 + WHERE a.enable_status =1 AND a.user_company_id =? `
  466 + var (
  467 + err error
  468 + data []protocol.DepartmentBase
  469 + )
  470 + err = utils.ExecuteQueryAll(&data, datasql, usercompanyid)
  471 + if err != nil {
  472 + e := fmt.Errorf("EXECUTE SQL err:%s", err)
  473 + log.Error(e.Error())
  474 + }
  475 + return data
419 } 476 }
420 477
421 -func GetUserPosition(user int64, companyid int64) { 478 +func GetUserPosition(usercompanyid int64) []protocol.PositionBase {
  479 + const datasql string = `SELECT b.name,b.parent_id,b.id FROM user_position AS a
  480 + JOIN position AS b ON a.position_id = b.id
  481 + WHERE a.enable_status =1 AND a.user_company_id =? `
  482 + var (
  483 + err error
  484 + data []protocol.PositionBase
  485 + )
  486 + err = utils.ExecuteQueryAll(&data, datasql, usercompanyid)
  487 + if err != nil {
  488 + e := fmt.Errorf("EXECUTE SQL err:%s", err)
  489 + log.Error(e.Error())
  490 + }
  491 + return data
  492 +}
422 493
  494 +func GetUserRole(usercompanyid int64) []protocol.RoleBase {
  495 + const datasql string = `SELECT b.name,b.pid,b.id FROM user_role AS a
  496 + JOIN role AS b ON a.role_id = b.id
  497 + WHERE a.enable_status =1 AND a.user_company_id =? `
  498 + var (
  499 + err error
  500 + data []protocol.RoleBase
  501 + )
  502 + err = utils.ExecuteQueryAll(&data, datasql, usercompanyid)
  503 + if err != nil {
  504 + e := fmt.Errorf("EXECUTE SQL err:%s", err)
  505 + log.Error(e.Error())
  506 + }
  507 + return data
423 } 508 }
@@ -17,7 +17,7 @@ func RoleAdd(param protocol.RequestRoleAdd) (*protocol.ResponseRoleInfo, error) @@ -17,7 +17,7 @@ func RoleAdd(param protocol.RequestRoleAdd) (*protocol.ResponseRoleInfo, error)
17 CreateAt: nowTime, 17 CreateAt: nowTime,
18 Pid: param.Pid, 18 Pid: param.Pid,
19 Types: param.Types, 19 Types: param.Types,
20 - Descript: param.Descript, 20 + // Descript: param.Descript,
21 } 21 }
22 if ok := role.ValidateTypes(); !ok { 22 if ok := role.ValidateTypes(); !ok {
23 e := fmt.Errorf("ValidateTypes err") 23 e := fmt.Errorf("ValidateTypes err")
@@ -66,7 +66,7 @@ func RoleDelete(param protocol.RequestRoleDelete) error { @@ -66,7 +66,7 @@ func RoleDelete(param protocol.RequestRoleDelete) error {
66 log.Error(e.Error()) 66 log.Error(e.Error())
67 return protocol.NewErrWithMessage("1") 67 return protocol.NewErrWithMessage("1")
68 } 68 }
69 - cnt, err := models.CountRoleRelatedByUser(param.RoleID) 69 + cnt, err := models.CountUserRoleByRole(param.RoleID)
70 if err != nil { 70 if err != nil {
71 log.Error(err.Error()) 71 log.Error(err.Error())
72 return protocol.NewErrWithMessage("1") 72 return protocol.NewErrWithMessage("1")
@@ -99,7 +99,7 @@ func RoleEdit(param protocol.RequestRoleEdit) (*protocol.ResponseRoleInfo, error @@ -99,7 +99,7 @@ func RoleEdit(param protocol.RequestRoleEdit) (*protocol.ResponseRoleInfo, error
99 return nil, protocol.NewErrWithMessage("1", e) 99 return nil, protocol.NewErrWithMessage("1", e)
100 } 100 }
101 role.Pid = param.Pid 101 role.Pid = param.Pid
102 - role.Descript = param.Descript 102 + //role.Descript = param.Descript
103 role.Name = param.Name 103 role.Name = param.Name
104 if _, err = role.ValidatePid(); err != nil { 104 if _, err = role.ValidatePid(); err != nil {
105 e := fmt.Errorf("ValidatePid err:%s", err) 105 e := fmt.Errorf("ValidatePid err:%s", err)
@@ -301,7 +301,7 @@ token 的响应内容 @@ -301,7 +301,7 @@ token 的响应内容
301 301
302 ```json 302 ```json
303 { 303 {
304 - "id": [1, 2, 3] 304 + "ids": [1, 2, 3]
305 } 305 }
306 ``` 306 ```
307 307
@@ -311,7 +311,7 @@ token 的响应内容 @@ -311,7 +311,7 @@ token 的响应内容
311 { 311 {
312 "code": 0, 312 "code": 0,
313 "msg": "成功", 313 "msg": "成功",
314 - "data":null 314 + "data": null
315 } 315 }
316 ``` 316 ```
317 317
@@ -384,7 +384,7 @@ token 的响应内容 @@ -384,7 +384,7 @@ token 的响应内容
384 384
385 ```json 385 ```json
386 { 386 {
387 - "ids": [1, 23] 387 + "id": 1
388 } 388 }
389 ``` 389 ```
390 390
@@ -527,7 +527,7 @@ obj.status 状态 0-所有 1-下架 2-上架 @@ -527,7 +527,7 @@ obj.status 状态 0-所有 1-下架 2-上架
527 527
528 ```json 528 ```json
529 { 529 {
530 - "id":5 530 + "id": 5
531 } 531 }
532 ``` 532 ```
533 533