package com.ruoyi.web.controller.gw;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.ZyArticle;
import com.ruoyi.system.domain.ZyCategory;
import com.ruoyi.system.domain.ZyRecruit;
import com.ruoyi.system.domain.ZySlideshow;
import com.ruoyi.system.service.IZyArticleService;
import com.ruoyi.system.service.IZyCategoryService;
import com.ruoyi.system.service.IZyRecruitService;
import com.ruoyi.system.service.IZySlideshowService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/door")
public class DoorController extends BaseController {

    @Autowired
    private IZyArticleService zyArticleService;

    @Autowired
    private IZyCategoryService zyCategoryService;

    @Autowired
    private IZyRecruitService zyRecruitService;

    @Autowired
    private IZySlideshowService zySlideshowService;

    /**
     * 查询官网所有栏目
     * @return
     */
    @ApiOperation("查询官网所有栏目")
    @RequestMapping(value = "/getCategoryList",method = RequestMethod.GET)
    public R<?> getCategoryList() {
        try {
            return R.ok(zyCategoryService.selectZyCategoryList(new ZyCategory()));
        }catch (Exception e){
            e.printStackTrace();
            return R.fail("查询栏目数据异常，请联系管理员");
        }
    }

    /**
     * 查询官网所有文章（可通过条件查询）
     * @param zyArticle
     * @return
     */
    @ApiOperation("查询官网所有文章（可通过条件查询）")
    @RequestMapping(value = "/getArticleList",method = RequestMethod.GET)
    public R<?> getArticleList(ZyArticle zyArticle) {
        try {
            return R.ok(zyArticleService.selectZyArticleList(zyArticle));
        }catch (Exception e){
            e.printStackTrace();
            return R.fail("查询文章数据异常，请联系管理员");
        }
    }

    /**
     * 根据文章id查看文章详情
     * @param id
     * @return
     */
    @ApiOperation("查询官网所有文章（可通过条件查询）")
    @RequestMapping(value = "/getArticleById",method = RequestMethod.GET)
    public R<?> getArticleById(Long id) {
        try {
            return R.ok(zyArticleService.selectZyArticleById(id));
        }catch (Exception e){
            e.printStackTrace();
            return R.fail("查询文章数据异常，请联系管理员");
        }
    }

    /**
     * 查询人才招聘信息
     * @param zyRecruit
     * @return
     */
    @ApiOperation("查询人才招聘信息")
    @RequestMapping(value = "/getRecruitList",method = RequestMethod.GET)
    public R<?> getRecruitList(ZyRecruit zyRecruit) {
        try {
            return R.ok(zyRecruitService.selectZyRecruitList(zyRecruit));
        }catch (Exception e){
            e.printStackTrace();
            return R.fail("查询人才招聘数据异常，请联系管理员");
        }
    }

    /**
     * 查询轮播图
     * @return
     */
    @ApiOperation("查询轮播图")
    @RequestMapping(value = "/getSlideshowList",method = RequestMethod.GET)
    public R<?> getSlideshowList() {
        try {
            return R.ok(zySlideshowService.selectZySlideshowList(new ZySlideshow()));
        }catch (Exception e){
            e.printStackTrace();
            return R.fail("查询文章数据异常，请联系管理员");
        }
    }
}
