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

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
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.rlzysc.blo.JyzdglBLO;
import com.zjrs.zwnw.rlzysc.dto.JyzdQueryDTO;
import com.zjrs.zwnw.rlzysc.dto.ZjDTO;
import com.zjrs.zwnw.rlzysc.entity.JyzdglMapper;
import com.zjrs.zwnw.rlzysc.po.VRsRlzyJyzdPO;
import com.zjrs.zwnw.rlzysc.util.UserUtil;
import org.springframework.stereotype.Service;

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

@Service
public class JyzdglBLOimpl extends BLOImpl implements JyzdglBLO {

    @Resource
    private JyzdglMapper jyzdglMapper;

    @Override
    public PageResult getJyzdglList(JyzdQueryDTO dto) {
        CurrentUser currentUser = getCurrentUser();
        String userregioncode = UserUtil.getBae001(currentUser);//行政区划代码
        dto.setUserregioncode(userregioncode);
        Page<Map<String, Object>> page = new Page<>(dto.getPagenum(), dto.getPagesize());
        Page<Map<String, Object>> pageResult = (Page) jyzdglMapper.getJyzdglList(page, dto);
        PageResult result = PageUtil.PageResult(pageResult);
        return result;
    }

    @Override
    public void updateJyzdglsffk(ZjDTO dto) {
        String[] zjlshs = dto.getZjlsh().split(",");
        VRsRlzyJyzdPO po = new VRsRlzyJyzdPO();
        po.setSffk("1");
        jyzdglMapper.update(po,new UpdateWrapper<VRsRlzyJyzdPO>().in("rs_rlzy_jyzd",zjlshs));
    }

}
