package com.huimv.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huimv.admin.common.token.TokenSign;
import com.huimv.admin.common.utils.Result;
import com.huimv.admin.common.utils.ResultCode;
import com.huimv.admin.entity.BillIsolate;
import com.huimv.admin.mapper.BillIsolateMapper;
import com.huimv.admin.service.IBillIsolateService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * <p>
 * 隔离 服务实现类
 * </p>
 *
 * @author author
 * @since 2023-07-21
 */
@Service
public class BillIsolateServiceImpl extends ServiceImpl<BillIsolateMapper, BillIsolate> implements IBillIsolateService {

    @Resource
    private BillIsolateMapper billIsolateMapper;
    @Override
    public Result listPersonalIsolate(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
        String pageNo = paramsMap.get("pageNum");
        String pageSize = paramsMap.get("pageSize");
        Page<BillIsolate> page = new Page<>(Integer.parseInt(pageNo),Integer.parseInt(pageSize));
        QueryWrapper<BillIsolate> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("admission_user_id", TokenSign.getMemberIdByJwtToken(httpServletRequest)).orderByDesc("isolate_start_date");
        return new Result(ResultCode.SUCCESS,billIsolateMapper.selectPage(page,new QueryWrapper<BillIsolate>().eq("admission_user_id", TokenSign.getMemberIdByJwtToken(httpServletRequest)).orderByDesc("isolate_start_date")),billIsolateMapper.selectCount(queryWrapper));
    }
}
