Newer
Older
huludao / src / main / java / com / newfiber / api / pc / service / impl / CameraPicServiceImpl.java
package com.newfiber.api.pc.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.newfiber.api.core.utils.StringUtil;
import com.newfiber.api.pc.dao.CameraPicMapper;
import com.newfiber.api.pc.model.entity.CameraPic;
import com.newfiber.api.pc.service.CameraPicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 视频图片
 */
@Service
public class CameraPicServiceImpl implements CameraPicService {

    @Autowired
    private CameraPicMapper cameraPicMapper;

    @Override
    public int saveImage(CameraPic cameraPic) {
        if(cameraPic == null){
            return 0;
        }
        //截取图片名称
        if(!StringUtil.isEmpty(cameraPic.getFilePath())){
            String name = cameraPic.getFilePath();
            String fileName = name.substring(name.lastIndexOf("/")+1);
            cameraPic.setFileName(fileName);
        }
        return cameraPicMapper.insertSelective(cameraPic);
    }

    @Override
    public PageInfo<CameraPic> imageList(String indexCode, String startTime, String endTime, Integer current, Integer size) {
        PageInfo<CameraPic> result = new PageInfo<>();
        if(StringUtil.isEmpty(indexCode)){
            return result;
        }
        PageHelper.startPage(current,size);
        List<CameraPic> list = cameraPicMapper.imageList(indexCode,startTime,endTime);
        if(!list.isEmpty()){
            result = new PageInfo<>(list);
        }
        return result;
    }
}