作者 唐旭辉

跨越调试提交

... ... @@ -391,7 +391,7 @@ func (c *CompanyController) InitCompany() {
if ok := param.IsEnable(); ok {
err = servecompany.InitCompanyInfo(param)
} else if ok := param.IsForbid(); ok {
err = servecompany.ForbidCompany(param.CompanyId)
} else {
err = protocol.NewErrWithMessage("1")
}
... ... @@ -400,6 +400,25 @@ func (c *CompanyController) InitCompany() {
return
}
//@router /ucenter/company/info [post]
func (c *CompanyController) GetCompanyForUCenter() {
var msg *protocol.ResponseMessage
defer func() {
c.ResposeJson(msg)
}()
type Paremeter struct {
Companyid int64 `json:"company_id"`
}
var param protocol.CenterCompanyInfo
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &param); err != nil {
log.Error("json 解析失败 err:%s", err)
msg = protocol.BadRequestParam("1")
return
}
msg = protocol.NewReturnResponse(nil, nil)
return
}
//DepartmentUser 获取部门下成员
//@router /department/user [post]
func (c *CompanyController) DepartmentUser() {
... ...
... ... @@ -82,13 +82,14 @@ var AllowOption = func(ctx *context.Context) {
}
f := cors.Allow(&cors.Options{
AllowMethods: []string{"POST", "GET", "OPTIONS", "PUT", "DELETE"}, //允许的请求类型
AllowHeaders: []string{"Origin", "Authorization", "Access-Control-Allow-Origin",
"x-mmm-cid", "x-mmm-uid", "x-mmm-accesstoken", "x-mmm-refreshtoken"}, //允许的头部信息
ExposeHeaders: []string{"Content-Length", "Content-Type", "Access-Control-Allow-Origin"}, //允许暴露的头信息
AllowCredentials: false, //不允许共享AuthTuffic证书
AllowAllOrigins: true, //允许的请求来源
AllowHeaders: []string{"Origin", "Accept", "Content-Type", "Authorization",
"x-mmm-cid", "x-mmm-uid", "x-mmm-accesstoken", "x-mmm-refreshtoken", "x-requested-with"}, //允许的头部信息
ExposeHeaders: []string{"Content-Length"}, //允许暴露的头信息
AllowCredentials: false, //不允许共享AuthTuffic证书
AllowAllOrigins: true, //允许的请求来源
})
f(ctx)
ctx.Output.SetStatus(204)
ctx.Output.Body([]byte("{}"))
return
}
... ...
... ... @@ -84,15 +84,12 @@ func GetCompanyById(id int64) (v *Company, err error) {
// the record to be updated doesn't exist
func UpdateCompanyById(m *Company, col []string) (err error) {
o := orm.NewOrm()
v := Company{Id: m.Id}
// ascertain id exists in the database
if err = o.Read(&v); err == nil {
var num int64
m.UpdateAt = time.Now()
if num, err = o.Update(m, col...); err == nil {
fmt.Println("Number of records updated in database:", num)
}
var num int64
m.UpdateAt = time.Now()
if num, err = o.Update(m, col...); err == nil {
fmt.Println("Number of records updated in database:", num)
}
return
}
... ...
... ... @@ -121,13 +121,14 @@ type ResponseCompanyBase struct {
Logo string `json:"logo"`
}
//CenterCompanyInfo 统一用户中心调用的公司数据
type CenterCompanyInfo struct {
CompanyId int64 `json:"company_id"`
CompanyName string `json:"company_name"`
AdminId int64 `json:"admin_id"`
CompanyId int64 `json:"company_id"` //总后台的公司id
CompanyName string `json:"company_name"` //
AdminId int64 `json:"admin_id"` //统一用户中心的用户id
AdminAccount string `json:"admin_account"`
AdminName string `json:"admin_name"`
Status int8 `json:"status"`
Status int8 `json:"status"` //公司的状态 【1:启用】【2:禁用】
}
func (c CenterCompanyInfo) IsEnable() bool {
... ... @@ -143,3 +144,5 @@ func (c CenterCompanyInfo) IsForbid() bool {
}
return false
}
// type ResponseCenterCompany
... ...
... ... @@ -5,6 +5,7 @@ import (
"oppmg/common/log"
"oppmg/models"
"oppmg/protocol"
"time"
"github.com/astaxie/beego/orm"
)
... ... @@ -440,13 +441,26 @@ func CompanyBaseInfo(companyid int64) (*protocol.ResponseCompanyBase, error) {
}
func ForbidCompany(ucenterCompany int64) error {
// var (
// err error
// companyData *models.Company
// )
// companyData, err = models.GetCompanyByUCenter(ucenterCompany)
// if err == orm.ErrNoRows {
// // log.Info()
// }
var (
err error
companyData *models.Company
)
companyData, err = models.GetCompanyByUCenter(ucenterCompany)
if err == orm.ErrNoRows {
log.Warn("未查找到公司数据")
return nil
}
if err != nil && err != orm.ErrNoRows {
log.Error(err.Error())
return protocol.NewErrWithMessage("1")
}
companyData.Enable = models.COMPANY_ENABLE_NO
companyData.UpdateAt = time.Now()
err = models.UpdateCompanyById(companyData, []string{"Enable", "UpdateAt"})
if err != nil {
log.Error("更新公司数据失败:%s", err)
return protocol.NewErrWithMessage("1")
}
return nil
}
... ...