package com.sqx.modules.bl.massage.controller;

import com.sqx.common.utils.Result;
import com.sqx.modules.bl.massage.entity.MassagePackage;
import com.sqx.modules.bl.massage.entity.MassagePackageDetail;
import com.sqx.modules.bl.massage.service.MassagePackageDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;

@RestController
@RequestMapping("/massage/packageDetail")
@Api(value = "服务包详情管理", tags = {"服务包详情管理"})
public class MassagePackageDetailController {

    @Autowired
    private MassagePackageDetailService service;

    @GetMapping("/findPage")
    @ApiOperation("查询按服务包详情（分页）")
    public Result findPage(MassagePackageDetail massagePackageDetail){
        return service.findPage(massagePackageDetail);
    }

    @PostMapping("/updatePrice")
    @ApiOperation("修改优惠价格")
    public Result updatePrice(MassagePackageDetail massagePackageDetail){
        service.updatePrice(massagePackageDetail);
        return Result.success();
    }

    @PostMapping("/updateCount")
    @ApiOperation("修改次数")
    public Result updateCount(MassagePackageDetail massagePackageDetail){
        service.updateCount(massagePackageDetail);
        return Result.success();
    }

    @PostMapping("/updateIntervalDays")
    @ApiOperation("修改时间间隔")
    public Result updateIntervalDays(MassagePackageDetail massagePackageDetail){
        service.updateIntervalDays(massagePackageDetail);
        return Result.success();
    }

    @PostMapping("/updateStatus")
    @ApiOperation("修改状态")
    public Result updateStatus(MassagePackageDetail massagePackageDetail){
        service.updateStatus(massagePackageDetail);
        return Result.success();
    }

    @PostMapping("/add")
    @ApiOperation("添加服务包详情")
    public Result add(MassagePackageDetail massagePackageDetail){
        service.save(massagePackageDetail);
        return Result.success();
    }

    @PostMapping("/insertDetail")
    @ApiOperation("添加项目与服务包详情")
    public Result insertDetail(MassagePackageDetail massagePackageDetail){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        massagePackageDetail.setCreateTime(sdf.format(new Date()));
        service.insertDetail(massagePackageDetail);
        return Result.success();
    }

    @GetMapping("/findMassagePage")
    @ApiOperation("查询按服务包详情（分页）")
    public Result findMassagePage(MassagePackageDetail massagePackageDetail){
        return service.findMassagePage(massagePackageDetail);
    }

    @PostMapping("/delete")
    @ApiOperation("删除服务包详情")
    public Result delete(MassagePackageDetail massagePackageDetail){
        service.delete(massagePackageDetail);
        return Result.success();
    }

}
