package com.ssm.controller;


import com.ssm.manage.response.PageResponse;
import com.ssm.manage.entity.BaseZengkaIssue;
import com.ssm.manage.entity.BaseZengkaIssueRequest;
import com.ssm.manage.response.ResponseCode;
import com.ssm.manage.service.SsmBaseZengkaIssueService;
import com.ssm.manage.service.SsmBaseZengkaService;
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.RestController;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;

@Api(value="门店充值卡赠送卡明细表controller",tags={"门店充值卡赠送卡明细相关接口"})
@RestController
@RequestMapping("/demay/ssm/baseZengkaIssue")
@Slf4j
public class SsmBaseZengkaIssueController {

    @Autowired
    private SsmBaseZengkaIssueService ssmBaseZengkaIssueService;

    @Autowired
    private SsmBaseZengkaService ssmBaseZengkaService;

    @ApiOperation(value = "门店端-项目-分页查询项目", httpMethod = "POST", response = PageResponse.class)
    @RequestMapping("/page")
    public PageResponse selectPageNew(@RequestBody BaseZengkaIssueRequest baseZengkaIssueRequest, HttpSession session) {
        PageResponse<BaseZengkaIssue> pageResponse = new PageResponse<>();
        List<BaseZengkaIssue> list = new ArrayList<>();

        try {
            BaseZengkaIssue baseZengkaIssue = new BaseZengkaIssue();
            baseZengkaIssue.setZengkaId(baseZengkaIssueRequest.getZengkaId());
            list = ssmBaseZengkaIssueService.select(baseZengkaIssue);
        } catch (Exception e) {
            log.error("SsmProjectController.page", e);
            pageResponse.setCodeAndMsg(ResponseCode.FAILED);
            return pageResponse;
        }
        pageResponse.setData(list);
        pageResponse.setCodeAndMsg(ResponseCode.OK);
        return pageResponse;
    }


}
