package com.ssm.controller;


import com.ssm.filter.LoginInterceptor;
import com.ssm.manage.entity.BaseProject;
import com.ssm.manage.entity.CooperateList;
import com.ssm.manage.entity.SmsException;
import com.ssm.manage.query.CooperateListRequest;
import com.ssm.manage.query.CooperateProjectRequst;
import com.ssm.manage.query.ProjectRequest;
import com.ssm.manage.response.*;
import com.ssm.manage.service.CooperateListService;
import com.ssm.manage.service.CooperateProjectService;
import com.ssm.manage.utils.SessionHelp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
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.text.ParseException;
import java.util.List;

@Api(value="合作商项目",tags={"合作商项目"})
@RestController
@RequestMapping("/demay/ssm/cooperateProject")
@Slf4j
public class CooperateProjectController {

    @Autowired
    private CooperateProjectService cooperateProjectService;

    @ApiOperation(value = "新增", httpMethod = "POST", response = GenericResponse.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "projectNum",value = "项目编码",required = true),
            @ApiImplicitParam(name = "projectName",value = "项目名字",required = true),
            @ApiImplicitParam(name = "projectId",value = "项目id",required = true),
            @ApiImplicitParam(name = "cooperateNum",value = "合作商编码",required = true),
            @ApiImplicitParam(name = "cooperateName",value = "合作商名字",required = true),
            @ApiImplicitParam(name = "cooperateId",value = "合作商id",required = true),
            @ApiImplicitParam(name = "type",value = "0固定抽成，1比例抽成",required = true),
            @ApiImplicitParam(name = "projectMoney",value = "项目金额",required = true),
            @ApiImplicitParam(name = "projectNumber",value = "项目次数",required = true),
            @ApiImplicitParam(name = "brokerage",value = "金额",required = true),
            @ApiImplicitParam(name = "isCourse",value = "0收银，1疗程",required = true)
    })
    @RequestMapping("/add")
    public GenericResponse add(@RequestBody CooperateProjectRequst cooperateProject, HttpSession session) {
        return cooperateProjectService.insert(cooperateProject,session);
    }

    @ApiOperation(value = "分页查询", httpMethod = "POST", response = GenericResponse.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum",value = "页码",required = true),
            @ApiImplicitParam(name = "pageSize",value = "每页条数",required = true)
    })
    @RequestMapping("/page")
    public PageResponse page(@RequestBody CooperateProjectRequst cooperateProject, HttpSession session) {
        StaffResponse staffResponse = LoginInterceptor.getCurrentUserInfo();
        LoginInterceptor.clearThreadLocal();
        return cooperateProjectService.page(cooperateProject);
    }


    @ApiOperation(value = "修改", httpMethod = "POST", response = GenericResponse.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "id",required = true)
    })
    @RequestMapping("/update")
    public GenericResponse update(@RequestBody CooperateProjectRequst cooperateListRequest, HttpSession session) {
        return cooperateProjectService.update(cooperateListRequest,session);
    }



    @ApiOperation(value = "删除", httpMethod = "POST", response = GenericResponse.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "id",required = true)
    })
    @RequestMapping("/delete")
    public GenericResponse delete(@RequestBody CooperateProjectRequst cooperateListRequest, HttpSession session) {
        return cooperateProjectService.delete(cooperateListRequest.getId());
    }





}
