package com.iformall.controller.sys;

import com.github.pagehelper.PageInfo;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.vo.MallUserActionVo;
import com.iformall.service.MallUserActionService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("mallUserAction")
public class MallUserActionController extends BaseController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private MallUserActionService mallUserActionService;

    @ApiOperation("分页列表接口")
    @GetMapping("list")
    @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 MallUserActionVo userAction, Integer pageNum, Integer pageSize) {
        logger.debug("[" + getIpAddr() + "] MallUserActionController::list");
        if (null == userAction) {
            userAction = new MallUserActionVo();
        } else {
            if(StringUtils.isBlank(userAction.getName())) {
                userAction.setName(null);
            }
        }
        final PageInfo<MallUserActionVo> page = mallUserActionService.listAsPage(userAction, pageNum, pageSize);
        return new ResultData(page);
    }


}
