package cn.com.countrygarden.bi.main.controller.advise;

import cn.com.countrygarden.bi.main.controller.BaseController;
import cn.com.countrygarden.bi.main.core.Response;
import cn.com.countrygarden.bi.main.core.Result;
import cn.com.countrygarden.bi.main.dto.advise.param.AdviseTypeParam;
import cn.com.countrygarden.bi.main.model.advise.AfAdviseType;
import cn.com.countrygarden.bi.main.service.advise.IAfAdviseTypeService;
import cn.com.countrygarden.bi.main.util.roleUtils.AuthorityCheck;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * 建言类型-控制层实现
 *
 * @author 木木子
 * @email 944528607@qq.com
 * @url
 * @date 2019-04-15
 */
@RestController("AfAdviseTypeController")
@RequestMapping("/api/afAdviseType")
public class AfAdviseTypeController extends BaseController {
    @Autowired
    private IAfAdviseTypeService afAdviseTypeService;

    @AuthorityCheck(authorityArray={"adviseSystemAdmin"} )
    @GetMapping(value = "/list", produces = "application/json;charset=utf-8")
    public Result list(AdviseTypeParam adviseTypeParam,HttpServletRequest request) {

        return afAdviseTypeService.queryList( adviseTypeParam,getAccessToken(request));
    }
    @GetMapping(value = "/selectList", produces = "application/json;charset=utf-8")
    public Result selectList(AdviseTypeParam adviseTypeParam, HttpServletRequest request) {

        return afAdviseTypeService.querySelectList(adviseTypeParam, getAccessToken(request));
    }
    @AuthorityCheck(authorityArray={"adviseSystemAdmin"} )
    @GetMapping(value = "/one", produces = "application/json;charset=utf-8")
    public Result queryById(@RequestParam(value = "id", required = true) Integer id,
                            HttpServletRequest request) {
        return afAdviseTypeService.queryById(id);
    }
    @AuthorityCheck(authorityArray={"adviseSystemAdmin"} )
    @PostMapping(value = "/addOrEdit")
    public Result addOrEdit(AfAdviseType afAdviseType,
                            HttpServletRequest request) {
        if (afAdviseType == null) {
            return Response.response();
        }
        return afAdviseTypeService.addOrEdit(afAdviseType, getAccessToken(request));
    }

    @AuthorityCheck(authorityArray={"adviseSystemAdmin"} )
    @DeleteMapping(value = "/del")
    public Result del(@RequestParam(value = "ids", required = true) String ids) {
        return afAdviseTypeService.del(ids);
    }


}