|
...
|
...
|
@@ -129,3 +129,38 @@ func (service CompanyService) GetCompanyData(companyId int64) (*domain.Company, |
|
|
|
err = transactionContext.CommitTransaction()
|
|
|
|
return &companyData, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (service CompanyService) UpdateCompanyPhone(companyId int64, phone string) error {
|
|
|
|
var (
|
|
|
|
transactionContext, _ = factory.CreateTransactionContext(nil)
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
if err = transactionContext.StartTransaction(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
transactionContext.RollbackTransaction()
|
|
|
|
}()
|
|
|
|
var (
|
|
|
|
companyRespository domain.CompanyRepository
|
|
|
|
companyData domain.Company
|
|
|
|
)
|
|
|
|
if companyRespository, err = factory.CreateCompanyRepository(map[string]interface{}{
|
|
|
|
"transactionContext": transactionContext,
|
|
|
|
}); err != nil {
|
|
|
|
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
}
|
|
|
|
companyData, err = companyRespository.FindOne(domain.CompanyFindOneOptions{
|
|
|
|
Id: companyId,
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("获取公司(id=%d)的数据失败:%s", companyId, err.Error()))
|
|
|
|
}
|
|
|
|
companyData.Phone = phone
|
|
|
|
err = companyRespository.Edit(&companyData)
|
|
|
|
if err != nil {
|
|
|
|
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("更新公司(id=%d)的数据失败:%s", companyId, err.Error()))
|
|
|
|
}
|
|
|
|
err = transactionContext.CommitTransaction()
|
|
|
|
return nil
|
|
|
|
} |
...
|
...
|
|