package thyyxxk.webserver.controller.outpatient.thmz;

import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import thyyxxk.webserver.config.auth.PassToken;
import thyyxxk.webserver.config.exception.ExceptionEnum;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.executeItem.ZdChargeItem;
import thyyxxk.webserver.service.outpatient.thmz.ShareholderCardService;
import thyyxxk.webserver.service.outpatient.thmz.ZdDiscountDetail;
import thyyxxk.webserver.service.outpatient.thmz.ZdVisitTypeNew;
import thyyxxk.webserver.utils.ResultVoUtil;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Description:
 * @Author:lihong
 * @Date: 2024/1/12
 */
@Slf4j
@RestController
@RequestMapping("/shareholderCard")
public class ShareholderCardController {
    @Resource
    private ShareholderCardService service;
    /**
     * @description: 查询优惠类型
     * @author: lihong
     * @date: 2024/1/12 9:11
     * @return: thyyxxk.webserver.entity.ResultVo<java.util.Map<java.lang.String,java.lang.Object>>
     **/
    @PassToken
    @GetMapping("/queryDiscountClass")
    public ResultVo<List<Map<String, Object>>> queryDiscountClass(){
        return ResultVoUtil.success(service.queryDiscountClass());
    }

    /**
     * @description: 查询身份
     * @author: lihong
     * @date: 2024/1/12 9:45
     * @return: thyyxxk.webserver.entity.ResultVo<java.util.List<thyyxxk.webserver.service.mz.ZdVisitTypeNew>>
     **/
    @PassToken
    @PostMapping("/queryZdVisitTypeNew")
    public ResultVo<List<ZdVisitTypeNew>> queryZdVisitTypeNew(@RequestBody ZdVisitTypeNew zdVisitTypeNew){
        return ResultVoUtil.success(service.queryZdVisitTypeNew(zdVisitTypeNew));
    }

