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.dao.ChartParamDao;
|
import com.iailab.module.model.mpk.dto.ChartDTO;
|
import com.iailab.module.model.mpk.dto.ChartParamDTO;
|
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.stereotype.Service;
|
|
import java.util.Date;
|
import java.util.Map;
|
import java.util.UUID;
|
|
/**
|
* @description:
|
* @author: dzd
|
* @date: 2024/11/5 11:21
|
**/
|
@Slf4j
|
@Service
|
public class ChartServiceImpl extends BaseServiceImpl<ChartDao, ChartEntity> implements ChartService {
|
|
@Override
|
public PageData<ChartDTO> page(Map<String, Object> params) {
|
IPage<ChartEntity> 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<ChartEntity> getWrapper(Map<String, Object> params) {
|
String chartName = (String) params.get("chartName");
|
String chartCode = (String) params.get("chartCode");
|
|
QueryWrapper<ChartEntity> wrapper = new QueryWrapper<>();
|
wrapper.like(StringUtils.isNotBlank(chartName), "chart_name", chartName)
|
.like(StringUtils.isNotBlank(chartCode), "chart_code", chartCode);
|
return wrapper;
|
}
|
}
|