正在显示
5 个修改的文件
包含
49 行增加
和
8 行删除
@@ -420,6 +420,7 @@ func (c *CompanyController) InitCompany() { | @@ -420,6 +420,7 @@ func (c *CompanyController) InitCompany() { | ||
420 | return | 420 | return |
421 | } | 421 | } |
422 | 422 | ||
423 | +// GetCompanyForUCenter 总后台调用 | ||
423 | //@router /ucenter/company/info [post] | 424 | //@router /ucenter/company/info [post] |
424 | func (c *CompanyController) GetCompanyForUCenter() { | 425 | func (c *CompanyController) GetCompanyForUCenter() { |
425 | var msg *protocol.ResponseMessage | 426 | var msg *protocol.ResponseMessage |
@@ -427,6 +428,28 @@ func (c *CompanyController) GetCompanyForUCenter() { | @@ -427,6 +428,28 @@ func (c *CompanyController) GetCompanyForUCenter() { | ||
427 | c.ResposeJson(msg) | 428 | c.ResposeJson(msg) |
428 | }() | 429 | }() |
429 | type Paremeter struct { | 430 | type Paremeter struct { |
431 | + Companyid int64 `json:"company_id"` | ||
432 | + CompanyName string `json:"company_name"` | ||
433 | + } | ||
434 | + var param Paremeter | ||
435 | + if err := json.Unmarshal(c.Ctx.Input.RequestBody, ¶m); err != nil { | ||
436 | + log.Error("json 解析失败 err:%s", err) | ||
437 | + msg = protocol.BadRequestParam("1") | ||
438 | + return | ||
439 | + } | ||
440 | + err := servecompany.CompanyEditFromUcenter(param.Companyid, param.CompanyName) | ||
441 | + msg = protocol.NewReturnResponse(nil, err) | ||
442 | + return | ||
443 | +} | ||
444 | + | ||
445 | +//EditCompanyForUCenter | ||
446 | +//@router /ucenter/company/edit [post] | ||
447 | +func (c *CompanyController) EditCompanyForUCenter() { | ||
448 | + var msg *protocol.ResponseMessage | ||
449 | + defer func() { | ||
450 | + c.ResposeJson(msg) | ||
451 | + }() | ||
452 | + type Paremeter struct { | ||
430 | Companyid int64 `json:"company_id"` | 453 | Companyid int64 `json:"company_id"` |
431 | } | 454 | } |
432 | var param Paremeter | 455 | var param Paremeter |
@@ -112,6 +112,7 @@ type UserListItem struct { | @@ -112,6 +112,7 @@ type UserListItem struct { | ||
112 | Positions string `json:"positions" orm:"-"` | 112 | Positions string `json:"positions" orm:"-"` |
113 | Roles string `json:"roles" orm:"-"` | 113 | Roles string `json:"roles" orm:"-"` |
114 | Departments string `json:"departments" orm:"-"` | 114 | Departments string `json:"departments" orm:"-"` |
115 | + Phone string `json:"phone" orm:"column(phone)"` | ||
115 | Enable int8 `json:"enable" orm:"column(enable)"` | 116 | Enable int8 `json:"enable" orm:"column(enable)"` |
116 | } | 117 | } |
117 | 118 | ||
@@ -123,16 +124,15 @@ type ResponseCompanyBase struct { | @@ -123,16 +124,15 @@ type ResponseCompanyBase struct { | ||
123 | 124 | ||
124 | //CenterCompanyInfo 统一用户中心调用的公司数据 | 125 | //CenterCompanyInfo 统一用户中心调用的公司数据 |
125 | type CenterCompanyInfo struct { | 126 | type CenterCompanyInfo struct { |
126 | - CompanyId int64 `json:"company_id"` //总后台的公司id | ||
127 | - CompanyName string `json:"company_name"` // | ||
128 | - // AdminId int64 `json:"admin_id"` //统一用户中心的用户id | 127 | + CompanyId int64 `json:"company_id"` //总后台的公司id |
128 | + CompanyName string `json:"company_name"` // | ||
129 | AdminAccount string `json:"admin_account"` | 129 | AdminAccount string `json:"admin_account"` |
130 | AdminName string `json:"admin_name"` | 130 | AdminName string `json:"admin_name"` |
131 | Status int8 `json:"status"` //公司的状态 【1:启用】【2:禁用】 | 131 | Status int8 `json:"status"` //公司的状态 【1:启用】【2:禁用】 |
132 | } | 132 | } |
133 | 133 | ||
134 | func (c CenterCompanyInfo) IsEnable() bool { | 134 | func (c CenterCompanyInfo) IsEnable() bool { |
135 | - if c.Status == 1 || c.Status == 0 { | 135 | + if c.Status == 1 { |
136 | return true | 136 | return true |
137 | } | 137 | } |
138 | return false | 138 | return false |
@@ -97,6 +97,7 @@ func init() { | @@ -97,6 +97,7 @@ func init() { | ||
97 | beego.NSBefore(middleware.LogRequestData), | 97 | beego.NSBefore(middleware.LogRequestData), |
98 | beego.NSRouter("/company", &controllers.CompanyController{}, "post:InitCompany"), | 98 | beego.NSRouter("/company", &controllers.CompanyController{}, "post:InitCompany"), |
99 | beego.NSRouter("/company/info", &controllers.CompanyController{}, "post:GetCompanyForUCenter"), | 99 | beego.NSRouter("/company/info", &controllers.CompanyController{}, "post:GetCompanyForUCenter"), |
100 | + beego.NSRouter("/company/edit", &controllers.CompanyController{}, "post:EditCompanyForUCenter"), | ||
100 | ) | 101 | ) |
101 | 102 | ||
102 | beego.AddNamespace(nsV1) | 103 | beego.AddNamespace(nsV1) |
@@ -403,6 +403,23 @@ func CompanyInfoEdit(companyid int64, logo string) error { | @@ -403,6 +403,23 @@ func CompanyInfoEdit(companyid int64, logo string) error { | ||
403 | 403 | ||
404 | return nil | 404 | return nil |
405 | } | 405 | } |
406 | + | ||
407 | +// | ||
408 | +func CompanyEditFromUcenter(companyid int64, companyname string) error { | ||
409 | + companyinfo, err := models.GetCompanyByUCenter(companyid) | ||
410 | + if err != nil { | ||
411 | + log.Error("获取公司数据失败") | ||
412 | + return protocol.NewErrWithMessage("1") | ||
413 | + } | ||
414 | + companyinfo.Name = companyname | ||
415 | + err = models.UpdateCompanyById(companyinfo, []string{"Name"}) | ||
416 | + if err != nil { | ||
417 | + log.Info("更新公司数据失败:%s", err) | ||
418 | + return protocol.NewErrWithMessage("1") | ||
419 | + } | ||
420 | + return nil | ||
421 | +} | ||
422 | + | ||
406 | func CompanyBaseInfo(companyid int64) (*protocol.ResponseCompanyBase, error) { | 423 | func CompanyBaseInfo(companyid int64) (*protocol.ResponseCompanyBase, error) { |
407 | var ( | 424 | var ( |
408 | err error | 425 | err error |
@@ -538,9 +538,9 @@ func UserList(param protocol.RequestUserList) (protocol.ResponseUserList, error) | @@ -538,9 +538,9 @@ func UserList(param protocol.RequestUserList) (protocol.ResponseUserList, error) | ||
538 | } | 538 | } |
539 | for k, v := range result { | 539 | for k, v := range result { |
540 | var ( | 540 | var ( |
541 | - pname []string | ||
542 | - dname []string | ||
543 | - rname []string | 541 | + pname = make([]string, 0) |
542 | + dname = make([]string, 0) | ||
543 | + rname = make([]string, 0) | ||
544 | ) | 544 | ) |
545 | positions := GetUserPosition(v.UserCompanydId) | 545 | positions := GetUserPosition(v.UserCompanydId) |
546 | for i := range positions { | 546 | for i := range positions { |
@@ -570,7 +570,7 @@ func GetUserDepartment(usercompanyid int64) []protocol.DepartmentBase { | @@ -570,7 +570,7 @@ func GetUserDepartment(usercompanyid int64) []protocol.DepartmentBase { | ||
570 | WHERE a.enable_status =1 AND a.user_company_id =? ` | 570 | WHERE a.enable_status =1 AND a.user_company_id =? ` |
571 | var ( | 571 | var ( |
572 | err error | 572 | err error |
573 | - data []protocol.DepartmentBase | 573 | + data = make([]protocol.DepartmentBase, 0) |
574 | ) | 574 | ) |
575 | err = utils.ExecuteQueryAll(&data, datasql, usercompanyid) | 575 | err = utils.ExecuteQueryAll(&data, datasql, usercompanyid) |
576 | if err != nil { | 576 | if err != nil { |
-
请 注册 或 登录 后发表评论