package com.unis.crk.common.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.unis.crk.common.entity.AppVersion;
import com.unis.crk.common.entity.vo.AppVersionVo;
import com.unis.crk.common.mapper.AppVersionMapper;
import com.unis.crk.common.service.IAppVersionService;
import com.unis.crk.cplbusiness.entity.DataCrkywCplbjdyDefault;
import org.springframework.stereotype.Service;

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

/**
 * <p>
 * app版本 服务实现类
 * </p>
 *
 * @author TangSong
 * @since 2022-06-24
 */
@Service
public class AppVersionServiceImpl extends ServiceImpl<AppVersionMapper, AppVersion> implements IAppVersionService {

    @Resource
    private AppVersionMapper appVersionMapper;


    /**
     * 按照条件查询app版本信息
     * @param pageQuery
     * @throws Exception
     */
    @Override
    public IPage<Map<String,Object>> findPageVo(AppVersionVo pageQuery){
        {
        //条形查询器
        QueryWrapper<AppVersion> queryWrapper = new QueryWrapper<>();
         queryWrapper.orderByDesc("pub_date");
        //分页相关
        Page<AppVersion> p =new Page<>(pageQuery.getPage(),pageQuery.getLimit());

        IPage<Map<String,Object>> page = appVersionMapper.selectMyMapsPage(p,queryWrapper);
        return page;
        }
    }

    /**
     * 通过code得到内容
     *
     * @param appCode
     * @return
     */
    @Override
    public AppVersion getByCode(String appCode) {
        QueryWrapper<AppVersion> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("app_code", appCode);
        queryWrapper.last("limit 1");
        return super.getOne(queryWrapper) ;
    }

}
