package com.iailab.module.mcs.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.framework.common.util.object.ConvertUtils;
|
import com.iailab.module.mcs.dao.StModelRequestLogDao;
|
import com.iailab.module.mcs.dto.StModelRequestLogDTO;
|
import com.iailab.module.mcs.entity.StModelRequestLogEntity;
|
import com.iailab.module.mcs.service.StModelRequestLogService;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.stereotype.Service;
|
|
import java.util.Map;
|
import java.util.UUID;
|
|
/**
|
* @author PanZhibao
|
* @Description
|
* @createTime 2024年05月22日
|
*/
|
@Service
|
public class StModelRequestLogServiceImpl extends BaseServiceImpl<StModelRequestLogDao, StModelRequestLogEntity> implements StModelRequestLogService {
|
|
@Override
|
public PageData<StModelRequestLogDTO> page(Map<String, Object> params) {
|
IPage<StModelRequestLogEntity> page = baseDao.selectPage(
|
getPage(params, "request_time", false),
|
getWrapper(params)
|
);
|
return getPageData(page, StModelRequestLogDTO.class);
|
}
|
|
private QueryWrapper<StModelRequestLogEntity> getWrapper(Map<String, Object> params) {
|
String modelId = (String) params.get("modelId");
|
String appKey = (String) params.get("appKey");
|
String startTime = (String) params.get("startTime");
|
String endTime = (String) params.get("endTime");
|
|
QueryWrapper<StModelRequestLogEntity> wrapper = new QueryWrapper<>();
|
wrapper.eq(StringUtils.isNotBlank(modelId), "model_id", modelId)
|
.like(StringUtils.isNotBlank(appKey), "app_key", appKey)
|
.ge(StringUtils.isNotBlank(startTime), "request_time", startTime)
|
.le(StringUtils.isNotBlank(endTime), "request_time", endTime);
|
return wrapper;
|
}
|
|
@Override
|
public void save(StModelRequestLogDTO dto) {
|
StModelRequestLogEntity entity = ConvertUtils.sourceToTarget(dto, StModelRequestLogEntity.class);
|
entity.setId(UUID.randomUUID().toString());
|
insert(entity);
|
}
|
}
|