package com.iailab.module.model.mpk.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.iailab.framework.common.page.PageData; import com.iailab.framework.common.service.impl.BaseServiceImpl; import com.iailab.module.model.mpk.dao.ChartDao; import com.iailab.module.model.mpk.dto.ChartDTO; import com.iailab.module.model.mpk.entity.ChartEntity; import com.iailab.module.model.mpk.entity.ChartParamEntity; import com.iailab.module.model.mpk.service.ChartParamService; import com.iailab.module.model.mpk.service.ChartService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.util.*; /** * @description: * @author: dzd * @date: 2024/11/5 11:21 **/ @Slf4j @Service public class ChartServiceImpl extends BaseServiceImpl implements ChartService { @Autowired private ChartParamService chartParamService; @Override public PageData page(Map params) { IPage page = baseDao.selectPage( getPage(params, "create_time", false), getWrapper(params) ); return getPageData(page, ChartDTO.class); } @Override public void create(ChartEntity entity) { entity.setId(UUID.randomUUID().toString()); entity.setCreateTime(new Date()); baseDao.insert(entity); } @Override public void update(ChartEntity entity) { entity.setUpdateTime(new Date()); baseDao.updateById(entity); } @Override public ChartEntity get(String id) { return baseDao.selectById(id); } @Override public void delete(String id) { baseDao.deleteById(id); } private QueryWrapper getWrapper(Map params) { String chartName = (String) params.get("chartName"); String chartCode = (String) params.get("chartCode"); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.like(StringUtils.isNotBlank(chartName), "chart_name", chartName) .like(StringUtils.isNotBlank(chartCode), "chart_code", chartCode); return wrapper; } @Override public Map getByChartCode(String chartCode) { Map result = new HashMap<>(); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq("chart_code", chartCode); ChartEntity entity = baseDao.selectOne(wrapper); if (entity == null) { return result; } return chartParamService.getByChartId(entity.getId()); } }