package com.iailab.module.data.video.service.impl;
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.iailab.framework.common.constant.Constant;
|
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.data.video.dao.LogDao;
|
import com.iailab.module.data.video.dto.LogDTO;
|
import com.iailab.module.data.video.entity.LogEntity;
|
import com.iailab.module.data.video.service.LogService;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.Arrays;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* @author PanZhibao
|
* @Description
|
* @createTime 2024年03月07日
|
*/
|
@Service
|
public class LogServiceImpl extends BaseServiceImpl<LogDao, LogEntity> implements LogService {
|
|
@Override
|
public PageData<LogDTO> page(Map<String, Object> params) {
|
IPage<LogEntity> page = baseDao.selectPage(
|
getPage(params, Constant.CREATE_DATE, false),
|
getWrapper(params)
|
);
|
return getPageData(page, LogDTO.class);
|
}
|
|
@Override
|
public List<LogDTO> list(Map<String, Object> params) {
|
QueryWrapper<LogEntity> queryWrapper = getWrapper(params);
|
queryWrapper.orderByDesc(Constant.CREATE_DATE);
|
List<LogEntity> list = baseDao.selectList(queryWrapper);
|
return ConvertUtils.sourceToTarget(list, LogDTO.class);
|
}
|
|
@Override
|
public LogDTO get(String id) {
|
LogEntity entity = baseDao.selectById(id);
|
|
return ConvertUtils.sourceToTarget(entity, LogDTO.class);
|
}
|
|
private QueryWrapper<LogEntity> getWrapper(Map<String, Object> params){
|
String code = (String)params.get("code");
|
String location = (String)params.get("location");
|
Integer status = params.get("status") == null ? null : Integer.parseInt(params.get("status").toString());
|
|
QueryWrapper<LogEntity> wrapper = new QueryWrapper<>();
|
wrapper.like(StringUtils.isNotBlank(code), "code", code)
|
.like(StringUtils.isNotBlank(location), "location", location)
|
.eq(status != null, "status", status);
|
|
return wrapper;
|
}
|
|
@Override
|
public void save(LogDTO dto) {
|
LogEntity entity = ConvertUtils.sourceToTarget(dto, LogEntity.class);
|
|
insert(entity);
|
}
|
|
@Override
|
public void update(LogDTO dto) {
|
LogEntity entity = ConvertUtils.sourceToTarget(dto, LogEntity.class);
|
updateById(entity);
|
}
|
|
@Override
|
@DSTransactional(rollbackFor = Exception.class)
|
public void delete(String[] ids) {
|
baseDao.deleteBatchIds(Arrays.asList(ids));
|
}
|
}
|