package com.fs.app.controller.store;

import com.fs.app.annotation.Login;
import com.fs.app.controller.AppBaseController;
import com.fs.common.core.domain.R;
import com.fs.course.param.UserCourseComplaintRecordParam;
import com.fs.course.service.IFsUserCourseComplaintRecordService;
import com.fs.course.service.IFsUserCourseComplaintTypeService;
import com.fs.course.vo.FsUserCourseComplaintTypeListVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api("看课投诉相关接口")
@RestController
@RequestMapping("/store/app/user/complaint")
public class UserCourseComplaintScrmController extends AppBaseController {

    @Autowired
    private IFsUserCourseComplaintTypeService fsUserCourseComplaintTypeService;

    @Autowired
    private IFsUserCourseComplaintRecordService fsUserCourseComplaintRecordService;

    @Login
    @ApiOperation("获取投诉类型")
    @GetMapping("/getTypeTree")
    public R getTypeTree() {
        List<FsUserCourseComplaintTypeListVO> allComplaintTypeTree = fsUserCourseComplaintTypeService.getAllComplaintTypeTree();
        return R.ok().put("data", allComplaintTypeTree);
    }

    @Login
    @ApiOperation("提交反馈记录")
    @PostMapping("/record")
    public R submitRecord(@RequestBody UserCourseComplaintRecordParam param) {
        param.setUserId(Long.parseLong(getUserId()));
        int i = fsUserCourseComplaintRecordService.submitRecord(param);
        if (i > 0) {
            return R.ok();
        } else {
            return R.error();
        }
    }

}
