From e421b95541e2796a7c7b2cee7930fe27f9a33d1d Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期五, 21 三月 2025 15:38:17 +0800
Subject: [PATCH] 冥想
---
xinquan-modules/xinquan-system/src/main/java/com/xinquan/system/controller/BannerController.java | 125 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 123 insertions(+), 2 deletions(-)
diff --git a/xinquan-modules/xinquan-system/src/main/java/com/xinquan/system/controller/BannerController.java b/xinquan-modules/xinquan-system/src/main/java/com/xinquan/system/controller/BannerController.java
index c0cf144..d5eb4c5 100644
--- a/xinquan-modules/xinquan-system/src/main/java/com/xinquan/system/controller/BannerController.java
+++ b/xinquan-modules/xinquan-system/src/main/java/com/xinquan/system/controller/BannerController.java
@@ -1,9 +1,25 @@
package com.xinquan.system.controller;
-import org.springframework.web.bind.annotation.RequestMapping;
+import com.xinquan.common.core.domain.R;
+import com.xinquan.common.core.utils.page.PageDTO;
+import com.xinquan.common.log.annotation.Log;
+import com.xinquan.common.log.enums.BusinessType;
+import com.xinquan.course.api.domain.Course;
+import com.xinquan.course.api.domain.CourseCategory;
+import com.xinquan.course.api.domain.CourseDTO;
+import com.xinquan.course.api.feign.RemoteCourseService;
+import com.xinquan.system.domain.Banner;
+import com.xinquan.system.service.BannerService;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
-import org.springframework.web.bind.annotation.RestController;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
/**
* <p>
@@ -17,5 +33,110 @@
@RequestMapping("/system/banner")
public class BannerController {
+ @Autowired
+ private BannerService bannerService;
+ @Autowired
+ private RemoteCourseService remoteCourseService;
+
+ @PostMapping("/bannerList")
+ @ApiOperation(value = "获取banner列表-分页",tags = "管理后台banner")
+ @ApiImplicitParams({
+ @ApiImplicitParam(value = "分页参数,当前页码", name = "pageCurr", required = true, dataType = "Integer"),
+ @ApiImplicitParam(value = "分页参数,每页数量", name = "pageSize", required = true, dataType = "Integer")
+ })
+ public R<PageDTO<Banner>> bannerList(
+ @RequestParam(value = "pageCurr", defaultValue = "1") Integer pageCurr,
+ @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
+ return R.ok(bannerService.bannerList(pageCurr, pageSize));
+ }
+ @PostMapping("/cateList")
+ @ApiOperation(value = "课程分类下拉选择列表-不分页",tags = "管理后台banner")
+
+ public R<List<CourseCategory>> cateList() {
+ List<CourseCategory> data = remoteCourseService.cateList().getData();
+ return R.ok(data);
+ }
+ @GetMapping("/courseList")
+ @ApiOperation(value = "选择课程-分页",tags = "管理后台banner")
+ @ApiImplicitParams({
+ @ApiImplicitParam(value = "分页参数,当前页码", name = "pageCurr", required = false, dataType = "Integer"),
+ @ApiImplicitParam(value = "分页参数,每页数量", name = "pageSize", required = false, dataType = "Integer"),
+ @ApiImplicitParam(value = "课程类型1线上2线下", name = "courseType", required = false, dataType = "Integer"),
+ @ApiImplicitParam(value = "课程分类id", name = "cateId", required = false, dataType = "Long"),
+ @ApiImplicitParam(value = "课程标题", name = "courseTitle", required = false, dataType = "String"),
+ @ApiImplicitParam(value = "导师名称", name = "tutor", required = false, dataType = "String"),
+ })
+ public R<PageDTO<Course>> courseList(
+ Integer pageCurr,
+ Integer pageSize,
+ Integer courseType,
+ Long cateId,
+ String courseTitle,
+
+ String tutor
+ ) {
+ CourseDTO courseDTO = new CourseDTO();
+ courseDTO.setPageCurr(pageCurr);
+ courseDTO.setPageSize(pageSize);
+ courseDTO.setCourseType(courseType);
+ courseDTO.setCateId(cateId);
+ courseDTO.setCourseTitle(courseTitle);
+ courseDTO.setTutor(tutor);
+ PageDTO<Course> data = remoteCourseService.courseList(courseDTO).getData();
+ return R.ok(data);
+ }
+ @PostMapping("/deleteBatch")
+ @ApiOperation(value = "批量删除banner",tags = "管理后台banner")
+ @ApiImplicitParams({
+ @ApiImplicitParam(value = "ids", name = "ids", required = true, dataType = "String"),
+ })
+ @Log(title = "【banner】批量删除", businessType = BusinessType.DELETE)
+
+ public R deleteBatch(
+ @RequestParam(value = "ids") String ids)
+ {
+ List<Long> list = Arrays.asList(ids.split(",")).stream().map(Long::valueOf).collect(Collectors.toList());
+ bannerService.removeBatchByIds(list);
+ return R.ok();
+ }
+ @PostMapping("/addBanner")
+ @ApiOperation(value = "添加banner",tags = "管理后台banner")
+ @Log(title = "【banner】添加", businessType = BusinessType.INSERT)
+
+ public R addBanner(@RequestBody Banner banner)
+ {
+ bannerService.save(banner);
+ return R.ok();
+ }
+ @PostMapping("/updateBanner")
+ @ApiOperation(value = "修改banner",tags = "管理后台banner")
+ @Log(title = "【banner】修改", businessType = BusinessType.UPDATE)
+ public R updateBanner(@RequestBody Banner banner)
+ {
+ bannerService.updateById(banner);
+ return R.ok();
+ }
+ @PostMapping("/bannerDetail")
+ @ApiOperation(value = "查看详情",tags = "管理后台banner")
+
+ public R<Banner> bannerDetail(String uid)
+ {
+ Banner byId = bannerService.getById(uid);
+ if (byId.getCourseId()!=null){
+ Course data = remoteCourseService.getCourseById(byId.getCourseId()).getData();
+ if (data!=null){
+ byId.setCourseTitle(data.getCourseTitle());
+ byId.setCoverUrl(data.getCoverUrl());
+ byId.setTutor(data.getTutor());
+ byId.setPrice(data.getGeneralPrice());
+ if (data.getCateId()!=null){
+ CourseCategory data1 = remoteCourseService.getCategoryById(data.getCateId().toString()).getData();
+ byId.setCate(data1.getName());
+ }
+ }
+ }
+ return R.ok(byId);
+ }
+
}
--
Gitblit v1.7.1