作者 唐旭辉

错误

@@ -129,3 +129,38 @@ func (service CompanyService) GetCompanyData(companyId int64) (*domain.Company, @@ -129,3 +129,38 @@ func (service CompanyService) GetCompanyData(companyId int64) (*domain.Company,
129 err = transactionContext.CommitTransaction() 129 err = transactionContext.CommitTransaction()
130 return &companyData, nil 130 return &companyData, nil
131 } 131 }
  132 +
  133 +func (service CompanyService) UpdateCompanyPhone(companyId int64, phone string) error {
  134 + var (
  135 + transactionContext, _ = factory.CreateTransactionContext(nil)
  136 + err error
  137 + )
  138 + if err = transactionContext.StartTransaction(); err != nil {
  139 + return err
  140 + }
  141 + defer func() {
  142 + transactionContext.RollbackTransaction()
  143 + }()
  144 + var (
  145 + companyRespository domain.CompanyRepository
  146 + companyData domain.Company
  147 + )
  148 + if companyRespository, err = factory.CreateCompanyRepository(map[string]interface{}{
  149 + "transactionContext": transactionContext,
  150 + }); err != nil {
  151 + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
  152 + }
  153 + companyData, err = companyRespository.FindOne(domain.CompanyFindOneOptions{
  154 + Id: companyId,
  155 + })
  156 + if err != nil {
  157 + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("获取公司(id=%d)的数据失败:%s", companyId, err.Error()))
  158 + }
  159 + companyData.Phone = phone
  160 + err = companyRespository.Edit(&companyData)
  161 + if err != nil {
  162 + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("更新公司(id=%d)的数据失败:%s", companyId, err.Error()))
  163 + }
  164 + err = transactionContext.CommitTransaction()
  165 + return nil
  166 +}
@@ -58,7 +58,7 @@ func (service UsersService) UserLoginBySecretKey(cmd command.LoginBySecretKeyCom @@ -58,7 +58,7 @@ func (service UsersService) UserLoginBySecretKey(cmd command.LoginBySecretKeyCom
58 } 58 }
59 //检索本系统的公司数据判断公司权限 59 //检索本系统的公司数据判断公司权限
60 companyData, err = companyRespository.FindOne(domain.CompanyFindOneOptions{ 60 companyData, err = companyRespository.FindOne(domain.CompanyFindOneOptions{
61 - Id: loginResp.Data.Muid, 61 + AdminCompanyId: loginResp.Data.CompanyId,
62 }) 62 })
63 if err != nil { 63 if err != nil {
64 e := fmt.Sprintf("获取公司(id=%d)数据失败:%s", loginResp.Data.Muid, err.Error()) 64 e := fmt.Sprintf("获取公司(id=%d)数据失败:%s", loginResp.Data.Muid, err.Error())
@@ -69,7 +69,7 @@ func (service UsersService) UserLoginBySecretKey(cmd command.LoginBySecretKeyCom @@ -69,7 +69,7 @@ func (service UsersService) UserLoginBySecretKey(cmd command.LoginBySecretKeyCom
69 } 69 }
70 //检索本系统的用户数据 70 //检索本系统的用户数据
71 usersData, err = userRespository.FindOne(domain.UsersFindOneQuery{ 71 usersData, err = userRespository.FindOne(domain.UsersFindOneQuery{
72 - OpenId: loginResp.Data.Id, 72 + Id: loginResp.Data.Muid,
73 CompanyId: companyData.Id, 73 CompanyId: companyData.Id,
74 }) 74 })
75 if err != nil { 75 if err != nil {
@@ -80,7 +80,8 @@ func (c *Company) Update(m map[string]interface{}) error { @@ -80,7 +80,8 @@ func (c *Company) Update(m map[string]interface{}) error {
80 } 80 }
81 81
82 type CompanyFindOneOptions struct { 82 type CompanyFindOneOptions struct {
83 - Id int64 83 + Id int64
  84 + AdminCompanyId int64
84 } 85 }
85 86
86 type CompanyFindOptions struct { 87 type CompanyFindOptions struct {