|
@@ -0,0 +1,141 @@
|
|
|
+package com.taais.biz.service.impl;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.mybatisflex.core.paginate.Page;
|
|
|
+import com.mybatisflex.core.query.QueryWrapper;
|
|
|
+import com.taais.common.core.utils.MapstructUtils;
|
|
|
+import com.taais.common.core.utils.StringUtils;
|
|
|
+import com.taais.common.orm.core.page.PageQuery;
|
|
|
+import com.taais.common.orm.core.page.TableDataInfo;
|
|
|
+import com.taais.common.orm.core.service.impl.BaseServiceImpl;
|
|
|
+import jakarta.annotation.Resource;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import com.taais.biz.mapper.AlgorithmConfigMapper;
|
|
|
+import com.taais.biz.domain.AlgorithmConfig;
|
|
|
+import com.taais.biz.domain.bo.AlgorithmConfigBo;
|
|
|
+import com.taais.biz.domain.vo.AlgorithmConfigVo;
|
|
|
+import com.taais.biz.service.IAlgorithmConfigService;
|
|
|
+import static com.taais.biz.domain.table.AlgorithmConfigTableDef .ALGORITHM_CONFIG;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 算法配置Service业务层处理
|
|
|
+ *
|
|
|
+ * @author 0
|
|
|
+ * 2024-05-27
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class AlgorithmConfigServiceImpl extends BaseServiceImpl<AlgorithmConfigMapper, AlgorithmConfig> implements IAlgorithmConfigService {
|
|
|
+ @Resource
|
|
|
+ private AlgorithmConfigMapper algorithmConfigMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public QueryWrapper query() {
|
|
|
+ return super.query().from(ALGORITHM_CONFIG);
|
|
|
+ }
|
|
|
+
|
|
|
+ private QueryWrapper buildQueryWrapper(AlgorithmConfigBo algorithmConfigBo) {
|
|
|
+ QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
|
|
|
+ queryWrapper.and(ALGORITHM_CONFIG.SUBSYSTEM.eq
|
|
|
+ (algorithmConfigBo.getSubsystem()));
|
|
|
+ queryWrapper.and(ALGORITHM_CONFIG.ALGORITHM_NAME.like
|
|
|
+ (algorithmConfigBo.getAlgorithmName()));
|
|
|
+ queryWrapper.and(ALGORITHM_CONFIG.ALGORITHM_ADDRESS.like
|
|
|
+ (algorithmConfigBo.getAlgorithmAddress()));
|
|
|
+ queryWrapper.and(ALGORITHM_CONFIG.PARAMETER_CONFIG.eq
|
|
|
+ (algorithmConfigBo.getParameterConfig()));
|
|
|
+ queryWrapper.and(ALGORITHM_CONFIG.CREATED_BY.eq
|
|
|
+ (algorithmConfigBo.getCreatedBy()));
|
|
|
+ queryWrapper.and(ALGORITHM_CONFIG.CREATED_AT.eq
|
|
|
+ (algorithmConfigBo.getCreatedAt()));
|
|
|
+ queryWrapper.and(ALGORITHM_CONFIG.UPDATED_BY.eq
|
|
|
+ (algorithmConfigBo.getUpdatedBy()));
|
|
|
+ queryWrapper.and(ALGORITHM_CONFIG.UPDATED_AT.eq
|
|
|
+ (algorithmConfigBo.getUpdatedAt()));
|
|
|
+ queryWrapper.and(ALGORITHM_CONFIG.REMARKS.eq
|
|
|
+ (algorithmConfigBo.getRemarks()));
|
|
|
+
|
|
|
+ return queryWrapper;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询算法配置
|
|
|
+ *
|
|
|
+ * @param id 算法配置主键
|
|
|
+ * @return 算法配置
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public AlgorithmConfigVo selectById(Long id) {
|
|
|
+ return this.getOneAs(query().where(ALGORITHM_CONFIG.ID.eq(id)), AlgorithmConfigVo.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询算法配置列表
|
|
|
+ *
|
|
|
+ * @param algorithmConfigBo 算法配置Bo
|
|
|
+ * @return 算法配置集合
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<AlgorithmConfigVo> selectList(AlgorithmConfigBo algorithmConfigBo) {
|
|
|
+ QueryWrapper queryWrapper = buildQueryWrapper(algorithmConfigBo);
|
|
|
+ return this.listAs(queryWrapper, AlgorithmConfigVo.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询算法配置列表
|
|
|
+ *
|
|
|
+ * @param algorithmConfigBo 算法配置Bo
|
|
|
+ * @return 分页算法配置集合
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public TableDataInfo<AlgorithmConfigVo> selectPage(AlgorithmConfigBo algorithmConfigBo) {
|
|
|
+ QueryWrapper queryWrapper = buildQueryWrapper(algorithmConfigBo);
|
|
|
+ Page<AlgorithmConfigVo> page = this.pageAs(PageQuery.build(), queryWrapper, AlgorithmConfigVo.class);
|
|
|
+ return TableDataInfo.build(page);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增算法配置
|
|
|
+ *
|
|
|
+ * @param algorithmConfigBo 算法配置Bo
|
|
|
+ * @return 结果:true 操作成功,false 操作失败
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public boolean insert(AlgorithmConfigBo algorithmConfigBo) {
|
|
|
+ AlgorithmConfig algorithmConfig =MapstructUtils.convert(algorithmConfigBo, AlgorithmConfig. class);
|
|
|
+
|
|
|
+ return this.save(algorithmConfig);//使用全局配置的雪花算法主键生成器生成ID值
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改算法配置
|
|
|
+ *
|
|
|
+ * @param algorithmConfigBo 算法配置Bo
|
|
|
+ * @return 结果:true 更新成功,false 更新失败
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public boolean update(AlgorithmConfigBo algorithmConfigBo) {
|
|
|
+ AlgorithmConfig algorithmConfig =MapstructUtils.convert(algorithmConfigBo, AlgorithmConfig. class);
|
|
|
+ if (ObjectUtil.isNotNull(algorithmConfig) && ObjectUtil.isNotNull(algorithmConfig.getId())){
|
|
|
+ boolean updated = this.updateById(algorithmConfig);
|
|
|
+ return updated;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除算法配置
|
|
|
+ *
|
|
|
+ * @param ids 需要删除的算法配置主键集合
|
|
|
+ * @return 结果:true 删除成功,false 删除失败
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public boolean deleteByIds(Long[] ids) {
|
|
|
+ return this.removeByIds(Arrays.asList(ids));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|