package com.hssx.pcbms.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hssx.pcbms.entity.Goods;
import com.hssx.pcbms.entity.IdeaComment;
import com.hssx.pcbms.entity.Institution;
import com.hssx.pcbms.entity.vo.InstitutionVO;
import com.hssx.pcbms.mapper.InstitutionMapper;
import com.hssx.pcbms.service.InstitutionService;
import com.hssx.pcbms.util.HttpRespMsg;
import com.hssx.pcbms.util.PageUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 吴涛涛
 * @since 2019-11-05
 */
@Controller
@RequestMapping("/institution")
public class InstitutionController {
    @Autowired
    private InstitutionService institutionService;

    /**
     * 制度标题列表
     * 参数：pageNum:当前页，pageSize：每页多少条
     * @return
     */
    @ApiOperation(value = "制度标题列表", notes = "制度标题列表")
    @RequestMapping("/list")
    @ResponseBody
    public HttpRespMsg list(PageUtil page) {
        HttpRespMsg msg = new HttpRespMsg();
        PageHelper.startPage(page.getPageNum(),page.getPageSize());
        List<Institution> institutions = institutionService.list(new QueryWrapper<Institution>().select("id","title"));
        PageInfo<Institution> info = new PageInfo<>(institutions);
        msg.data = info;
        return msg;
    }
    /**
     * 制度标题列表
     * 参数：id:制度id
     * @return
     */
    @ApiOperation(value = "制度标题列表", notes = "制度标题列表")
    @RequestMapping("/detail")
    @ResponseBody
    public HttpRespMsg detail(Institution institution) {
        HttpRespMsg msg = new HttpRespMsg();
        msg = institutionService.getDetail(institution);
        return msg;
    }

}

