后端接口
FrontBannerCon
package jkw.controller.front;
import jkw.pojo.Banner;
import jkw.service.BannerService;
import jkw.vo.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 轮播图前台控制器
*/
@CrossOrigin
@RequestMapping("/front/banner")
@RestController
public class FrontBannerCon {
@Autowired
private BannerService bannerService;
/**
* 根据轮播图类型查找轮播图
*
* @param bannerTypeId
* @return
*/
@RequestMapping("/findByTypeId")
public BaseResult findByTypeId(Integer bannerTypeId) {
List bannerList = bannerService.findByTypeId(bannerTypeId);
return BaseResult.ok(bannerList);
}
}
FrontBlogCon
package jkw.controller.front;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jkw.pojo.Blog;
import jkw.pojo.BlogColumn;
import jkw.pojo.BlogTag;
import jkw.service.BlogService;
import jkw.vo.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 前台博客控制器
*/
@CrossOrigin
@RestController
@RequestMapping("/front/blog")
public class FrontBlogCon {
@Autowired
private BlogService blogService;
/**
* 新增
*
* @param blog
* @return
*/
@PostMapping("/add")
public BaseResult add(Blog blog) {
blogService.add(blog);
return BaseResult.ok();
}
/**
* 修改
*
* @param blog
* @return
*/
@PostMapping("/update")
public BaseResult update(Blog blog) {
blogService.update(blog);
return BaseResult.ok();
}
/**
* 删除
*
* @param blogId
* @return
*/
@DeleteMapping("/delete")
public BaseResult delete(Integer blogId) {
blogService.delete(blogId);
return BaseResult.ok();
}
/**
* 根据id查询
*
* @param blogId
* @return
*/
@GetMapping("/findById")
public BaseResult findById(Integer blogId) {
Blog blog = blogService.findById(blogId);
return BaseResult.ok(blog);
}
/**
* 分页查询【状态为true】
*
* @param page
* @param size
* @return
*/
@GetMapping("/search")
public BaseResult search(String search, int page, int size) {
Page brandPage = blogService.searchForStatus(search, page, size);
return BaseResult.ok(brandPage);
}
/**
* 根据用户名分页查找博客文章
*
* @param page
* @param size
* @return
*/
@GetMapping("/searchByUserId")
public BaseResult search(Integer userId, int page, int size) {
Page brandPage = blogService.searchByUserId(userId, page, size);
return BaseResult.ok(brandPage);
}
/**
* 添加博客_专栏中间表的数据
*
* @param blogId 博客id
* @param blogColumnId 专栏id
* @return
*/
@PostMapping("/addColumn")
public BaseResult addColumn(Integer blogId, Integer blogColumnId) {
blogService.addBlog_column(blogId, blogColumnId);
return BaseResult.ok();
}
/**
* 删除博客_专栏中间表的数据
*
* @param blogId 博客id
* @param blogColumnId 专栏id
* @return
*/
@DeleteMapping("/deleteColumn")
public BaseResult deleteColumn(Integer blogId, Integer blogColumnId) {
blogService.deleteBlog_column(blogId, blogColumnId);
return BaseResult.ok();
}
/**
* 根据博客id查询博客_专栏中间表的专栏数据
*
* @param blogId
* @return
*/
@GetMapping("/findColumnByBlogId")
public BaseResult findColumnByBlogId(Integer blogId) {
List blogColumnList = blogService.findColumnByBlogId(blogId);
return BaseResult.ok(blogColumnList);
}
/**
* 添加博客_标签中间表的数据
*
* @param blogId 博客id
* @param blogTagId 标签id
* @return
*/
@PostMapping("/addTag")
public BaseResult addTag(Integer blogId, Integer blogTagId) {
blogService.addBlog_tag(blogId, blogTagId);
return BaseResult.ok();
}
/**
* 删除博客_标签中间表的数据
*
* @param blogId 博客id
* @param blogTagId 标签id
* @return
*/
@DeleteMapping("/deleteTag")
public BaseResult deleteTag(Integer blogId, Integer blogTagId) {
blogService.deleteBlog_tag(blogId, blogTagId);
return BaseResult.ok();
}
/**
* 根据博客id查询博客_标签中间表的标签数据
*
* @param blogId
* @return
*/
@GetMapping("/findTagByBlogId")
public BaseResult findTagByBlogId(Integer blogId) {
List blogTagList = blogService.findTagByBlogId(blogId);
return BaseResult.ok(blogTagList);
}
}
FrontGoodsCon
package jkw.controller.front;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jkw.pojo.Goods;
import jkw.service.GoodsService;
import jkw.vo.BaseResult;
import jkw.vo.GoodsDesc;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
@RestController
@CrossOrigin
@RequestMapping("/front/goods")
public class FrontGoodsCon {
@Autowired
private GoodsService goodsService;
/**
* 分页查询上架的商品
*
* @param search
* @param page
* @param size
* @return
*/
@GetMapping("/search")
public BaseResult search(String search, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int size) {
Page goodsPage = goodsService.search(search, page, size);
List goodsList = new ArrayList<>();
List records = goodsPage.getRecords();
for (Goods record : records) {
if (record.getGoodsUse().equals("1")) {
goodsList.add(record);
}
}
goodsPage.setRecords(goodsList);
return BaseResult.ok(goodsPage);
}
/**
* 查询所有上架的商品
*
* @return
*/
@GetMapping("/findAll")
public BaseResult findAll() {
List allgoods = goodsService.findAll();
List goodsList = new ArrayList<>();
for (Goods goods : allgoods) {
if (goods.getGoodsUse().equals("1")) {
goodsList.add(goods);
}
}
return BaseResult.ok(goodsList);
}
/**
* 查询商品详情
*
* @param goodsId
* @return
*/
@GetMapping("/findDesc")
public BaseResult findDesc(Integer goodsId) {
GoodsDesc goodsDesc = goodsService.findDescById(goodsId);
return BaseResult.ok(goodsDesc);
}
/**
* 根据二级类型查询商品
*
* @param id
* @return
*/
@GetMapping("findByType2")
public BaseResult findByType2(Integer id) {
List allgoods = goodsService.findByType2(id);
List goodsList = new ArrayList<>();
for (Goods goods : allgoods) {
if (goods.getGoodsUse().equals("1")) {
goodsList.add(goods);
}
}
return BaseResult.ok(goodsList);
}
/**
* 根据三级类型查询商品
*
* @param id
* @return
*/
@GetMapping("findByType3")
public BaseResult findByType3(Integer id) {
List allgoods = goodsService.findByType3(id);
List goodsList = new ArrayList<>();
for (Goods goods : allgoods) {
if (goods.getGoodsUse().equals("1")) {
goodsList.add(goods);
}
}
return BaseResult.ok(goodsList);
}
}
FrontGoodsType
package jkw.controller.front;
import jkw.pojo.GoodsType;
import jkw.service.GoodsTypeService;
import jkw.vo.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@CrossOrigin
@RequestMapping("/front/goodsType")
public class FrontGoodsType {
@Autowired
private GoodsTypeService goodsTypeService;
/**
* 查询所有二级分类
* @return
*/
@GetMapping("/findAllTwo")
public BaseResult findAllTwo() {
List goodsTypeList = goodsTypeService.findAllTwo();
return BaseResult.ok(goodsTypeList);
}
/**
* 查询所有三级分类
* @return
*/
@GetMapping("/findAllThree")
public BaseResult findAllThree() {
List goodsTypeList = goodsTypeService.findAllThree();
return BaseResult.ok(goodsTypeList);
}
/**
* 根据父级id查询对应所有子级别
* @param id
* @return
*/
@GetMapping("/findAllByParentId")
public BaseResult findAllByParentId(Integer id) {
List goodsTypes = goodsTypeService.findAllByParentId(id);
return BaseResult.ok(goodsTypes);
}
}
FrontMusicCon
package jkw.controller.front;
import jkw.pojo.Music;
import jkw.service.MusicService;
import jkw.vo.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 前台音乐控制器
*/
@CrossOrigin
@RestController
@RequestMapping("/front/music")
public class FrontMusicCon {
@Autowired
private MusicService musicService;
/**
* 查询所有
*
* @return
*/
@GetMapping("/findAll")
public BaseResult findAll() {
List all = musicService.findAll();
return BaseResult.ok(all);
}
}
FrontUserCon
package jkw.controller.front;
import jkw.pojo.User;
import jkw.service.MessageService;
import jkw.service.UserService;
import jkw.utils.RandomUtil;
import jkw.vo.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* 前台用户控制器
*/
@RestController
@CrossOrigin
@RequestMapping("/front/user")
public class FrontUserCon {
@Autowired
private UserService userService;
@Autowired
private MessageService messageService;
/**
* 复杂【手机号注册】--发送注册短信
*
* @param phone 注册手机号
* @return 操作结果
*/
@GetMapping("/sendMessage")
public BaseResult sendMessage(String phone) {
// 1.生成随机四位数
String checkCode = RandomUtil.buildCheckCode(4);
// 2.发送短信
BaseResult result = messageService.sendMessage(phone, checkCode);
// 3.发送成功,将验证码保存到redis中,发送失败,返回发送结果
if (200 == result.getCode()) {
userService.saveRegisterCheckCode(phone, checkCode);
return BaseResult.ok();
} else {
return result;
}
}
/**
* 复杂【手机号注册】--验证用户注册验证码
*
* @param phone 手机号
* @param checkCode 验证码
* @return 200验证成功,605验证码不正确
*/
@GetMapping("/registerCheckCode")
public BaseResult register(String phone, String checkCode) {
userService.registerCheckCode(phone, checkCode);
return BaseResult.ok();
}
/**
* 复杂【手机号注册】--用户注册
*
* @param user 用户信息
* @return 注册结果
*/
@PostMapping("/register")
public BaseResult register(User user) {
userService.register(user);
return BaseResult.ok();
}
/**
* 复杂【手机号登录】--发送登录短信验证码
*
* @param phone 手机号
* @return 操作结果
*/
@GetMapping("/sendLoginCheckCode")
public BaseResult sendLoginCheckCode(String phone) {
// 1.生成随机四位数
String checkCode = RandomUtil.buildCheckCode(4);
// 2.发送短信
BaseResult result = messageService.sendMessage(phone, checkCode);
// 3.发送成功,将验证码保存到redis中,发送失败,返回发送结果
if (200 == result.getCode()) {
userService.saveLoginCheckCode(phone, checkCode);
return BaseResult.ok();
} else {
return result;
}
}
/**
* 复杂【手机号登录】--手机号验证码登录
*
* @param phone 手机号
* @param checkCode 验证码
* @return 登录结果
*/
@PostMapping("/loginCheckCode")
public BaseResult loginCheckCode(String phone, String checkCode) {
String token = userService.loginCheckCode(phone, checkCode);
return BaseResult.ok(token);
}
/**
* 用户名密码登录
*
* @param user 用户对象
* @return 登录结果
*/
@PostMapping("/loginPassword")
public BaseResult loginPassword(User user) {
String token = userService.loginPassword(user.getUsername(), user.getPassword());
return BaseResult.ok(token);
}
/**
* 获取登录用户
*
* @param token 令牌
* @return 用户名
*/
@GetMapping("/getUser")
public BaseResult getUser(String token) {
User u = userService.getLoginUser(token);
return BaseResult.ok(u);
}
/**
* 根据id查询
*
* @param userId
* @return
*/
@GetMapping("/findById")
public BaseResult findById(Integer userId) {
User user = userService.findById(userId);
return BaseResult.ok(user);
}
}
FrontUserTypeCon
package jkw.controller.back;
import jkw.pojo.UserType;
import jkw.service.UserTypeService;
import jkw.vo.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* VIP等级控控制器
*/
@CrossOrigin
@RestController
@RequestMapping("/front/userType")
public class FrontUserTypeCon {
@Autowired
private UserTypeService userTypeService;
/**
* 查询所有VIP等级
*
* @return
*/
@GetMapping("/findAll")
public BaseResult findAll() {
List all = userTypeService.findAll();
return BaseResult.ok(all);
}
/**
* 根据用户id查询用户_用户类型中间表的专栏数据
*
* @param userId
* @return
*/
@GetMapping("/findUserTypeByUserId")
public BaseResult findColumnByBlogId(Integer userId) {
List userTypeByUserId = userTypeService.findUserTypeByUserId(userId);
return BaseResult.ok(userTypeByUserId);
}
}
FrontWebsiteCon
package jkw.controller.front;
import jkw.pojo.Website;
import jkw.pojo.WebsiteType;
import jkw.service.WebsiteService;
import jkw.service.WebsiteTypeService;
import jkw.vo.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 前台网址控制器
*/
@RequestMapping("/front/website")
@RestController
@CrossOrigin
public class FrontWebsiteCon {
@Autowired
private WebsiteService websiteService;
@Autowired
private WebsiteTypeService websiteTypeService;
/**
* 查询所有网站类型以及对应的网站
*
* @return
*/
@GetMapping("/findAllTypes")
public BaseResult findAllTypeWithWebsite() {
List websiteTypeList = websiteTypeService.findAll();
for (WebsiteType websiteType : websiteTypeList) {
List websiteList = websiteService.findAllByWebsiteTypeId(websiteType.getWebsiteTypeId());
websiteType.setWebsites(websiteList);
}
return BaseResult.ok(websiteTypeList);
}
}
前端模块
首页模块【正在开发】
博客模块
课程模块【正在开发】
商城模块