...
|
...
|
@@ -111,6 +111,15 @@ func (service SyncCompanyService) addCompany(data CompanytData) error { |
|
|
}); err != nil {
|
|
|
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
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 := domain.Company{
|
|
|
Id: data.Company.Id,
|
|
|
Name: data.Company.Name,
|
...
|
...
|
@@ -121,17 +130,9 @@ func (service SyncCompanyService) addCompany(data CompanytData) error { |
|
|
//Status: data.Company.Status,
|
|
|
Enable: domain.CompanyEnableYes, //默认初始化值
|
|
|
Abbreviation: data.Company.Abbreviation,
|
|
|
Applets: applets,
|
|
|
}
|
|
|
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)
|
...
|
...
|
@@ -203,13 +204,22 @@ func (service SyncCompanyService) updateCompany(data CompanytData) error { |
|
|
newUser, err = userRespository.FindOne(domain.UsersFindOneQuery{
|
|
|
Id: data.User.Id,
|
|
|
})
|
|
|
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)
|
|
|
}
|
|
|
oldCompany.Update(map[string]interface{}{
|
|
|
"Name": data.Company.Name,
|
|
|
"Logo": data.Company.Logo,
|
|
|
"Remarks": data.Company.Remarks,
|
|
|
"AdminCompanyId": data.Company.AdminCompanyId,
|
|
|
"Abbreviation": data.Company.Abbreviation,
|
|
|
"Applets": data.Company.Applets,
|
|
|
"Applets": applets,
|
|
|
})
|
|
|
for i := range oldCompanyAdmins {
|
|
|
oldCompanyAdmins[i].Update(map[string]interface{}{
|
...
|
...
|
|