正在显示
1 个修改的文件
包含
21 行增加
和
11 行删除
@@ -111,6 +111,15 @@ func (service SyncCompanyService) addCompany(data CompanytData) error { | @@ -111,6 +111,15 @@ func (service SyncCompanyService) addCompany(data CompanytData) error { | ||
111 | }); err != nil { | 111 | }); err != nil { |
112 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | 112 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) |
113 | } | 113 | } |
114 | + applets := []domain.CompanyApplets{} | ||
115 | + for _, v := range data.Company.Applets { | ||
116 | + app := domain.CompanyApplets{ | ||
117 | + Name: v.Name, | ||
118 | + URL: v.URL, | ||
119 | + Id: v.Id, | ||
120 | + } | ||
121 | + applets = append(applets, app) | ||
122 | + } | ||
114 | comany := domain.Company{ | 123 | comany := domain.Company{ |
115 | Id: data.Company.Id, | 124 | Id: data.Company.Id, |
116 | Name: data.Company.Name, | 125 | Name: data.Company.Name, |
@@ -121,17 +130,9 @@ func (service SyncCompanyService) addCompany(data CompanytData) error { | @@ -121,17 +130,9 @@ func (service SyncCompanyService) addCompany(data CompanytData) error { | ||
121 | //Status: data.Company.Status, | 130 | //Status: data.Company.Status, |
122 | Enable: domain.CompanyEnableYes, //默认初始化值 | 131 | Enable: domain.CompanyEnableYes, //默认初始化值 |
123 | Abbreviation: data.Company.Abbreviation, | 132 | Abbreviation: data.Company.Abbreviation, |
133 | + Applets: applets, | ||
124 | } | 134 | } |
125 | - applets := []domain.CompanyApplets{} | ||
126 | - for _, v := range data.Company.Applets { | ||
127 | - app := domain.CompanyApplets{ | ||
128 | - Name: v.Name, | ||
129 | - URL: v.URL, | ||
130 | - Id: v.Id, | ||
131 | - } | ||
132 | - applets = append(applets, app) | ||
133 | - } | ||
134 | - comany.Applets = applets | 135 | + |
135 | err = companyRespository.Add(&comany) | 136 | err = companyRespository.Add(&comany) |
136 | if err != nil { | 137 | if err != nil { |
137 | return fmt.Errorf("添加公司数据失败,%s", err) | 138 | return fmt.Errorf("添加公司数据失败,%s", err) |
@@ -203,13 +204,22 @@ func (service SyncCompanyService) updateCompany(data CompanytData) error { | @@ -203,13 +204,22 @@ func (service SyncCompanyService) updateCompany(data CompanytData) error { | ||
203 | newUser, err = userRespository.FindOne(domain.UsersFindOneQuery{ | 204 | newUser, err = userRespository.FindOne(domain.UsersFindOneQuery{ |
204 | Id: data.User.Id, | 205 | Id: data.User.Id, |
205 | }) | 206 | }) |
207 | + applets := []domain.CompanyApplets{} | ||
208 | + for _, v := range data.Company.Applets { | ||
209 | + app := domain.CompanyApplets{ | ||
210 | + Name: v.Name, | ||
211 | + URL: v.URL, | ||
212 | + Id: v.Id, | ||
213 | + } | ||
214 | + applets = append(applets, app) | ||
215 | + } | ||
206 | oldCompany.Update(map[string]interface{}{ | 216 | oldCompany.Update(map[string]interface{}{ |
207 | "Name": data.Company.Name, | 217 | "Name": data.Company.Name, |
208 | "Logo": data.Company.Logo, | 218 | "Logo": data.Company.Logo, |
209 | "Remarks": data.Company.Remarks, | 219 | "Remarks": data.Company.Remarks, |
210 | "AdminCompanyId": data.Company.AdminCompanyId, | 220 | "AdminCompanyId": data.Company.AdminCompanyId, |
211 | "Abbreviation": data.Company.Abbreviation, | 221 | "Abbreviation": data.Company.Abbreviation, |
212 | - "Applets": data.Company.Applets, | 222 | + "Applets": applets, |
213 | }) | 223 | }) |
214 | for i := range oldCompanyAdmins { | 224 | for i := range oldCompanyAdmins { |
215 | oldCompanyAdmins[i].Update(map[string]interface{}{ | 225 | oldCompanyAdmins[i].Update(map[string]interface{}{ |
-
请 注册 或 登录 后发表评论