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


import com.yida.data.common.core.annotation.ControllerLog;
import com.yida.data.common.core.common.ModuleName;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.apply.EduApplyFunction;
import com.yida.data.common.core.entity.system.enums.OperationLogTypeEnum;
import com.yida.data.log.annotation.OperationLog;
import com.yida.data.school.transaction.service.EduApplyFunctionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 后台应用功能管理
 */
@Api(tags = "交易-应用功能")
@RestController
@RequestMapping("/transaction/applyFunction")
public class EduApplyFunctionController {
    @Resource
    private EduApplyFunctionService eduApplyFunctionService;


    @ApiOperation("新增应用功能")
    @PostMapping("/insertApplyFunction")
    @OperationLog(module = ModuleName.TRANSATION, methods = "新增应用功能", type = OperationLogTypeEnum.INSERT)
    public ResultBean<EduApplyFunction> insertApply(@ApiParam("应用名字") @RequestParam EduApplyFunction eduApplyFunction) {
        eduApplyFunctionService.insertEduApplyFunctionService(eduApplyFunction);
        return ResultBean.buildSuccess();
    }


    @ApiOperation("修改应用功能")
    @PostMapping("/updateApplyFunction")
    @OperationLog(module = ModuleName.TRANSATION, methods = "修改应用功能", type = OperationLogTypeEnum.UPDATE)
    public ResultBean<EduApplyFunction> upDataApplyFunction(@ApiParam("应用名字") @RequestParam EduApplyFunction eduApplyFunction) {

        eduApplyFunctionService.upDataEduApplyFunctionService(eduApplyFunction);
        return ResultBean.buildSuccess();
    }


    @ApiOperation("删除应用功能")
    @GetMapping("/removeEduApplyFunction")
    @OperationLog(module = ModuleName.TRANSATION, methods = "删除应用功能", type = OperationLogTypeEnum.DELETE)
    public ResultBean removeEduApply(@ApiParam("功能id") @RequestParam Long functionId) {
        eduApplyFunctionService.removeById(functionId);
        return ResultBean.buildSuccess();
    }
}