...
|
...
|
@@ -16,6 +16,12 @@ type SyncCompanyService struct{} |
|
|
|
|
|
var _ SyncAction = (*SyncCompanyService)(nil)
|
|
|
|
|
|
type CompanyBaseApplet struct {
|
|
|
Name string `json:"name"`
|
|
|
URL string `json:"url"`
|
|
|
Id string `json:"id"`
|
|
|
}
|
|
|
|
|
|
//企业平台的公司基础数据
|
|
|
type CompanyBase struct {
|
|
|
Id int64 `json:"id"` //id
|
...
|
...
|
@@ -23,7 +29,8 @@ type CompanyBase struct { |
|
|
AdminCompanyId int `json:"admin_company_id"` //总后台的公司id
|
|
|
Logo string `json:"logo"` //公司图标
|
|
|
Remarks string `json:"remarks"` //备注
|
|
|
Abbreviation string `json:"abbreviation"`
|
|
|
Abbreviation string `json:"abbreviation"` //公司简称
|
|
|
Applets []CompanyBaseApplet `json:"applets"` //公司对接的小程序
|
|
|
}
|
|
|
|
|
|
// CompanytData 企业平台发送过来的公司数据数据
|
...
|
...
|
@@ -115,6 +122,16 @@ func (service SyncCompanyService) addCompany(data CompanytData) error { |
|
|
Enable: domain.CompanyEnableYes, //默认初始化值
|
|
|
Abbreviation: data.Company.Abbreviation,
|
|
|
}
|
|
|
applets := []domain.CompanyApplets{}
|
|
|
for _, v := range data.Company.Applets {
|
|
|
app := domain.CompanyApplets{
|
|
|
Name: v.Name,
|
|
|
URL: v.URL,
|
|
|
Id: v.Id,
|
|
|
}
|
|
|
applets = append(applets, app)
|
|
|
}
|
|
|
comany.Applets = applets
|
|
|
err = companyRespository.Add(&comany)
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("添加公司数据失败,%s", err)
|
...
|
...
|
@@ -192,6 +209,7 @@ func (service SyncCompanyService) updateCompany(data CompanytData) error { |
|
|
"Remarks": data.Company.Remarks,
|
|
|
"AdminCompanyId": data.Company.AdminCompanyId,
|
|
|
"Abbreviation": data.Company.Abbreviation,
|
|
|
"Applets": data.Company.Applets,
|
|
|
})
|
|
|
for i := range oldCompanyAdmins {
|
|
|
oldCompanyAdmins[i].Update(map[string]interface{}{
|
...
|
...
|
|