Commit 16c6bb0c authored by 赵啸非's avatar 赵啸非

动态字段调整排序逻辑

parent c4979560
package com.mortals.xhx.module.app.service.impl;
import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.module.app.model.*;
import com.mortals.xhx.module.app.service.AppDatasetService;
import com.mortals.xhx.module.app.service.AppInfoFieldService;
import com.mortals.xhx.module.app.service.AppService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.xhx.module.app.dao.AppInfoTempleteFieldDao;
import com.mortals.xhx.module.app.model.AppInfoTempleteFieldEntity;
import com.mortals.xhx.module.app.service.AppInfoTempleteFieldService;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.List;
/**
* AppInfoTempleteFieldService
* 自助终端应用模板信息字段 service实现
*
* @author zxfei
* @date 2022-11-28
*/
* AppInfoTempleteFieldService
* 自助终端应用模板信息字段 service实现
*
* @author zxfei
* @date 2022-11-28
*/
@Service("appInfoTempleteFieldService")
public class AppInfoTempleteFieldServiceImpl extends AbstractCRUDServiceImpl<AppInfoTempleteFieldDao, AppInfoTempleteFieldEntity, Long> implements AppInfoTempleteFieldService {
@Autowired
private AppService appService;
@Autowired
private AppDatasetService appDatasetService;
@Autowired
private AppInfoFieldService appInfoFieldService;
/**
* @param entity
* @param context
* @throws AppException
*/
@Override
protected void saveAfter(AppInfoTempleteFieldEntity entity, Context context) throws AppException {
//同步添加已有模板数据
AppDatasetQuery appDatasetQuery = new AppDatasetQuery();
appDatasetQuery.setAppId(entity.getAppId());
List<AppDatasetEntity> appDatasetEntities = appDatasetService.find(appDatasetQuery, context);
// 判断该数据集 是否已经存在 没存在 再添加
ArrayList<AppInfoFieldEntity> fieldSaveList = new ArrayList<>();
for (AppDatasetEntity appDatasetEntity : appDatasetEntities) {
AppInfoFieldQuery appInfoFieldQuery = new AppInfoFieldQuery();
appInfoFieldQuery.setDatasetId(appDatasetEntity.getId());
appInfoFieldQuery.setFieldCode(entity.getFieldCode());
appInfoFieldQuery.setFieldType(entity.getFieldType());
AppInfoFieldEntity appInfoFieldEntity = appInfoFieldService.selectOne(appInfoFieldQuery, context);
if (ObjectUtils.isEmpty(appInfoFieldEntity)) {
AppInfoFieldEntity fieldEntity = new AppInfoFieldEntity();
fieldEntity.initAttrValue();
BeanUtils.copyProperties(entity, fieldEntity, BeanUtil.getNullPropertyNames(entity));
fieldEntity.setDatasetId(appDatasetEntity.getId());
fieldEntity.setId(null);
fieldSaveList.add(fieldEntity);
}
if (!ObjectUtils.isEmpty(fieldSaveList)) {
appInfoFieldService.save(fieldSaveList, context);
}
}
super.saveAfter(entity, context);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment