package com.dy.pipIrrIrrigate.crop; 
 | 
  
 | 
import com.dy.common.webUtil.QueryResultVo; 
 | 
import com.dy.pipIrrGlobal.daoIr.IrCropMapper; 
 | 
  
 | 
import com.dy.pipIrrGlobal.pojoIr.IrCrop; 
 | 
import com.dy.pipIrrGlobal.voIr.VoCrop; 
 | 
import com.dy.pipIrrGlobal.voIr.VoCropOne; 
 | 
import com.dy.pipIrrGlobal.voIr.VoProjectOne; 
 | 
import com.dy.pipIrrIrrigate.crop.QueryVo; 
 | 
import lombok.extern.slf4j.Slf4j; 
 | 
import org.apache.dubbo.common.utils.PojoUtils; 
 | 
import org.springframework.beans.factory.annotation.Autowired; 
 | 
import org.springframework.stereotype.Service; 
 | 
  
 | 
import java.util.Date; 
 | 
import java.util.List; 
 | 
import java.util.Map; 
 | 
  
 | 
/** 
 | 
 * @author :WuZeYu 
 | 
 * @Date :2024/5/24  19:38 
 | 
 * @LastEditTime :2024/5/24  19:38 
 | 
 * @Description 
 | 
 */ 
 | 
@Slf4j 
 | 
@Service 
 | 
public class CropSv { 
 | 
  
 | 
    @Autowired 
 | 
    private IrCropMapper irCropMapper; 
 | 
  
 | 
    /** 
 | 
     * 添加项目 
 | 
     * 
 | 
     * @param po 
 | 
     * @return 
 | 
     */ 
 | 
    public Integer addCrop(IrCrop po) { 
 | 
        po.setDeleted((byte) 0); 
 | 
        int rows = irCropMapper.insertSelective(po); 
 | 
        if (rows == 0) { 
 | 
            return 0; 
 | 
        } 
 | 
        return 1; 
 | 
    } 
 | 
    /** 
 | 
     * 删除项目 
 | 
     * 
 | 
     * @param id 
 | 
     */ 
 | 
    public Integer deleteCrop(Long id) { 
 | 
        int rows = irCropMapper.deleteLogicById(id); 
 | 
        if (rows == 0) { 
 | 
            return 0; 
 | 
        } 
 | 
        return 1; 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 修改项目信息 
 | 
     * @param po 
 | 
     * @return 
 | 
     */ 
 | 
    public Integer updateCrop(IrCrop po){ 
 | 
        int rows = irCropMapper.updateByPrimaryKeySelective(po); 
 | 
        if (rows == 0){ 
 | 
            return 0; 
 | 
        } 
 | 
        return 1; 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 分页查询项目 
 | 
     * @param queryVo 
 | 
     * @return 
 | 
     */ 
 | 
    public QueryResultVo<List<VoCrop>> getCrops(QueryVo queryVo){ 
 | 
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); 
 | 
        Long itemTotal = irCropMapper.getRecordCount(params); 
 | 
  
 | 
        QueryResultVo<List<VoCrop>> rsVo = new QueryResultVo<>(); 
 | 
        rsVo.pageSize = queryVo.pageSize; 
 | 
        rsVo.pageCurr = queryVo.pageCurr; 
 | 
        rsVo.calculateAndSet(itemTotal, params); 
 | 
        rsVo.obj = irCropMapper.getCrops(params); 
 | 
        return rsVo; 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 获取一个作物数据 
 | 
     * @param id 
 | 
     * @return 
 | 
     */ 
 | 
    public VoCropOne selectById(Long id){ 
 | 
        VoCropOne irCrop = irCropMapper.selectById(id); 
 | 
        return irCrop; 
 | 
    } 
 | 
} 
 |