package com.iformall.controller.sys;


import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxDataRuleTarget;
import com.iformall.service.WxDataRuleTargetService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author gongbiao
 */
@RestController
@RequestMapping("wxDataRuleTarget")
@Api(description = "数据权限目标")
public class WxDataRuleTargetController extends BaseController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private WxDataRuleTargetService wxDataRuleTargetService;

    @ApiOperation("列表接口")
    @GetMapping("list")
    @SystemControllerLog(description = "数据权限目标-列表接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)})
    public ResultData list(@ModelAttribute WxDataRuleTarget wxDataRuleTarget, Integer pageNum, Integer pageSize) {
        logger.debug("[" + getIpAddr() + "] wxDataRuleTarget::list");
        final PageInfo<WxDataRuleTarget> page = wxDataRuleTargetService.listAsPage(wxDataRuleTarget, pageNum, pageSize);
        return new ResultData(page);
    }


    @ApiOperation("获取全部")
    @GetMapping("getList")
    @SystemControllerLog(description = "数据权限目标-获取全部")
    public ResultData getList() {
        logger.debug("[" + getIpAddr() + "] wxDataRuleTarget::getList");
        List<WxDataRuleTarget> datalist = wxDataRuleTargetService.getList();
        return new ResultData(datalist);
    }
}
