正在显示
5 个修改的文件
包含
54 行增加
和
20 行删除
| @@ -391,7 +391,7 @@ func (c *CompanyController) InitCompany() { | @@ -391,7 +391,7 @@ func (c *CompanyController) InitCompany() { | ||
| 391 | if ok := param.IsEnable(); ok { | 391 | if ok := param.IsEnable(); ok { |
| 392 | err = servecompany.InitCompanyInfo(param) | 392 | err = servecompany.InitCompanyInfo(param) |
| 393 | } else if ok := param.IsForbid(); ok { | 393 | } else if ok := param.IsForbid(); ok { |
| 394 | - | 394 | + err = servecompany.ForbidCompany(param.CompanyId) |
| 395 | } else { | 395 | } else { |
| 396 | err = protocol.NewErrWithMessage("1") | 396 | err = protocol.NewErrWithMessage("1") |
| 397 | } | 397 | } |
| @@ -400,6 +400,25 @@ func (c *CompanyController) InitCompany() { | @@ -400,6 +400,25 @@ func (c *CompanyController) InitCompany() { | ||
| 400 | return | 400 | return |
| 401 | } | 401 | } |
| 402 | 402 | ||
| 403 | +//@router /ucenter/company/info [post] | ||
| 404 | +func (c *CompanyController) GetCompanyForUCenter() { | ||
| 405 | + var msg *protocol.ResponseMessage | ||
| 406 | + defer func() { | ||
| 407 | + c.ResposeJson(msg) | ||
| 408 | + }() | ||
| 409 | + type Paremeter struct { | ||
| 410 | + Companyid int64 `json:"company_id"` | ||
| 411 | + } | ||
| 412 | + var param protocol.CenterCompanyInfo | ||
| 413 | + if err := json.Unmarshal(c.Ctx.Input.RequestBody, ¶m); err != nil { | ||
| 414 | + log.Error("json 解析失败 err:%s", err) | ||
| 415 | + msg = protocol.BadRequestParam("1") | ||
| 416 | + return | ||
| 417 | + } | ||
| 418 | + msg = protocol.NewReturnResponse(nil, nil) | ||
| 419 | + return | ||
| 420 | +} | ||
| 421 | + | ||
| 403 | //DepartmentUser 获取部门下成员 | 422 | //DepartmentUser 获取部门下成员 |
| 404 | //@router /department/user [post] | 423 | //@router /department/user [post] |
| 405 | func (c *CompanyController) DepartmentUser() { | 424 | func (c *CompanyController) DepartmentUser() { |
| @@ -82,13 +82,14 @@ var AllowOption = func(ctx *context.Context) { | @@ -82,13 +82,14 @@ var AllowOption = func(ctx *context.Context) { | ||
| 82 | } | 82 | } |
| 83 | f := cors.Allow(&cors.Options{ | 83 | f := cors.Allow(&cors.Options{ |
| 84 | AllowMethods: []string{"POST", "GET", "OPTIONS", "PUT", "DELETE"}, //允许的请求类型 | 84 | AllowMethods: []string{"POST", "GET", "OPTIONS", "PUT", "DELETE"}, //允许的请求类型 |
| 85 | - AllowHeaders: []string{"Origin", "Authorization", "Access-Control-Allow-Origin", | ||
| 86 | - "x-mmm-cid", "x-mmm-uid", "x-mmm-accesstoken", "x-mmm-refreshtoken"}, //允许的头部信息 | ||
| 87 | - ExposeHeaders: []string{"Content-Length", "Content-Type", "Access-Control-Allow-Origin"}, //允许暴露的头信息 | 85 | + AllowHeaders: []string{"Origin", "Accept", "Content-Type", "Authorization", |
| 86 | + "x-mmm-cid", "x-mmm-uid", "x-mmm-accesstoken", "x-mmm-refreshtoken", "x-requested-with"}, //允许的头部信息 | ||
| 87 | + ExposeHeaders: []string{"Content-Length"}, //允许暴露的头信息 | ||
| 88 | AllowCredentials: false, //不允许共享AuthTuffic证书 | 88 | AllowCredentials: false, //不允许共享AuthTuffic证书 |
| 89 | AllowAllOrigins: true, //允许的请求来源 | 89 | AllowAllOrigins: true, //允许的请求来源 |
| 90 | }) | 90 | }) |
| 91 | f(ctx) | 91 | f(ctx) |
| 92 | + ctx.Output.SetStatus(204) | ||
| 92 | ctx.Output.Body([]byte("{}")) | 93 | ctx.Output.Body([]byte("{}")) |
| 93 | return | 94 | return |
| 94 | } | 95 | } |
| @@ -84,15 +84,12 @@ func GetCompanyById(id int64) (v *Company, err error) { | @@ -84,15 +84,12 @@ func GetCompanyById(id int64) (v *Company, err error) { | ||
| 84 | // the record to be updated doesn't exist | 84 | // the record to be updated doesn't exist |
| 85 | func UpdateCompanyById(m *Company, col []string) (err error) { | 85 | func UpdateCompanyById(m *Company, col []string) (err error) { |
| 86 | o := orm.NewOrm() | 86 | o := orm.NewOrm() |
| 87 | - v := Company{Id: m.Id} | ||
| 88 | - // ascertain id exists in the database | ||
| 89 | - if err = o.Read(&v); err == nil { | ||
| 90 | var num int64 | 87 | var num int64 |
| 91 | m.UpdateAt = time.Now() | 88 | m.UpdateAt = time.Now() |
| 92 | if num, err = o.Update(m, col...); err == nil { | 89 | if num, err = o.Update(m, col...); err == nil { |
| 93 | fmt.Println("Number of records updated in database:", num) | 90 | fmt.Println("Number of records updated in database:", num) |
| 94 | } | 91 | } |
| 95 | - } | 92 | + |
| 96 | return | 93 | return |
| 97 | } | 94 | } |
| 98 | 95 |
| @@ -121,13 +121,14 @@ type ResponseCompanyBase struct { | @@ -121,13 +121,14 @@ type ResponseCompanyBase struct { | ||
| 121 | Logo string `json:"logo"` | 121 | Logo string `json:"logo"` |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | +//CenterCompanyInfo 统一用户中心调用的公司数据 | ||
| 124 | type CenterCompanyInfo struct { | 125 | type CenterCompanyInfo struct { |
| 125 | - CompanyId int64 `json:"company_id"` | ||
| 126 | - CompanyName string `json:"company_name"` | ||
| 127 | - AdminId int64 `json:"admin_id"` | 126 | + CompanyId int64 `json:"company_id"` //总后台的公司id |
| 127 | + CompanyName string `json:"company_name"` // | ||
| 128 | + AdminId int64 `json:"admin_id"` //统一用户中心的用户id | ||
| 128 | AdminAccount string `json:"admin_account"` | 129 | AdminAccount string `json:"admin_account"` |
| 129 | AdminName string `json:"admin_name"` | 130 | AdminName string `json:"admin_name"` |
| 130 | - Status int8 `json:"status"` | 131 | + Status int8 `json:"status"` //公司的状态 【1:启用】【2:禁用】 |
| 131 | } | 132 | } |
| 132 | 133 | ||
| 133 | func (c CenterCompanyInfo) IsEnable() bool { | 134 | func (c CenterCompanyInfo) IsEnable() bool { |
| @@ -143,3 +144,5 @@ func (c CenterCompanyInfo) IsForbid() bool { | @@ -143,3 +144,5 @@ func (c CenterCompanyInfo) IsForbid() bool { | ||
| 143 | } | 144 | } |
| 144 | return false | 145 | return false |
| 145 | } | 146 | } |
| 147 | + | ||
| 148 | +// type ResponseCenterCompany |
| @@ -5,6 +5,7 @@ import ( | @@ -5,6 +5,7 @@ import ( | ||
| 5 | "oppmg/common/log" | 5 | "oppmg/common/log" |
| 6 | "oppmg/models" | 6 | "oppmg/models" |
| 7 | "oppmg/protocol" | 7 | "oppmg/protocol" |
| 8 | + "time" | ||
| 8 | 9 | ||
| 9 | "github.com/astaxie/beego/orm" | 10 | "github.com/astaxie/beego/orm" |
| 10 | ) | 11 | ) |
| @@ -440,13 +441,26 @@ func CompanyBaseInfo(companyid int64) (*protocol.ResponseCompanyBase, error) { | @@ -440,13 +441,26 @@ func CompanyBaseInfo(companyid int64) (*protocol.ResponseCompanyBase, error) { | ||
| 440 | } | 441 | } |
| 441 | 442 | ||
| 442 | func ForbidCompany(ucenterCompany int64) error { | 443 | func ForbidCompany(ucenterCompany int64) error { |
| 443 | - // var ( | ||
| 444 | - // err error | ||
| 445 | - // companyData *models.Company | ||
| 446 | - // ) | ||
| 447 | - // companyData, err = models.GetCompanyByUCenter(ucenterCompany) | ||
| 448 | - // if err == orm.ErrNoRows { | ||
| 449 | - // // log.Info() | ||
| 450 | - // } | 444 | + var ( |
| 445 | + err error | ||
| 446 | + companyData *models.Company | ||
| 447 | + ) | ||
| 448 | + companyData, err = models.GetCompanyByUCenter(ucenterCompany) | ||
| 449 | + if err == orm.ErrNoRows { | ||
| 450 | + log.Warn("未查找到公司数据") | ||
| 451 | + return nil | ||
| 452 | + } | ||
| 453 | + if err != nil && err != orm.ErrNoRows { | ||
| 454 | + log.Error(err.Error()) | ||
| 455 | + return protocol.NewErrWithMessage("1") | ||
| 456 | + } | ||
| 457 | + | ||
| 458 | + companyData.Enable = models.COMPANY_ENABLE_NO | ||
| 459 | + companyData.UpdateAt = time.Now() | ||
| 460 | + err = models.UpdateCompanyById(companyData, []string{"Enable", "UpdateAt"}) | ||
| 461 | + if err != nil { | ||
| 462 | + log.Error("更新公司数据失败:%s", err) | ||
| 463 | + return protocol.NewErrWithMessage("1") | ||
| 464 | + } | ||
| 451 | return nil | 465 | return nil |
| 452 | } | 466 | } |
-
请 注册 或 登录 后发表评论