package com.yida.data.school.transaction.controller;

import com.yida.data.common.core.common.ModuleName;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.apply.EduProduct;
import com.yida.data.common.core.entity.system.enums.OperationLogTypeEnum;
import com.yida.data.log.annotation.OperationLog;
import com.yida.data.school.transaction.service.EduProductNoticeService;
import com.yida.data.school.transaction.service.EduProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import javax.annotation.Resource;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chenbo
 */
@Api(tags = "交易-商品(不鉴权)")
@AllArgsConstructor
@RestController
@RequestMapping("/in/transaction/product")
public class InEduProductController {
    @Resource
    EduProductService eduProductService;
    @Resource
    EduProductNoticeService eduProductNoticeService;

    @ApiOperation("商品上架")
    @GetMapping("/upDateProductById")
    @OperationLog(module = ModuleName.PRODUCT, methods = "商品上架", type = OperationLogTypeEnum.UPDATE)
    public ResultBean upDateProductById(@ApiParam("商品") @RequestParam("id") Long id) {
        EduProduct eduProduct = new EduProduct();
        eduProduct.setProductId(id);
        eduProduct.setStatus(1);
        eduProductService.upDateProductById(eduProduct);
        return ResultBean.buildSuccess();
    }

    @ApiOperation("发送商品催缴续费通知")
    @GetMapping("/productSendNotice")
    @OperationLog(module = ModuleName.PRODUCT, methods = "发送商品催缴续费通知", type = OperationLogTypeEnum.SELECT)
    public ResultBean productSendNotice(@ApiParam("通知id") @RequestParam("id") Long id) {
        eduProductNoticeService.productSendNotice(id);
        return ResultBean.buildSuccess();
    }

    @ApiOperation("修改商品的状态为已失效")
    @GetMapping("/productMonitor")
    @OperationLog(module = ModuleName.PRODUCT, methods = "修改商品的状态为已失效", type = OperationLogTypeEnum.UPDATE)
    public ResultBean productMonitor() {
        eduProductNoticeService.productMonitor();
        return ResultBean.buildSuccess();
    }

}
