package com.zcloud.modules.sys.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.zcloud.common.utils.PageUtils;
 import com.zcloud.modules.sys.dao.BusNoticeCorpDao;
 import com.zcloud.modules.sys.entity.BusNoticeCorpEntity;
 import com.zcloud.modules.sys.service.BusNoticeCorpService;
 import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

 import java.util.List;
 import java.util.Map;

/**
 * @Author chenxinying
 * @Desc (BusNoticeCorp)表服务实现类
 * @Date 2024-03-29 09:53:21
 */
@Service("busNoticeCorpService")
public class BusNoticeCorpServiceImpl extends ServiceImpl<BusNoticeCorpDao, BusNoticeCorpEntity> implements BusNoticeCorpService {

    @Override
	public BusNoticeCorpEntity queryByFlexibleParams(String paramName, Object paramValue) {
		QueryWrapper<BusNoticeCorpEntity> queryWrapper = new QueryWrapper<>();
		queryWrapper.eq(paramName, paramValue); // 根据传入的参数名和参数值动态构建查询条件

		return baseMapper.selectOne(queryWrapper);
	}

	@Override
	public List<BusNoticeCorpEntity> queryListByFlexibleParams(String paramName, Object paramValue) {
		QueryWrapper<BusNoticeCorpEntity> queryWrapper = new QueryWrapper<>();
		queryWrapper.eq(paramName, paramValue); // 根据传入的参数名和参数值动态构建查询条件

		return baseMapper.selectList(queryWrapper);
	}

    @Override
    public PageUtils listPage(Map<String, Object> params) {
        Page<Map<String,Object>> page = new Page<>(Integer.parseInt(params.get("curPage").toString()),Integer.parseInt(params.get("limit").toString()));
        params.put("isDelete",0);
        IPage<BusNoticeCorpEntity> ipage = baseMapper.listPage(page,params);
        return new PageUtils(ipage);
    }


   @Override
	public void delete(String noticeCorpId,String userId){
		UpdateWrapper<BusNoticeCorpEntity> updateWrapper = new UpdateWrapper<>();
		updateWrapper.eq("notice_corp_id",noticeCorpId);

		BusNoticeCorpEntity busNoticeCorp = new BusNoticeCorpEntity();
		busNoticeCorp.setIsDelete(1);

		this.update(busNoticeCorp, updateWrapper);
	}



}
