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 implements StModelRequestLogService { @Override public PageData page(Map params) { IPage page = baseDao.selectPage( getPage(params, "request_time", false), getWrapper(params) ); return getPageData(page, StModelRequestLogDTO.class); } private QueryWrapper getWrapper(Map 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 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); } }