    /**
     * @description: 更新
     * @author: lihong
     * @date: 2024/1/12 9:54
     * @param: param
     * @return: thyyxxk.webserver.entity.ResultVo<java.util.List<thyyxxk.webserver.service.mz.ZdVisitTypeNew>>
     **/
    @PassToken
    @PostMapping("/delZdVisitTypeNew")
    public ResultVo<List<ZdVisitTypeNew>> delZdVisitTypeNew(@RequestBody ZdVisitTypeNew param){
        service.delZdVisitTypeNew(param);
        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_EL_MESSAGE,"成功");
    }
    @PassToken
    @PostMapping("/updateZdVisitTypeNew")
    public ResultVo<List<ZdVisitTypeNew>> updateZdVisitTypeNew(@RequestBody ZdVisitTypeNew param){
        service.updateZdVisitTypeNew(param);
        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_EL_MESSAGE,"成功");
    }
    @PassToken
    @PostMapping("/insertZdVisitTypeNew")
    public ResultVo<List<ZdVisitTypeNew>> insertZdVisitTypeNew(@RequestBody ZdVisitTypeNew param){
        service.insertZdVisitTypeNew(param);
        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_EL_MESSAGE,"保存成功");
    }
    @PassToken
    @PostMapping("/queryPatientInfo")
    public ResultVo<IPage> queryPatientInfo(@RequestBody  Map<String,Object> params){
        return ResultVoUtil.success(service.queryPatientInfo(new Page(Convert.toInt(params.get("currentPage"),1),Convert.toInt(params.get("pageSize"),30)),Convert.toStr(params.get("keyWard")),Convert.toInt(params.get("id"))));
    }

    @PassToken
    @PostMapping("/saveZdVisitTypeUser")
    public ResultVo<String> saveZdVisitTypeUser(@RequestBody ZdVisitTypeNew params){
        service.saveZdVisitTypeUser(params);
        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_EL_MESSAGE,"保存成功");
    }

    @PassToken
    @PostMapping("/delZdVisitTypeUser")
    public ResultVo<String> delZdVisitTypeUser(@RequestBody ZdVisitTypeNew params){
        service.delZdVisitTypeUser(params);
        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_EL_MESSAGE,"删除成功");
    }

    /**
     * @description: 查询优惠明细
     * @author: lihong
     * @date: 2024/1/15 9:20
     * @param: params
     * @return: thyyxxk.webserver.entity.ResultVo<java.lang.String>
     **/
    @PassToken
    @PostMapping("/queryZdDiscountDetail")
    public ResultVo<IPage> queryZdDiscountDetail(@RequestBody ZdDiscountDetail params){
        return ResultVoUtil.success(service.queryZdDiscountDetail(params));
    }

    /**
     * @description: 启用或停用
     * @author: lihong
     * @date: 2024/1/15 9:32
     * @param: params
     * @return: thyyxxk.webserver.entity.ResultVo<java.util.List<thyyxxk.webserver.service.mz.ZdDiscountDetail>>
     **/
    @PassToken
    @PostMapping("/updateZdDiscountDetailDelFlag")
    public ResultVo<List<ZdDiscountDetail>> updateZdDiscountDetailDelFlag(@RequestBody ZdDiscountDetail params){
        service.updateZdDiscountDetailDelFlag(params);
        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_EL_MESSAGE);
    }
    /**
     * @description:
     * @author: lihong
     * @date: 2024/1/15 9:34
     * @param: params
     * @return: thyyxxk.webserver.entity.ResultVo<java.util.List<thyyxxk.webserver.service.mz.ZdDiscountDetail>>
     **/
    @PassToken
    @PostMapping("/saveZdDiscountDetail")
    public ResultVo<List<ZdDiscountDetail>> saveZdDiscountDetail(@RequestBody ZdDiscountDetail params){
        service.saveZdDiscountDetail(params);
        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_EL_MESSAGE,"保存成功");
    }


    @PassToken
    @PostMapping("/queryItemDetail")
    public ResultVo<List<ZdChargeItem>> queryItemDetail(@RequestBody ZdDiscountDetail params){
        return ResultVoUtil.success(service.queryItemDetail(params));
    }

    @PassToken
    @PostMapping("/queryItemList")
    public ResultVo<List<ZdChargeItem>> queryItemList(@RequestBody Map<String,Object> params){
        return ResultVoUtil.success(service.queryItemList(Convert.toStr(params.get("discountClass")),Convert.toStr(params.get("keyWard"))));
    }

    /**
     * @description: 查询所组合套餐
     * @author: lihong
     * @date: 2024/1/17 10:20
     * @return: thyyxxk.webserver.entity.ResultVo<java.util.List<java.util.Map<java.lang.String,java.lang.Object>>>
     **/
    @PassToken
    @GetMapping("/queryAllTemplate")
    public ResultVo<List<Map<String,Object>>> queryAllTemplate(){
        return service.queryAllTemplate();
    }
    /**
     * @description: 查询组合套餐明细
     * @author: lihong
     * @date: 2024/1/17 10:20
     * @param: params
     * @return: thyyxxk.webserver.entity.ResultVo<java.util.List<java.util.Map<java.lang.String,java.lang.Object>>>
     **/
    @PassToken
    @PostMapping("/queryTemplateDetails")
    public ResultVo<List<Map<String,Object>>> queryTemplateDetails(@RequestBody Map<String,Object> params){
        return ResultVoUtil.success(service.queryTemplateDetails(Convert.toLong(params.get("code"))));
    }
    /**
     * @description: 查询挂号类别
     * @author: lihong
     * @date: 2024/1/17 10:20
     * @return: thyyxxk.webserver.entity.ResultVo<java.util.List<java.util.Map<java.lang.String,java.lang.Object>>>
     **/
    @PassToken
    @GetMapping("/queryMzChargeType")
    public ResultVo<List<Map<String,Object>>> queryMzChargeType(){
        return ResultVoUtil.success(service.queryMzChargeType());
    }

}
