package com.yonge.cooleshow.admin.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;

import com.yonge.cooleshow.biz.dal.support.PageUtil;
import com.yonge.cooleshow.common.controller.BaseController;
import com.yonge.cooleshow.common.entity.HttpResponseResult;
import com.yonge.toolset.mybatis.page.PageInfo;
import com.yonge.toolset.utils.string.StringUtil;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

import com.yonge.cooleshow.biz.dal.vo.CourseScheduleRepliedVo;
import com.yonge.cooleshow.biz.dal.dto.search.CourseScheduleRepliedSearch;
import com.yonge.cooleshow.biz.dal.entity.CourseScheduleReplied;
import com.yonge.cooleshow.biz.dal.service.CourseScheduleRepliedService;

@RestController
@RequestMapping("/courseScheduleReplied")
@Api(value = "课程点评", tags = "课程点评")
public class CourseScheduleRepliedController extends BaseController {

    @Autowired
    private CourseScheduleRepliedService courseScheduleRepliedService;

	/**
     * 查询单条
     */
    @GetMapping("/detail/{id}")
    @ApiOperation(value = "详情", notes = "传入id")
    public HttpResponseResult<CourseScheduleRepliedVo> detail(@PathVariable("id") Long id) {
    	return succeed(courseScheduleRepliedService.detail(id));
	}
    
    /**
     * 查询分页
     */
    @PostMapping("/page")
    @ApiOperation(value = "查询分页", notes = "传入courseScheduleRepliedSearch")
    public HttpResponseResult<PageInfo<CourseScheduleRepliedVo>> page(@RequestBody CourseScheduleRepliedSearch query) {
		IPage<CourseScheduleRepliedVo> pages = courseScheduleRepliedService.selectPage(PageUtil.getPage(query), query);
        return succeed(PageUtil.pageInfo(pages));
	}
    
    /**
	 * 新增
	 */
	@PostMapping("/save")
	@ApiOperation(value = "新增", notes = "传入courseScheduleReplied")
	public HttpResponseResult save(@Valid @RequestBody CourseScheduleReplied courseScheduleReplied) {
    	return status(courseScheduleRepliedService.save(courseScheduleReplied));
	}
    
    /**
	 * 修改
	 */
	@PostMapping("/update")
	@ApiOperation(value = "修改", notes = "传入courseScheduleReplied")
	public HttpResponseResult update(@Valid @RequestBody CourseScheduleReplied courseScheduleReplied) {
        return status(courseScheduleRepliedService.updateById(courseScheduleReplied));
	}
    
    /**
	 * 新增或修改
	 */
    @PostMapping("/submit")
    @ApiOperation(value = "新增或修改", notes = "传入courseScheduleReplied")
	public HttpResponseResult submit(@Valid @RequestBody CourseScheduleReplied courseScheduleReplied) {
        return status(courseScheduleRepliedService.saveOrUpdate(courseScheduleReplied));
    }

 	/**
	 * 删除
	 */
	@PostMapping("/remove")
	@ApiOperation(value = "逻辑删除", notes = "传入ids")
	public HttpResponseResult remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
        if (StringUtil.isEmpty(ids)) {
			return failed("参数不能为空");
		}
		return status(courseScheduleRepliedService.removeByIds(StringUtil.toLongList(ids)));
	}
}