package com.hzs.system.home.controller.api;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hzs.common.core.web.controller.BaseController;
import com.hzs.common.core.web.domain.AjaxResult;
import com.hzs.common.core.web.page.TableDataInfo;
import com.hzs.common.domain.system.ext.HoEnterpriseMissionExt;
import com.hzs.common.domain.system.home.HoVrArea;
import com.hzs.system.home.service.IHoVrAreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * VR专区 前端控制器
 * </p>
 *
 * @author hzs
 * @since 2022-11-19
 */
@RestController
@RequestMapping("/api/ho-vr-area")
public class ApiHoVrAreaController extends BaseController {
    @Autowired
    private IHoVrAreaService vrAreaService;

    /**
     * @description: 查询VR专区列表
     * @author: zhang jing
     * @date: 2022/8/30 10:20
     * @param: [vrArea]
     * @return: com.hzs.common.core.web.page.TableDataInfo
     **/
    @GetMapping("/list")
    public TableDataInfo list(HoEnterpriseMissionExt vrArea) {
        QueryWrapper<HoVrArea> queryWrapper = new QueryWrapper();
        if(null!=vrArea.getLanguageType()){
            if(vrArea.getLanguageType()!=1){
                queryWrapper.ne("PK_COUNTRY",vrArea.getPkCountry());
            }else{
                queryWrapper.eq("PK_COUNTRY",vrArea.getPkCountry());
            }
        }
        queryWrapper.lt("EFFECTIVE_DATE",new Date());
        queryWrapper.orderByAsc("SORT");
        List<HoVrArea> list = vrAreaService.list(queryWrapper);
        return getDataTable(list);
    }


    /**
     * @description: 查询单条个VR专区
     * @author: zhang jing
     * @date: 2022/8/30 10:21
     * @param: [pkId]
     * @return: com.hzs.common.core.web.domain.AjaxResult
     **/
    @GetMapping("/getOne/{pkId}")
    public AjaxResult getOne(@PathVariable Long pkId) {
        HoVrArea vrArea = vrAreaService.getById(pkId);
        return AjaxResult.success(vrArea);
    }

}
