栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

《谷粒在线教育》后台管理前台轮播图

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

《谷粒在线教育》后台管理前台轮播图

《谷粒在线教育》后台管理前台轮播图 项目架构:

前端效果展示就不实现轮播上线展示下线了





后端代码 BannerAdminController:简单的common操作
package com.education.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.education.commonutils.R;
import com.education.entity.CrmBanner;
import com.education.entity.Vo.BannerQuery;
import com.education.service.Impl.BannerServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(description = "轮播图管理")
@CrossOrigin
@RestController
@RequestMapping("/eduBanner/admin")
public class BannerAdminController {

    @Autowired
    private BannerServiceImpl bannerService;


    @ApiOperation("查询全部轮播图")
    @GetMapping("/findAllBanner")
    public R findAllBanner() {
        List allBanner = bannerService.findAllBanner();
        return R.ok().data("bannerList", allBanner);
    }

    @ApiOperation("分页查询轮播图")
    @GetMapping("/pageBanner/{current}/{limit}")
    public R pageBanner(@ApiParam(value = "起始页", required = true)
                        @PathVariable("current") Long current,
                        @ApiParam(value = "末页", required = true)
                        @PathVariable("limit") Long limit) {
        Page bannerPage = new Page<>(current, limit);
        bannerService.page(bannerPage, null);
        return R.ok().data("bannerList", bannerPage.getRecords()).data("total", bannerPage.getTotal());
    }

    @ApiOperation("添加轮播")
    @PostMapping("/addBanner")
    public R addBanner(@RequestBody BannerQuery bannerQuery) {
        bannerService.saveBanner(bannerQuery);
        return R.ok();
    }

    @ApiOperation("删除轮播")
    @DeleteMapping("/deleteBannerBy/{id}")
    public R deleteBannerById(@PathVariable("id") String id) {
        bannerService.removeById(id);
        return R.ok();
    }

    @ApiOperation("根据Id获取轮播")
    @GetMapping("getBannerBy/{id}")
    public R getBannerById(@PathVariable("id") String id) {
        CrmBanner banner = bannerService.getById(id);
        return R.ok().data("bannerInfo", banner);
    }

    @ApiOperation("修改轮播图")
    @PostMapping("/updateBanner")
    public R updateBanner(@RequestBody BannerQuery banner) {
        bannerService.updateBannerById(banner);
        return R.ok();
    }
}

BannerService
package com.education.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.education.entity.CrmBanner;
import com.education.entity.Vo.BannerQuery;

import java.util.List;

public interface BannerService extends IService {
    void saveBanner(BannerQuery bannerQuery);

    void updateBannerById(BannerQuery banner);

    List findAllBanner();

}
BannerServiceImpl
package com.education.service.Impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.education.commonutils.GuLiException;
import com.education.entity.CrmBanner;
import com.education.entity.Vo.BannerQuery;
import com.education.mapper.BannerMapper;
import com.education.service.BannerService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BannerServiceImpl extends ServiceImpl implements BannerService {

    @Override
    public void saveBanner(BannerQuery bannerQuery) {
        CrmBanner banner = new CrmBanner();
        BeanUtils.copyProperties(bannerQuery, banner);
        int insert = baseMapper.insert(banner);
        if (insert == 0) {
            throw new GuLiException(444, "添加轮播信息失败异常");
        }
    }

    @Override
    public void updateBannerById(BannerQuery banner) {
        CrmBanner crmBanner = new CrmBanner();
        BeanUtils.copyProperties(banner, crmBanner);
        int update = baseMapper.updateById(crmBanner);
        if (update == 0) {
            throw new GuLiException(444, "修改轮播信息失败异常");
        }
    }

    @Override
    public List findAllBanner() {
        return baseMapper.selectList(null);
    }
}
前端代码 src/router/index.js
//前台首页轮播图管理
 {
    path: "/banner",
    component: Layout,
    redirect: "/banner/list",
    name: "轮播图管理",
    meta: { title: "轮播图管理", icon: "BannerCommons" },
    children: [
      {
        path: "list",
        name: "轮播图列表",
        component: () => import("@/views/banner/BannerList"),
        meta: { title: "轮播图列表", icon: "BannerLIst" }
      },
      {
        path: "add",
        name: "轮播图展示",
        component: () => import("@/views/banner/BannerList"),
        meta: { title: "轮播图展示", icon: "BannerAdd" }
      }
    ]
},
src/views/banner/BannerList.vue






希望大家指出代码可以优化的地方
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/632493.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号