作者 tangxvhui

同步数据 编辑公司

@@ -17,6 +17,7 @@ type Company struct { @@ -17,6 +17,7 @@ type Company struct {
17 Logo string `orm:"column(logo);size(255)"` 17 Logo string `orm:"column(logo);size(255)"`
18 Enable int8 `orm:"column(enable)"` 18 Enable int8 `orm:"column(enable)"`
19 UserCenterId int64 `orm:"column(user_center_id)"` 19 UserCenterId int64 `orm:"column(user_center_id)"`
  20 + Remark string `orm:"column(remark)"`
20 } 21 }
21 22
22 func (t *Company) TableName() string { 23 func (t *Company) TableName() string {
@@ -151,9 +151,9 @@ func init() { @@ -151,9 +151,9 @@ func init() {
151 ) 151 )
152 nsUcenter := beego.NewNamespace("/ucenter", 152 nsUcenter := beego.NewNamespace("/ucenter",
153 beego.NSBefore(middleware.LogRequestData), 153 beego.NSBefore(middleware.LogRequestData),
154 - beego.NSRouter("/company", &controllers.CompanyController{}, "post:InitCompany"), 154 + //beego.NSRouter("/company", &controllers.CompanyController{}, "post:InitCompany"),(废弃)
155 beego.NSRouter("/company/info", &controllers.CompanyController{}, "post:GetCompanyForUCenter"), 155 beego.NSRouter("/company/info", &controllers.CompanyController{}, "post:GetCompanyForUCenter"),
156 - beego.NSRouter("/company/edit", &controllers.CompanyController{}, "post:EditCompanyForUCenter"), 156 + //beego.NSRouter("/company/edit", &controllers.CompanyController{}, "post:EditCompanyForUCenter"),(废弃)
157 beego.NSRouter("/user/revoke", &controllers.CompanyController{}, "post:UserRevoke"), 157 beego.NSRouter("/user/revoke", &controllers.CompanyController{}, "post:UserRevoke"),
158 beego.NSRouter("/user/changePhone", &controllers.CompanyController{}, "post:UserChangePhone"), 158 beego.NSRouter("/user/changePhone", &controllers.CompanyController{}, "post:UserChangePhone"),
159 beego.NSRouter("/company/allow_forbid", &controllers.CompanyController{}, "post:AllowForidCompanyForUCenter"), 159 beego.NSRouter("/company/allow_forbid", &controllers.CompanyController{}, "post:AllowForidCompanyForUCenter"),
@@ -18,6 +18,7 @@ type CompanyBase struct { @@ -18,6 +18,7 @@ type CompanyBase struct {
18 Name string `json:"name"` //公司名称名称 18 Name string `json:"name"` //公司名称名称
19 AdminCompanyId int64 `json:"admin_company_id"` 19 AdminCompanyId int64 `json:"admin_company_id"`
20 Logo string `json:"logo"` 20 Logo string `json:"logo"`
  21 + Remarks string `json:"remarks"`
21 } 22 }
22 23
23 // ModuleCompanytData 主管理平台发送过来的数据 24 // ModuleCompanytData 主管理平台发送过来的数据
@@ -46,15 +47,15 @@ func (m ModuleCompanytData) DoAction(code string, jsondata []byte) error { @@ -46,15 +47,15 @@ func (m ModuleCompanytData) DoAction(code string, jsondata []byte) error {
46 } 47 }
47 return AddCompanyData(data) 48 return AddCompanyData(data)
48 case "edit": 49 case "edit":
49 - // var (  
50 - // data ModuleCompanytData  
51 - // err error  
52 - // )  
53 - // err = json.Unmarshal(jsondata, &data)  
54 - // if err != nil {  
55 - // return fmt.Errorf("数据解析失败:%s", err)  
56 - // }  
57 - // return UpdateCompanyData(data) 50 + var (
  51 + data ModuleCompanytData
  52 + err error
  53 + )
  54 + err = json.Unmarshal(jsondata, &data)
  55 + if err != nil {
  56 + return fmt.Errorf("数据解析失败:%s", err)
  57 + }
  58 + return UpdateCompanyData(data)
58 return nil 59 return nil
59 case "setCompanyCharge": 60 case "setCompanyCharge":
60 var ( 61 var (
@@ -112,22 +113,24 @@ func SetCompanyCharge(data CompanyCharge) error { @@ -112,22 +113,24 @@ func SetCompanyCharge(data CompanyCharge) error {
112 } 113 }
113 114
114 func UpdateCompanyData(data ModuleCompanytData) error { 115 func UpdateCompanyData(data ModuleCompanytData) error {
115 - // var (  
116 - // companyData *models.Company  
117 - // err error  
118 - // )  
119 - // companyData, err = models.GetCompanyByUCenter(data.Id)  
120 - // if err != nil {  
121 - // log.Error("获取企业数据失败,user_center_id:%d ,err:%s", data.Id, err)  
122 - // return errors.New("获取企业数据失败")  
123 - // }  
124 - // companyData.Logo = data.Logo  
125 - // companyData.Name = data.Name  
126 - // err = models.UpdateCompanyById(companyData, []string{"Logo", "Name"})  
127 - // if err != nil {  
128 - // log.Error("更新公司数据失败:%s", err)  
129 - // return errors.New("更新公司数据失败")  
130 - // } 116 + var (
  117 + companyData *models.Company
  118 + err error
  119 + )
  120 + companyBaseData := data.Company
  121 + companyData, err = models.GetCompanyByUCenter(companyBaseData.AdminCompanyId)
  122 + if err != nil {
  123 + log.Error("获取企业数据失败,user_center_id:%d ,err:%s", data.Id, err)
  124 + return errors.New("获取企业数据失败")
  125 + }
  126 + companyData.Logo = companyBaseData.Logo
  127 + companyData.Name = companyBaseData.Name
  128 + companyData.Remark = companyBaseData.Remarks
  129 + err = models.UpdateCompanyById(companyData, []string{"Logo", "Name"})
  130 + if err != nil {
  131 + log.Error("更新公司数据失败:%s", err)
  132 + return errors.New("更新公司数据失败")
  133 + }
131 return nil 134 return nil
132 } 135 }
133 136