作者 陈志颖

fix:修改新增公司增加栏目设置

... ... @@ -102,6 +102,7 @@ func (service SyncCompanyService) addCompany(data CompanytData) error {
var (
companyRespository domain.CompanyRepository
userRespository domain.UsersRepository
columnSettingRepository domain.ColumnSettingRepository
)
if companyRespository, err = factory.CreateCompanyRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -113,6 +114,11 @@ func (service SyncCompanyService) addCompany(data CompanytData) error {
}); err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
if columnSettingRepository, err = factory.CreateColumnSettingRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
applets := []domain.CompanyApplets{}
for _, v := range data.Company.Applets {
app := domain.CompanyApplets{
... ... @@ -164,6 +170,21 @@ func (service SyncCompanyService) addCompany(data CompanytData) error {
if err != nil {
return fmt.Errorf("添加用户数据失败,%s", err)
}
// 初始化栏目设置
newColumnSetting := &domain.ColumnSetting{
Description: "订单管理栏目设置",
UserName: data.User.Name,
CompanyId: int(data.User.CompanyId),
Uid: data.User.Id,
Key: constant.ORDER_BASE, // 订单栏目模块名称
Value: domain.DefaultColumns, // 栏目值数组,创建用户时使用默认栏目设置
InvalidValue: domain.DefaultInvalidColumns, // 初始化无效栏目数组
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
}
if _, err = columnSettingRepository.Save(newColumnSetting); err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
err = transactionContext.CommitTransaction()
return nil
}
... ... @@ -197,12 +218,6 @@ func (service SyncCompanyService) updateCompany(data CompanytData) error {
}); err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
var columnSettingRepository domain.ColumnSettingRepository
if columnSettingRepository, err = factory.CreateColumnSettingRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
oldCompany, err = companyRespository.FindOne(domain.CompanyFindOneOptions{
Id: data.Company.Id,
})
... ... @@ -284,21 +299,6 @@ func (service SyncCompanyService) updateCompany(data CompanytData) error {
if err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
// 初始化栏目设置
newColumnSetting := &domain.ColumnSetting{
Description: "订单管理栏目设置",
UserName: data.User.Name,
CompanyId: int(data.User.CompanyId),
Uid: data.User.Id,
Key: constant.ORDER_BASE, // 订单栏目模块名称
Value: domain.DefaultColumns, // 栏目值数组,创建用户时使用默认栏目设置
InvalidValue: domain.DefaultInvalidColumns, // 初始化无效栏目数组
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
}
if _, err = columnSettingRepository.Save(newColumnSetting); err != nil {
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
err = transactionContext.CommitTransaction()
return nil
}
... ...