package com.zjrs.zwnw.dbgl.blo.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.mohrss.leaf.core.framework.domain.blo.impl.BLOImpl;
import org.mohrss.leaf.core.framework.persistens.PageResult;
import org.mohrss.leaf.core.framework.persistens.PageUtil;
import org.mohrss.leaf.core.framework.util.CurrentUser;
import com.zjrs.zwnw.dbgl.blo.DbrwtbPLO;
import com.zjrs.zwnw.dbgl.dto.DbrwglDbrwtbQueryDTO;
import com.zjrs.zwnw.dbgl.dto.DbrwglGzrwtbSaveDTO;
import com.zjrs.zwnw.dbgl.entity.DbrwMapper;
import com.zjrs.zwnw.dbgl.entity.GzqdMapper;
import com.zjrs.zwnw.dbgl.po.RsdbglgzqdPO;
import com.zjrs.zwnw.portal.blo.CommonBLO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import jakarta.annotation.Resource;
import java.util.Map;


/**
 * @Author chenzhibiao
 * @create 2022/6/30 8:43
 */
@Service
public class DbrwtbimplPLO extends BLOImpl implements DbrwtbPLO {
    @Resource
    private DbrwMapper dbrwMapper;
    @Resource
    private CommonBLO commonBLO;
    @Resource
    private GzqdMapper gzqdMapper;

    @Override
    public PageResult getDbrwtbList(DbrwglDbrwtbQueryDTO dto, Integer pagenum, Integer pagesize){
        CurrentUser currentUser = getCurrentUser();
        String userid = currentUser.getUserid()==null?"":currentUser.getUserid().trim();
        //userid = "1c872fa8-8681-42b4-a221-04f5a7759b74";
        dto.setUserid(userid);
        Page<Map<String, Object>> page = new Page<>(dto.getPagenum(), dto.getPagesize());
        Page<Map<String, Object>> pageResult = (Page) dbrwMapper.getDbrwtbList(page,dto);
        PageResult result = PageUtil.PageResult(pageResult);
        return result;
    }
    @Override
    public void saveDbrwtb(DbrwglGzrwtbSaveDTO dto){
        RsdbglgzqdPO po = new RsdbglgzqdPO();
        BeanUtils.copyProperties(dto,po);
        po.setShzt("0");
        po.setShsj("");
        po.setShjg("");
        po.setChecker("");
        this.gzqdMapper.updateById(po);
    }
}
