package com.ssm.controller;

import com.github.pagehelper.PageInfo;
import com.ssm.manage.query.SysMuenRoleRequest;
import com.ssm.manage.response.PageResponse;
import com.ssm.manage.entity.SysMuenRole;
import com.ssm.manage.response.ResponseCode;
import com.ssm.manage.service.SsmSysMuenRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@Api(value="门店角色关联菜单表（新登录）controller",tags={"门店角色关联菜单（新登录）相关接口"})
@RestController
@Slf4j
@RequestMapping("/demay/ssm/SysMuenRole")
public class SsmSysMuenRoleController {
    @Autowired
    private SsmSysMuenRoleService ssmSysMuenRoleService;

    @ApiOperation(value = "分页获取角色菜单信息  门店端-角色-分页获取角色信息", httpMethod = "POST", response = PageResponse.class, notes = "分页获取菜单信息")
    @RequestMapping(value = "/page", method = RequestMethod.POST)
    public PageResponse<SysMuenRole> selectByPage(@RequestBody SysMuenRole sysStoreRole, HttpSession session) {
        PageResponse<SysMuenRole> pageResponse = new PageResponse<>();
        PageInfo<SysMuenRole> pageInfo;
        if (null == sysStoreRole.getRoleId()) {
            pageResponse.setCodeAndMsg(ResponseCode.PARAMETER_NOT_EXIST_S, "角色Id");
            return pageResponse;
        }
        try {
            pageInfo = ssmSysMuenRoleService.selectPage(sysStoreRole);
        } catch (Exception e) {
            log.error("SsmSysRoleController.selectPage:", e);
            pageResponse.setCodeAndMsg(ResponseCode.FAILED);
            return pageResponse;
        }
        pageResponse.setCodeAndMsg(ResponseCode.OK);
        pageResponse.setPageInfo(pageInfo);
        return pageResponse;
    }

}
