package org.jeecg.modules.system.app.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.system.app.dto.AppCoursesRuleDTO;
import org.jeecg.modules.system.app.entity.AppCoursesPriceRules;
import org.jeecg.modules.system.app.service.IAppCoursesPriceRulesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description: 课程价格规则表
 * @Author: jeecg-boot
 * @Date:   2025-07-03
 * @Version: V1.0
 */
@Tag(name="课程课时表")
@RestController
@RequestMapping("/app/appCoursesPriceRules")
@Slf4j
public class AppCoursesPriceRulesController extends JeecgController<AppCoursesPriceRules, IAppCoursesPriceRulesService> {
	@Autowired
	private IAppCoursesPriceRulesService appCoursesPriceRulesService;
	
//	/**
//	 * 分页列表查询
//	 *
//	 * @param appCoursesPriceRules
//	 * @param pageNo
//	 * @param pageSize
//	 * @param req
//	 * @return
//	 */
//	//@AutoLog(value = "课程价格规则表-分页列表查询")
//	@Operation(summary="课程价格规则表-分页列表查询")
//	@GetMapping(value = "/list")
//	public Result<IPage<AppCoursesPriceRules>> queryPageList(AppCoursesPriceRules appCoursesPriceRules,
//								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
//								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
//								   HttpServletRequest req) {
//
//
//        QueryWrapper<AppCoursesPriceRules> queryWrapper = QueryGenerator.initQueryWrapper(appCoursesPriceRules, req.getParameterMap());
//		Page<AppCoursesPriceRules> page = new Page<AppCoursesPriceRules>(pageNo, pageSize);
//		IPage<AppCoursesPriceRules> pageList = appCoursesPriceRulesService.page(page, queryWrapper);
//		return Result.OK(pageList);
//	}
//
//	/**
//	 *   添加
//	 *
//	 * @param appCoursesPriceRules
//	 * @return
//	 */
//	@AutoLog(value = "课程价格规则表-添加")
//	@Operation(summary="课程价格规则表-添加")
//	@RequiresPermissions("org.jeecg.modules.app:nm_courses_price_rules:add")
//	@PostMapping(value = "/add")
//	public Result<String> add(@RequestBody AppCoursesPriceRules appCoursesPriceRules) {
//		appCoursesPriceRulesService.save(appCoursesPriceRules);
//
//		return Result.OK("添加成功！");
//	}
//
//	/**
//	 *  编辑
//	 *
//	 * @param appCoursesPriceRules
//	 * @return
//	 */
//	@AutoLog(value = "课程价格规则表-编辑")
//	@Operation(summary="课程价格规则表-编辑")
//	@RequiresPermissions("org.jeecg.modules.app:nm_courses_price_rules:edit")
//	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
//	public Result<String> edit(@RequestBody AppCoursesPriceRules appCoursesPriceRules) {
//		appCoursesPriceRulesService.updateById(appCoursesPriceRules);
//		return Result.OK("编辑成功!");
//	}
//
//	/**
//	 *   通过id删除
//	 *
//	 * @param id
//	 * @return
//	 */
//	@AutoLog(value = "课程价格规则表-通过id删除")
//	@Operation(summary="课程价格规则表-通过id删除")
//	@RequiresPermissions("org.jeecg.modules.app:nm_courses_price_rules:delete")
//	@DeleteMapping(value = "/delete")
//	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
//		appCoursesPriceRulesService.removeById(id);
//		return Result.OK("删除成功!");
//	}
//
//	/**
//	 *  批量删除
//	 *
//	 * @param ids
//	 * @return
//	 */
//	@AutoLog(value = "课程价格规则表-批量删除")
//	@Operation(summary="课程价格规则表-批量删除")
//	@RequiresPermissions("org.jeecg.modules.app:nm_courses_price_rules:deleteBatch")
//	@DeleteMapping(value = "/deleteBatch")
//	public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
//		this.appCoursesPriceRulesService.removeByIds(Arrays.asList(ids.split(",")));
//		return Result.OK("批量删除成功!");
//	}
//
	/**
	 * 通过id查询
	 *
	 * @param coursesId
	 * @return
	 */
	//@AutoLog(value = "课程价格规则表-通过id查询")
	@Operation(summary="课程价格规则表-通过课程id查询")
	@GetMapping(value = "/queryListByCoursesId")
	public Result<List<AppCoursesRuleDTO>> queryListByCoursesId(@RequestParam(name="id",required=true) String coursesId,@RequestParam(name="coursesType",required=true) Integer coursesType) {
		return Result.OK(appCoursesPriceRulesService.queryCoursesPriceRulesList(coursesId,coursesType));
	}

	/**
	 * 补课列表编辑
	 *
	 * @param dtoList
	 * @return
	 */
	//@AutoLog(value = "课程价格规则表-通过id查询")
	@Operation(summary="课程价格规则表-补课列表编辑")
	@PostMapping(value = "/editPriceRules")
	public Result<String> editPriceRules(@RequestBody List<AppCoursesRuleDTO> dtoList) {
		return appCoursesPriceRulesService.editWitchPriceRules(dtoList)?Result.OK("操作成功"):Result.error("保存失败");
	}
//
//    /**
//    * 导出excel
//    *
//    * @param request
//    * @param appCoursesPriceRules
//    */
//    @RequiresPermissions("org.jeecg.modules.app:nm_courses_price_rules:exportXls")
//    @RequestMapping(value = "/exportXls")
//    public ModelAndView exportXls(HttpServletRequest request, AppCoursesPriceRules appCoursesPriceRules) {
//        return super.exportXls(request, appCoursesPriceRules, AppCoursesPriceRules.class, "课程价格规则表");
//    }
//
//    /**
//      * 通过excel导入数据
//    *
//    * @param request
//    * @param response
//    * @return
//    */
//    @RequiresPermissions("org.jeecg.modules.app:nm_courses_price_rules:importExcel")
//    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
//    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
//        return super.importExcel(request, response, AppCoursesPriceRules.class);
//    }

}
