...
|
...
|
@@ -13,13 +13,13 @@ import ( |
|
|
|
|
|
type RewardStandardService struct{}
|
|
|
|
|
|
func NewProductService(options map[string]interface{}) *RewardStandardService {
|
|
|
func NewRewardStandardService(options map[string]interface{}) *RewardStandardService {
|
|
|
newService := &RewardStandardService{}
|
|
|
return newService
|
|
|
}
|
|
|
|
|
|
//SaveRewardStandard 保存奖惩标准数据
|
|
|
func (srv RewardStandardService) SaveRewardStandard(operateInfo domain.OperateInfo, param *command.SaveRewardStandardCommand) (*command.SaveRewardStandardCommand, error) {
|
|
|
func (srv RewardStandardService) SaveRewardStandard(operateInfo *domain.OperateInfo, param *command.SaveRewardStandardCommand) (*command.SaveRewardStandardCommand, error) {
|
|
|
if err := param.ValidateCommand(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
@@ -118,7 +118,7 @@ func (srv RewardStandardService) SaveRewardStandard(operateInfo domain.OperateIn |
|
|
}
|
|
|
|
|
|
//GetRewardStandard 根据id获取奖惩标准数据
|
|
|
func (srv RewardStandardService) GetRewardStandard(param *query.GetRewardStandard) (*dto.RewardStandardInfo, error) {
|
|
|
func (srv RewardStandardService) GetRewardStandard(operateInfo *domain.OperateInfo, param *query.GetRewardStandard) (*dto.RewardStandardInfo, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
@@ -142,6 +142,9 @@ func (srv RewardStandardService) GetRewardStandard(param *query.GetRewardStandar |
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if operateInfo.CompanyId != rewardStandardData.CompanyId {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "指标数据不存在")
|
|
|
}
|
|
|
|
|
|
result := dto.RewardStandardInfo{
|
|
|
Id: rewardStandardData.Id,
|
...
|
...
|
@@ -162,7 +165,7 @@ func (srv RewardStandardService) GetRewardStandard(param *query.GetRewardStandar |
|
|
}
|
|
|
|
|
|
//DeleteRewardStandard 根据id删除奖惩标准
|
|
|
func (srv RewardStandardService) DeleteRewardStandard(param *query.GetRewardStandard) (*domain.RewardStandard, error) {
|
|
|
func (srv RewardStandardService) DeleteRewardStandard(operateInfo *domain.OperateInfo, param *query.GetRewardStandard) (*domain.RewardStandard, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
@@ -181,10 +184,84 @@ func (srv RewardStandardService) DeleteRewardStandard(param *query.GetRewardStan |
|
|
"id": param.Id,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "指标数据不存在"+err.Error())
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "指标数据不存在:"+err.Error())
|
|
|
}
|
|
|
|
|
|
if operateInfo.CompanyId != rewardStandardData.CompanyId {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "指标数据不存在")
|
|
|
}
|
|
|
_, err = rewardStandardRepo.Remove(rewardStandardData)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "操作指标数据失败"+err.Error())
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return rewardStandardData, nil
|
|
|
}
|
|
|
|
|
|
func (srv RewardStandardService) ListRewardStandard(param *query.ListRewardStandard) (int64, []dto.RewardStandardList, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
rewardStandardRepo, _ := factory.CreateRewardStandardRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
|
|
|
condition := map[string]interface{}{
|
|
|
"limit": 20,
|
|
|
"offset": 0,
|
|
|
"companyId": param.CompanyId,
|
|
|
}
|
|
|
if param.PageSize > 0 {
|
|
|
condition["limit"] = param.PageSize
|
|
|
}
|
|
|
offset := param.PageSize * (param.PageSize - 1)
|
|
|
if offset > 0 {
|
|
|
condition["offset"] = offset
|
|
|
}
|
|
|
if len(param.WorkshopName) > 0 {
|
|
|
condition["workshopName"] = param.WorkshopName
|
|
|
}
|
|
|
if len(param.SectionName) > 0 {
|
|
|
condition["sectionName"] = param.SectionName
|
|
|
}
|
|
|
if len(param.LineName) > 0 {
|
|
|
condition["lineName"] = param.LineName
|
|
|
}
|
|
|
cnt, rewardStandardList, err := rewardStandardRepo.Find(condition)
|
|
|
if err != nil {
|
|
|
return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
var listResult []dto.RewardStandardList
|
|
|
var temp dto.RewardStandardList
|
|
|
for _, v := range rewardStandardList {
|
|
|
temp = dto.RewardStandardList{
|
|
|
Id: v.Id,
|
|
|
WorkshopId: v.Workshop.WorkshopId,
|
|
|
WorkshopName: v.Workshop.WorkshopName,
|
|
|
LineId: v.ProductLine.LineId,
|
|
|
LineName: v.ProductLine.LineName,
|
|
|
SectionId: v.ProductSection.SectionId,
|
|
|
SectionName: v.ProductSection.SectionName,
|
|
|
Remark: v.Remark,
|
|
|
TargetType: v.TargetType,
|
|
|
TargetTypeName: v.TargetTypeName(),
|
|
|
TargeReward: v.ShowTargeReward(),
|
|
|
TargeFault: v.ShowTargeFault(),
|
|
|
}
|
|
|
listResult = append(listResult, temp)
|
|
|
}
|
|
|
return cnt, listResult, nil
|
|
|
} |
...
|
...
|
|