From 77673e42c6c99825a68f133518fa0d5e1d10b4bf Mon Sep 17 00:00:00 2001 From: "@t2652009480" <2652009480@qq.com> Date: Fri, 11 Aug 2023 13:14:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=94=E7=94=A8=E4=B8=AD=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AcademicController.java | 65 +++++++++ .../zhiyun03/academic/entity/Academic.java | 2 +- .../academic/service/AcademicService.java | 12 ++ .../service/impl/AcademicServiceImpl.java | 122 +++++++++++++++++ .../zhiyun03/academic/vo/AcademicVo.java | 44 ++++++ .../controller/ApplicationController.java | 26 ++-- .../application/entity/Application.java | 2 +- .../application/entity/Directory.java | 2 +- .../service/ApplicationService.java | 7 +- .../service/impl/ApplicationServiceImpl.java | 21 +-- .../application/vo/ApplicationVo.java | 2 +- .../zhiyun03/download/entity/Download.java | 2 +- .../game/controller/GameController.java | 70 ++++++++++ .../com/zhiyun/zhiyun03/game/entity/Game.java | 2 +- .../zhiyun03/game/service/GameService.java | 13 ++ .../game/service/impl/GameServiceImpl.java | 122 +++++++++++++++++ .../com/zhiyun/zhiyun03/game/vo/GameVo.java | 50 +++++++ .../zhiyun/zhiyun03/invite/entity/Invite.java | 2 +- .../controller/KnowledgeController.java | 64 +++++++++ .../zhiyun03/knowledge/entity/Knowledge.java | 2 +- .../knowledge/service/KnowledgeService.java | 11 ++ .../service/impl/KnowledgeServiceImpl.java | 126 ++++++++++++++++++ .../zhiyun03/knowledge/vo/KnowledgeVo.java | 44 ++++++ .../zhiyun/zhiyun03/serve/entity/Serve.java | 2 +- .../textual/controller/TextualController.java | 63 +++++++++ .../zhiyun03/textual/entity/Textual.java | 2 +- .../textual/service/TextualService.java | 11 ++ .../service/impl/TextualServiceImpl.java | 122 +++++++++++++++++ .../zhiyun/zhiyun03/textual/vo/TextualVo.java | 44 ++++++ .../utils/config/GlobalCrossConfig.java | 33 +++++ .../layui-v2.6.8/applicationList.html | 80 +++++++++++ .../templates/layui-v2.6.8/courseList.html | 2 +- 32 files changed, 1141 insertions(+), 31 deletions(-) create mode 100644 src/main/java/com/zhiyun/zhiyun03/academic/vo/AcademicVo.java create mode 100644 src/main/java/com/zhiyun/zhiyun03/game/vo/GameVo.java create mode 100644 src/main/java/com/zhiyun/zhiyun03/knowledge/vo/KnowledgeVo.java create mode 100644 src/main/java/com/zhiyun/zhiyun03/textual/vo/TextualVo.java create mode 100644 src/main/java/com/zhiyun/zhiyun03/utils/config/GlobalCrossConfig.java create mode 100644 src/main/resources/templates/layui-v2.6.8/applicationList.html diff --git a/src/main/java/com/zhiyun/zhiyun03/academic/controller/AcademicController.java b/src/main/java/com/zhiyun/zhiyun03/academic/controller/AcademicController.java index 75ba604..f4b068a 100644 --- a/src/main/java/com/zhiyun/zhiyun03/academic/controller/AcademicController.java +++ b/src/main/java/com/zhiyun/zhiyun03/academic/controller/AcademicController.java @@ -1,4 +1,69 @@ package com.zhiyun.zhiyun03.academic.controller; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.zhiyun.zhiyun03.academic.service.AcademicService; +import com.zhiyun.zhiyun03.academic.vo.AcademicVo; +import com.zhiyun.zhiyun03.game.vo.GameVo; +import com.zhiyun.zhiyun03.utils.common.JsonResult; +import com.zhiyun.zhiyun03.utils.common.ResultCode; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +@RestController +@RequestMapping("/academic") +@Api("学术中心") public class AcademicController { + @Resource + AcademicService academicService; + + @RequestMapping("/queryAcademic") + @ApiOperation("查询学术信息") + public JsonResult queryAcademic(@RequestParam(name="page") Integer page, + @RequestParam(name="limit") Integer limit){ + Page academicVoPage = academicService.queryAcademic(page,limit); + return JsonResult.success(academicVoPage); + } + + @RequestMapping("/addAcademic") + @ApiOperation("新增学术信息") + public JsonResult addAcademic(@RequestBody AcademicVo academicVo){ + int result = academicService.addAcademic(academicVo); + if(result>0){ + return JsonResult.success(ResultCode.SUCCESS); + } + return JsonResult.success(ResultCode.Fail); + } + + @RequestMapping("/selectByIdAcademic") + @ApiOperation("根据id查询学术信息") + public JsonResult selectByIdAcademic(Integer id){ + AcademicVo academicVo = academicService.selectByIdAcademic(id); + return JsonResult.success(academicVo); + } + + @RequestMapping("/updateAcademic") + @ApiOperation("更新学术信息") + public JsonResult updateAcademic(@RequestBody AcademicVo academicVo){ + int result = academicService.updateAcademic(academicVo); + if(result>0){ + return JsonResult.success(ResultCode.SUCCESS); + } + return JsonResult.success(ResultCode.Fail); + } + + @RequestMapping("/deleteAcademic") + @ApiOperation("删除学术信息") + public JsonResult deleteAcademic(Integer id){ + int result = academicService.deleteAcademic(id); + if(result>0){ + return JsonResult.success(ResultCode.SUCCESS); + } + return JsonResult.success(ResultCode.Fail); + } } diff --git a/src/main/java/com/zhiyun/zhiyun03/academic/entity/Academic.java b/src/main/java/com/zhiyun/zhiyun03/academic/entity/Academic.java index 0961f9d..610e76d 100644 --- a/src/main/java/com/zhiyun/zhiyun03/academic/entity/Academic.java +++ b/src/main/java/com/zhiyun/zhiyun03/academic/entity/Academic.java @@ -21,7 +21,7 @@ public class Academic { * id */ @TableId(value = "id",type = IdType.AUTO) - private int id; + private Integer id; /** * 学术名称 diff --git a/src/main/java/com/zhiyun/zhiyun03/academic/service/AcademicService.java b/src/main/java/com/zhiyun/zhiyun03/academic/service/AcademicService.java index dfa2593..8314912 100644 --- a/src/main/java/com/zhiyun/zhiyun03/academic/service/AcademicService.java +++ b/src/main/java/com/zhiyun/zhiyun03/academic/service/AcademicService.java @@ -1,7 +1,19 @@ package com.zhiyun.zhiyun03.academic.service; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.zhiyun.zhiyun03.academic.entity.Academic; +import com.zhiyun.zhiyun03.academic.vo.AcademicVo; +import com.zhiyun.zhiyun03.game.vo.GameVo; public interface AcademicService extends IService { + Page queryAcademic(Integer page,Integer limit); + + int addAcademic(AcademicVo academicVo); + + AcademicVo selectByIdAcademic(Integer id); + + int updateAcademic(AcademicVo academicVo); + + int deleteAcademic(Integer id); } diff --git a/src/main/java/com/zhiyun/zhiyun03/academic/service/impl/AcademicServiceImpl.java b/src/main/java/com/zhiyun/zhiyun03/academic/service/impl/AcademicServiceImpl.java index 4303ea9..ef1dd41 100644 --- a/src/main/java/com/zhiyun/zhiyun03/academic/service/impl/AcademicServiceImpl.java +++ b/src/main/java/com/zhiyun/zhiyun03/academic/service/impl/AcademicServiceImpl.java @@ -1,11 +1,133 @@ package com.zhiyun.zhiyun03.academic.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.zhiyun.zhiyun03.academic.entity.Academic; import com.zhiyun.zhiyun03.academic.mapper.AcademicMapper; import com.zhiyun.zhiyun03.academic.service.AcademicService; +import com.zhiyun.zhiyun03.academic.vo.AcademicVo; +import com.zhiyun.zhiyun03.application.entity.Directory; +import com.zhiyun.zhiyun03.application.mapper.DirectoryMapper; +import com.zhiyun.zhiyun03.game.entity.Game; +import com.zhiyun.zhiyun03.game.vo.GameVo; +import com.zhiyun.zhiyun03.utils.convert.ConvertUtil; +import com.zhiyun.zhiyun03.utils.convert.Switch; import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; + @Service public class AcademicServiceImpl extends ServiceImpl implements AcademicService { + + @Resource + AcademicMapper academicMapper; + + @Resource + DirectoryMapper directoryMapper; + + /** + * 学术信息查询 + */ + @Override + public Page queryAcademic(Integer page,Integer limit) { + Page page1=new Page(); + page1.setCurrent(limit); + page1.setSize(page); + QueryWrapper qwa=new QueryWrapper<>(); + Page academicPage = academicMapper.selectPage(page1,qwa); + //查询目录 + QueryWrapper qwd=new QueryWrapper<>(); + List directories = directoryMapper.selectList(qwd); + + ConvertUtil convertUtil=new ConvertUtil(); +// 将实体类转换成vo类 + List academicVos = convertUtil.entityToVoList(academicPage.getRecords(), AcademicVo.class); + for (int i = 0; i < academicPage.getRecords().size(); i++) { + for (int j = 0; j pageVo=new Page<>(); + //将List转成page并返回 + Switch aSwitch=new Switch(); + aSwitch.ListToPage(pageVo,academicVos); + return pageVo; + } + + /** + * 学术信息新增 + */ + @Override + public int addAcademic(AcademicVo academicVo) { + //将vo类转换为实体类 + ConvertUtil convertUtil=new ConvertUtil(); + Academic academic = convertUtil.VoToEntity(academicVo, Academic.class); + //根据目录名称查询目录id + QueryWrapper qwd=new QueryWrapper<>(); + qwd.lambda().eq(Directory::getDirName,academicVo.getDirName()); + Directory directory = directoryMapper.selectOne(qwd); + //将目录id封装到实体类 + academic.setDirId(directory.getId()); + academic.setAcademicAddtime(new Date()); + int insert = academicMapper.insert(academic); + return insert; + } + + /** + * 根据id查询学术信息 + */ + @Override + public AcademicVo selectByIdAcademic(Integer id) { + //根据id查询大赛中心 + QueryWrapper qwa=new QueryWrapper<>(); + qwa.lambda().eq(Academic::getId,id); + Academic academic= academicMapper.selectOne(qwa); + //查询目录 + QueryWrapper qwd=new QueryWrapper<>(); + qwd.lambda().eq(Directory::getId,academic.getDirId()); + Directory directory = directoryMapper.selectOne(qwd); + ConvertUtil convertUtil=new ConvertUtil(); + AcademicVo academicVo = convertUtil.entityToVo(academic, AcademicVo.class); + //给目录名称赋值 + academicVo.setDirName(directory.getDirName()); + return academicVo; + } + + /** + * 学术信息更新 + */ + @Override + public int updateAcademic(AcademicVo academicVo) { + //将vo类转换为实体类 + ConvertUtil convertUtil=new ConvertUtil(); + Academic academic = convertUtil.VoToEntity(academicVo, Academic.class); + //根据目录名称查询目录id + QueryWrapper qwd=new QueryWrapper<>(); + qwd.lambda().eq(Directory::getDirName,academicVo.getDirName()); + Directory directory = directoryMapper.selectOne(qwd); + //将目录id封装到实体类 + academic.setDirId(directory.getId()); + academic.setAcademicUpdatetime(new Date()); + int update = academicMapper.updateById(academic); + return update; + } + + /** + * 学术信息删除 + */ + @Override + public int deleteAcademic(Integer id) { + if(id!=null){ + int delete = academicMapper.deleteById(id); + return delete; + } + return 0; + } } diff --git a/src/main/java/com/zhiyun/zhiyun03/academic/vo/AcademicVo.java b/src/main/java/com/zhiyun/zhiyun03/academic/vo/AcademicVo.java new file mode 100644 index 0000000..2d0097a --- /dev/null +++ b/src/main/java/com/zhiyun/zhiyun03/academic/vo/AcademicVo.java @@ -0,0 +1,44 @@ +package com.zhiyun.zhiyun03.academic.vo; + +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModel; +import lombok.Data; + + +@Data +@ApiModel("学术中心") +public class AcademicVo { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId + private Integer id; + + /** + * 学术名称 + */ + private String academicName; + + /** + * 学术简介 + */ + private String academicBiref; + + /** + * 学术链接 + */ + private String academicUrl; + + /** + * 目录名称 + */ + private String dirName; + + /** + * 学术图片 + */ + private String academicImg; + +} diff --git a/src/main/java/com/zhiyun/zhiyun03/application/controller/ApplicationController.java b/src/main/java/com/zhiyun/zhiyun03/application/controller/ApplicationController.java index 366ad1f..ab394a5 100644 --- a/src/main/java/com/zhiyun/zhiyun03/application/controller/ApplicationController.java +++ b/src/main/java/com/zhiyun/zhiyun03/application/controller/ApplicationController.java @@ -8,15 +8,15 @@ import com.zhiyun.zhiyun03.application.service.ApplicationService; import com.zhiyun.zhiyun03.application.vo.ApplicationVo; import com.zhiyun.zhiyun03.utils.common.JsonResult; import com.zhiyun.zhiyun03.utils.common.ResultCode; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.annotation.ApplicationScope; import javax.annotation.Resource; import java.util.List; +@Api("应用中心") @RestController @RequestMapping("/application") public class ApplicationController { @@ -24,19 +24,23 @@ public class ApplicationController { ApplicationService applicationService; - @RequestMapping("/queryApplication") - public JsonResult queryApplication(@RequestBody Page page){ - Page list = applicationService.queryApplication(page); + @GetMapping ("/queryApplication") + @ApiOperation("查询应用") + public JsonResult queryApplication(@RequestParam(name="page") Integer page, + @RequestParam(name="limit") Integer limit){ + Page list = applicationService.queryApplication(page,limit); return JsonResult.success(list); } @RequestMapping("/queryDir") + @ApiOperation("查询目录") public JsonResult queryDir(){ List list = applicationService.queryDir(); return JsonResult.success(list); } @RequestMapping("/addApplication") + @ApiOperation("新增应用") public JsonResult addApplication(@RequestBody ApplicationVo applicationVo){ int result = applicationService.addApplication(applicationVo); if(result>0){ @@ -46,12 +50,14 @@ public class ApplicationController { } @RequestMapping("/selectByIdApplication") - public JsonResult selectByIdApplication(int id){ + @ApiOperation("根据id查询应用") + public JsonResult selectByIdApplication(Integer id){ ApplicationVo applicationVo = applicationService.selectByIdApplication(id); return JsonResult.success(applicationVo); } @RequestMapping("/updateApplication") + @ApiOperation("更新应用") public JsonResult updateApplication(@RequestBody ApplicationVo applicationVo){ int result = applicationService.updateApplication(applicationVo); if(result>0){ @@ -61,7 +67,8 @@ public class ApplicationController { } @RequestMapping("/deleteApplication") - public JsonResult deleteApplication(int id){ + @ApiOperation("删除应用") + public JsonResult deleteApplication(Integer id){ int result = applicationService.deleteApplication(id); if(result>0){ return JsonResult.success(ResultCode.SUCCESS); @@ -70,6 +77,7 @@ public class ApplicationController { } @RequestMapping("/addDirectory") + @ApiOperation("新增目录") public JsonResult addDirectory(@RequestBody Directory directory){ int result = applicationService.addDirectory(directory); if(result>0){ diff --git a/src/main/java/com/zhiyun/zhiyun03/application/entity/Application.java b/src/main/java/com/zhiyun/zhiyun03/application/entity/Application.java index c439e3b..37e2779 100644 --- a/src/main/java/com/zhiyun/zhiyun03/application/entity/Application.java +++ b/src/main/java/com/zhiyun/zhiyun03/application/entity/Application.java @@ -23,7 +23,7 @@ public class Application { * id */ @TableId(value = "id",type = IdType.AUTO) - private int id; + private Integer id; /** * 应用名称 diff --git a/src/main/java/com/zhiyun/zhiyun03/application/entity/Directory.java b/src/main/java/com/zhiyun/zhiyun03/application/entity/Directory.java index ef93266..c34554e 100644 --- a/src/main/java/com/zhiyun/zhiyun03/application/entity/Directory.java +++ b/src/main/java/com/zhiyun/zhiyun03/application/entity/Directory.java @@ -18,7 +18,7 @@ public class Directory { * id */ @TableId(value ="id") - private int id; + private Integer id; /** * 目录名称 diff --git a/src/main/java/com/zhiyun/zhiyun03/application/service/ApplicationService.java b/src/main/java/com/zhiyun/zhiyun03/application/service/ApplicationService.java index bf7462d..b99ff03 100644 --- a/src/main/java/com/zhiyun/zhiyun03/application/service/ApplicationService.java +++ b/src/main/java/com/zhiyun/zhiyun03/application/service/ApplicationService.java @@ -1,5 +1,6 @@ package com.zhiyun.zhiyun03.application.service; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.zhiyun.zhiyun03.application.entity.Application; @@ -9,17 +10,17 @@ import com.zhiyun.zhiyun03.application.vo.ApplicationVo; import java.util.List; public interface ApplicationService extends IService { - Page queryApplication(Page page); + Page queryApplication(Integer page,Integer limit); int addApplication(ApplicationVo applicationVo); List queryDir(); - ApplicationVo selectByIdApplication(int id); + ApplicationVo selectByIdApplication(Integer id); int updateApplication(ApplicationVo applicationVo); - int deleteApplication(int id); + int deleteApplication(Integer id); int addDirectory(Directory directory); } diff --git a/src/main/java/com/zhiyun/zhiyun03/application/service/impl/ApplicationServiceImpl.java b/src/main/java/com/zhiyun/zhiyun03/application/service/impl/ApplicationServiceImpl.java index 540a227..a1ab75b 100644 --- a/src/main/java/com/zhiyun/zhiyun03/application/service/impl/ApplicationServiceImpl.java +++ b/src/main/java/com/zhiyun/zhiyun03/application/service/impl/ApplicationServiceImpl.java @@ -1,6 +1,7 @@ package com.zhiyun.zhiyun03.application.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.fasterxml.jackson.databind.util.BeanUtil; @@ -34,10 +35,13 @@ public class ApplicationServiceImpl extends ServiceImpl queryApplication(Page page) { + public Page queryApplication(Integer page,Integer limit) { + Page page1=new Page(); + page1.setCurrent(limit); + page1.setSize(page); //查询应用中心 QueryWrapper qwa=new QueryWrapper<>(); - Page applicationPage = applicationMapper.selectPage(page,qwa); + Page applicationPage = applicationMapper.selectPage(page1,qwa); //查询目录 QueryWrapper qwd=new QueryWrapper<>(); List directories = directoryMapper.selectList(qwd); @@ -76,7 +80,7 @@ public class ApplicationServiceImpl extends ServiceImpl qwa=new QueryWrapper<>(); qwa.lambda().eq(Application::getId,id); @@ -103,7 +107,6 @@ public class ApplicationServiceImpl extends ServiceImpl queryGame(@RequestParam(name="page") Integer page, + @RequestParam(name="limit") Integer limit){ + Page gameVos = gameService.queryGame(page,limit); + return JsonResult.success(gameVos); + } + + @RequestMapping("/addGame") + @ApiOperation("新增大赛信息") + public JsonResult addGame(@RequestBody GameVo gameVo){ + int result = gameService.addApplication(gameVo); + if(result>0){ + return JsonResult.success(ResultCode.SUCCESS); + } + return JsonResult.success(ResultCode.Fail); + } + + @RequestMapping("/selectByIdGame") + @ApiOperation("根据id查询大赛信息") + public JsonResult selectByIdGame(Integer id){ + GameVo gameVo = gameService.selectByIdGame(id); + return JsonResult.success(gameVo); + } + + @RequestMapping("/updateGame") + @ApiOperation("更新大赛信息") + public JsonResult updateGame(@RequestBody GameVo gameVo){ + int result = gameService.updateGame(gameVo); + if(result>0){ + return JsonResult.success(ResultCode.SUCCESS); + } + return JsonResult.success(ResultCode.Fail); + } + + @RequestMapping("/deleteGame") + @ApiOperation("删除大赛信息") + public JsonResult deleteGame(Integer id){ + int result = gameService.deleteGame(id); + if(result>0){ + return JsonResult.success(ResultCode.SUCCESS); + } + return JsonResult.success(ResultCode.Fail); + } + } diff --git a/src/main/java/com/zhiyun/zhiyun03/game/entity/Game.java b/src/main/java/com/zhiyun/zhiyun03/game/entity/Game.java index 08fb62f..9c8b00c 100644 --- a/src/main/java/com/zhiyun/zhiyun03/game/entity/Game.java +++ b/src/main/java/com/zhiyun/zhiyun03/game/entity/Game.java @@ -21,7 +21,7 @@ public class Game { * id */ @TableId(value = "id",type = IdType.AUTO) - private int id; + private Integer id; /** * 大赛名称 diff --git a/src/main/java/com/zhiyun/zhiyun03/game/service/GameService.java b/src/main/java/com/zhiyun/zhiyun03/game/service/GameService.java index 4ce2e6a..4e7f64f 100644 --- a/src/main/java/com/zhiyun/zhiyun03/game/service/GameService.java +++ b/src/main/java/com/zhiyun/zhiyun03/game/service/GameService.java @@ -1,7 +1,20 @@ package com.zhiyun.zhiyun03.game.service; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.zhiyun.zhiyun03.game.entity.Game; +import com.zhiyun.zhiyun03.game.vo.GameVo; + +import java.util.List; public interface GameService extends IService { + Page queryGame(Integer page,Integer limit); + + int addApplication(GameVo gameVo); + + GameVo selectByIdGame(Integer id); + + int updateGame(GameVo gameVo); + + int deleteGame(Integer id); } diff --git a/src/main/java/com/zhiyun/zhiyun03/game/service/impl/GameServiceImpl.java b/src/main/java/com/zhiyun/zhiyun03/game/service/impl/GameServiceImpl.java index 66d1cb7..164aba5 100644 --- a/src/main/java/com/zhiyun/zhiyun03/game/service/impl/GameServiceImpl.java +++ b/src/main/java/com/zhiyun/zhiyun03/game/service/impl/GameServiceImpl.java @@ -1,11 +1,133 @@ package com.zhiyun.zhiyun03.game.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.zhiyun.zhiyun03.application.entity.Application; +import com.zhiyun.zhiyun03.application.entity.Directory; +import com.zhiyun.zhiyun03.application.mapper.DirectoryMapper; +import com.zhiyun.zhiyun03.application.vo.ApplicationVo; import com.zhiyun.zhiyun03.game.entity.Game; import com.zhiyun.zhiyun03.game.mapper.GameMapper; import com.zhiyun.zhiyun03.game.service.GameService; +import com.zhiyun.zhiyun03.game.vo.GameVo; +import com.zhiyun.zhiyun03.utils.convert.ConvertUtil; +import com.zhiyun.zhiyun03.utils.convert.Switch; import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; + @Service public class GameServiceImpl extends ServiceImpl implements GameService { + @Resource + GameMapper gameMapper; + + @Resource + DirectoryMapper directoryMapper; + + /** + * 大赛中心查询 + */ + @Override + public Page queryGame(Integer page,Integer limit) { + Page page1=new Page(); + page1.setCurrent(limit); + page1.setSize(page); + //查询大赛中心 + QueryWrapper qwg=new QueryWrapper<>(); + Page gamePage = gameMapper.selectPage(page1,qwg); + //查询目录 + QueryWrapper qwd=new QueryWrapper<>(); + List directories = directoryMapper.selectList(qwd); + + ConvertUtil convertUtil=new ConvertUtil(); +// 将实体类转换成vo类 + List gamesVo = convertUtil.entityToVoList(gamePage.getRecords(), GameVo.class); + for (int i = 0; i < gamePage.getRecords().size(); i++) { + for (int j = 0; j pageVo=new Page<>(); + //将List转成page并返回 + Switch aSwitch=new Switch(); + aSwitch.ListToPage(pageVo,gamesVo); + return pageVo; + } + + /** + * 大赛中心新增 + */ + @Override + public int addApplication(GameVo gameVo) { + //将vo类转换为实体类 + ConvertUtil convertUtil=new ConvertUtil(); + Game game = convertUtil.VoToEntity(gameVo, Game.class); + //根据目录名称查询目录id + QueryWrapper qwd=new QueryWrapper<>(); + qwd.lambda().eq(Directory::getDirName,gameVo.getDirName()); + Directory directory = directoryMapper.selectOne(qwd); + //将目录id封装到实体类 + game.setDirId(directory.getId()); + game.setGameAddtime(new Date()); + int insert = gameMapper.insert(game); + return insert; + } + + /** + * 根据id查询大赛信息 + */ + @Override + public GameVo selectByIdGame(Integer id) { + //根据id查询大赛中心 + QueryWrapper qwa=new QueryWrapper<>(); + qwa.lambda().eq(Game::getId,id); + Game game = gameMapper.selectOne(qwa); + //查询目录 + QueryWrapper qwd=new QueryWrapper<>(); + qwd.lambda().eq(Directory::getId,game.getDirId()); + Directory directory = directoryMapper.selectOne(qwd); + ConvertUtil convertUtil=new ConvertUtil(); + GameVo gameVo = convertUtil.entityToVo(game, GameVo.class); + //给目录名称赋值 + gameVo.setDirName(directory.getDirName()); + return gameVo; + } + + /** + * 大赛中心更新 + */ + @Override + public int updateGame(GameVo gameVo) { + //将vo类转换为实体类 + ConvertUtil convertUtil=new ConvertUtil(); + Game game = convertUtil.VoToEntity(gameVo, Game.class); + //根据目录名称查询目录id + QueryWrapper qwd=new QueryWrapper<>(); + qwd.lambda().eq(Directory::getDirName,gameVo.getDirName()); + Directory directory = directoryMapper.selectOne(qwd); + //将目录id封装到实体类 + game.setDirId(directory.getId()); + game.setGameUpdatetime(new Date()); + int update = gameMapper.updateById(game); + return update; + } + + /** + * 大赛中心删除 + */ + @Override + public int deleteGame(Integer id) { + if(id!=null){ + int delete = gameMapper.deleteById(id); + return delete; + } + return 0; + } } diff --git a/src/main/java/com/zhiyun/zhiyun03/game/vo/GameVo.java b/src/main/java/com/zhiyun/zhiyun03/game/vo/GameVo.java new file mode 100644 index 0000000..0b43c49 --- /dev/null +++ b/src/main/java/com/zhiyun/zhiyun03/game/vo/GameVo.java @@ -0,0 +1,50 @@ +package com.zhiyun.zhiyun03.game.vo; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +@Data +@ApiModel("大赛中心Vo") +public class GameVo { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId + private Integer id; + + /** + * 大赛名称 + */ + private String gameName; + + /** + * 大赛简介 + */ + private String gameBiref; + + /** + * 大赛链接 + */ + private String gameUrl; + + /** + * 目录名称 + */ + private String dirName; + + /** + * 大赛图片 + */ + private String gameImg; + +} diff --git a/src/main/java/com/zhiyun/zhiyun03/invite/entity/Invite.java b/src/main/java/com/zhiyun/zhiyun03/invite/entity/Invite.java index a8b0ef6..71fc827 100644 --- a/src/main/java/com/zhiyun/zhiyun03/invite/entity/Invite.java +++ b/src/main/java/com/zhiyun/zhiyun03/invite/entity/Invite.java @@ -21,7 +21,7 @@ public class Invite { * id */ @TableId(value = "id",type = IdType.AUTO) - private int id; + private Integer id; /** * 招聘名称 diff --git a/src/main/java/com/zhiyun/zhiyun03/knowledge/controller/KnowledgeController.java b/src/main/java/com/zhiyun/zhiyun03/knowledge/controller/KnowledgeController.java index 16053d5..229eb77 100644 --- a/src/main/java/com/zhiyun/zhiyun03/knowledge/controller/KnowledgeController.java +++ b/src/main/java/com/zhiyun/zhiyun03/knowledge/controller/KnowledgeController.java @@ -1,4 +1,68 @@ package com.zhiyun.zhiyun03.knowledge.controller; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.zhiyun.zhiyun03.knowledge.service.KnowledgeService; +import com.zhiyun.zhiyun03.knowledge.vo.KnowledgeVo; +import com.zhiyun.zhiyun03.textual.vo.TextualVo; +import com.zhiyun.zhiyun03.utils.common.JsonResult; +import com.zhiyun.zhiyun03.utils.common.ResultCode; +import io.swagger.annotations.ApiOperation; +import lombok.Data; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +@RestController +@RequestMapping("/knowledge") public class KnowledgeController { + @Resource + KnowledgeService knowledgeService; + + @RequestMapping("/queryKnowledge") + @ApiOperation("查询考证信息") + public JsonResult queryKnowledge(@RequestParam(name="page") Integer page, + @RequestParam(name="limit") Integer limit){ + Page knowledge = knowledgeService.queryKnowledge(page,limit); + return JsonResult.success(knowledge); + } + + @RequestMapping("/addKnowledge") + @ApiOperation("新增考证信息") + public JsonResult addKnowledge(@RequestBody KnowledgeVo knowledgeVo){ + int result = knowledgeService.addKnowledge(knowledgeVo); + if(result>0){ + return JsonResult.success(ResultCode.SUCCESS); + } + return JsonResult.success(ResultCode.Fail); + } + + @RequestMapping("/selectByIdKnowledge") + @ApiOperation("根据id查询大赛信息") + public JsonResult selectByIdKnowledge(Integer id){ + KnowledgeVo knowledgeVo = knowledgeService.selectByIdKnowledge(id); + return JsonResult.success(knowledgeVo); + } + + @RequestMapping("/updateKnowledge") + @ApiOperation("更新大赛信息") + public JsonResult updateKnowledge(@RequestBody KnowledgeVo knowledgeVo){ + int result = knowledgeService.updateKnowledge(knowledgeVo); + if(result>0){ + return JsonResult.success(ResultCode.SUCCESS); + } + return JsonResult.success(ResultCode.Fail); + } + + @RequestMapping("/deleteKnowledge") + @ApiOperation("删除大赛信息") + public JsonResult deleteKnowledge(Integer id){ + int result = knowledgeService.deleteKnowledge(id); + if(result>0){ + return JsonResult.success(ResultCode.SUCCESS); + } + return JsonResult.success(ResultCode.Fail); + } } diff --git a/src/main/java/com/zhiyun/zhiyun03/knowledge/entity/Knowledge.java b/src/main/java/com/zhiyun/zhiyun03/knowledge/entity/Knowledge.java index 7fea784..32045eb 100644 --- a/src/main/java/com/zhiyun/zhiyun03/knowledge/entity/Knowledge.java +++ b/src/main/java/com/zhiyun/zhiyun03/knowledge/entity/Knowledge.java @@ -21,7 +21,7 @@ public class Knowledge { * id */ @TableId(value = "id",type = IdType.AUTO) - private int id; + private Integer id; /** * 知识名称 diff --git a/src/main/java/com/zhiyun/zhiyun03/knowledge/service/KnowledgeService.java b/src/main/java/com/zhiyun/zhiyun03/knowledge/service/KnowledgeService.java index d1ae049..86c855b 100644 --- a/src/main/java/com/zhiyun/zhiyun03/knowledge/service/KnowledgeService.java +++ b/src/main/java/com/zhiyun/zhiyun03/knowledge/service/KnowledgeService.java @@ -1,7 +1,18 @@ package com.zhiyun.zhiyun03.knowledge.service; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.zhiyun.zhiyun03.knowledge.entity.Knowledge; +import com.zhiyun.zhiyun03.knowledge.vo.KnowledgeVo; public interface KnowledgeService extends IService { + Page queryKnowledge(Integer page,Integer limit); + + int addKnowledge(KnowledgeVo knowledgeVo); + + KnowledgeVo selectByIdKnowledge(Integer id); + + int updateKnowledge(KnowledgeVo knowledgeVo); + + int deleteKnowledge(Integer id); } diff --git a/src/main/java/com/zhiyun/zhiyun03/knowledge/service/impl/KnowledgeServiceImpl.java b/src/main/java/com/zhiyun/zhiyun03/knowledge/service/impl/KnowledgeServiceImpl.java index 19b1134..c7a83cf 100644 --- a/src/main/java/com/zhiyun/zhiyun03/knowledge/service/impl/KnowledgeServiceImpl.java +++ b/src/main/java/com/zhiyun/zhiyun03/knowledge/service/impl/KnowledgeServiceImpl.java @@ -1,11 +1,137 @@ package com.zhiyun.zhiyun03.knowledge.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.zhiyun.zhiyun03.application.entity.Directory; +import com.zhiyun.zhiyun03.application.mapper.DirectoryMapper; import com.zhiyun.zhiyun03.knowledge.entity.Knowledge; import com.zhiyun.zhiyun03.knowledge.mapper.KnowledgeMapper; import com.zhiyun.zhiyun03.knowledge.service.KnowledgeService; +import com.zhiyun.zhiyun03.knowledge.vo.KnowledgeVo; +import com.zhiyun.zhiyun03.textual.entity.Textual; +import com.zhiyun.zhiyun03.textual.vo.TextualVo; +import com.zhiyun.zhiyun03.utils.convert.ConvertUtil; +import com.zhiyun.zhiyun03.utils.convert.Switch; import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; + @Service public class KnowledgeServiceImpl extends ServiceImpl implements KnowledgeService { + + @Resource + KnowledgeMapper knowledgeMapper; + + + @Resource + DirectoryMapper directoryMapper; + + + /** + * 知识分享信息查询 + */ + @Override + public Page queryKnowledge(Integer page,Integer limit) { + Page page1=new Page(); + page1.setCurrent(limit); + page1.setSize(page); + //查询知识分享信息 + QueryWrapper qwk=new QueryWrapper<>(); + Page knowledgePage = knowledgeMapper.selectPage(page1,qwk); + //查询目录 + QueryWrapper qwd=new QueryWrapper<>(); + List directories = directoryMapper.selectList(qwd); + + ConvertUtil convertUtil=new ConvertUtil(); +// 将实体类转换成vo类 + List knowledgeVos = convertUtil.entityToVoList(knowledgePage.getRecords(), KnowledgeVo.class); + for (int i = 0; i < knowledgePage.getRecords().size(); i++) { + for (int j = 0; j pageVo=new Page<>(); + //将List转成page并返回 + Switch aSwitch=new Switch(); + aSwitch.ListToPage(pageVo,knowledgeVos); + return pageVo; + } + + /** + * 知识分享信息新增 + */ + @Override + public int addKnowledge(KnowledgeVo knowledgeVo) { + //将vo类转换为实体类 + ConvertUtil convertUtil=new ConvertUtil(); + Knowledge knowledge = convertUtil.VoToEntity(knowledgeVo, Knowledge.class); + //根据目录名称查询目录id + QueryWrapper qwd=new QueryWrapper<>(); + qwd.lambda().eq(Directory::getDirName,knowledgeVo.getDirName()); + Directory directory = directoryMapper.selectOne(qwd); + //将目录id封装到实体类 + knowledge.setDirId(directory.getId()); + knowledge.setKnowledgeAddtime(new Date()); + int insert = knowledgeMapper.insert(knowledge); + return insert; + } + + /** + * 根据id查询知识分享信息 + */ + @Override + public KnowledgeVo selectByIdKnowledge(Integer id) { + //根据id查询考证中心 + QueryWrapper qwa=new QueryWrapper<>(); + qwa.lambda().eq(Knowledge::getId,id); + Knowledge knowledge = knowledgeMapper.selectOne(qwa); + //查询目录 + QueryWrapper qwd=new QueryWrapper<>(); + qwd.lambda().eq(Directory::getId,knowledge.getDirId()); + Directory directory = directoryMapper.selectOne(qwd); + ConvertUtil convertUtil=new ConvertUtil(); + KnowledgeVo knowledgeVo = convertUtil.entityToVo(knowledge, KnowledgeVo.class); + //给目录名称赋值 + knowledgeVo.setDirName(directory.getDirName()); + return knowledgeVo; + } + + /** + * 知识分享信息更新 + */ + @Override + public int updateKnowledge(KnowledgeVo knowledgeVo) { + //将vo类转换为实体类 + ConvertUtil convertUtil=new ConvertUtil(); + Knowledge knowledge = convertUtil.VoToEntity(knowledgeVo, Knowledge.class); + //根据目录名称查询目录id + QueryWrapper qwd=new QueryWrapper<>(); + qwd.lambda().eq(Directory::getDirName,knowledgeVo.getDirName()); + Directory directory = directoryMapper.selectOne(qwd); + //将目录id封装到实体类 + knowledge.setDirId(directory.getId()); + knowledge.setKnowledgeUpdatetime(new Date()); + int update = knowledgeMapper.updateById(knowledge); + return update; + } + + + /** + * 知识分享信息删除 + */ + @Override + public int deleteKnowledge(Integer id) { + if(id!=null){ + int delete = knowledgeMapper.deleteById(id); + return delete; + } + return 0; + } } diff --git a/src/main/java/com/zhiyun/zhiyun03/knowledge/vo/KnowledgeVo.java b/src/main/java/com/zhiyun/zhiyun03/knowledge/vo/KnowledgeVo.java new file mode 100644 index 0000000..e7049fd --- /dev/null +++ b/src/main/java/com/zhiyun/zhiyun03/knowledge/vo/KnowledgeVo.java @@ -0,0 +1,44 @@ +package com.zhiyun.zhiyun03.knowledge.vo; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +@Data +@ApiModel("知识中心") +public class KnowledgeVo { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId + private Integer id; + + /** + * 知识名称 + */ + private String knowledgeName; + + /** + * 知识链接 + */ + private String knowledgeUrl; + + /** + * 目录id + */ + private String dirName; + + /** + * 知识图片 + */ + private String knowledgeImg; + +} diff --git a/src/main/java/com/zhiyun/zhiyun03/serve/entity/Serve.java b/src/main/java/com/zhiyun/zhiyun03/serve/entity/Serve.java index 05657d4..61d8e37 100644 --- a/src/main/java/com/zhiyun/zhiyun03/serve/entity/Serve.java +++ b/src/main/java/com/zhiyun/zhiyun03/serve/entity/Serve.java @@ -21,7 +21,7 @@ public class Serve { * id */ @TableId(value = "id",type = IdType.AUTO) - private int id; + private Integer id; /** * 服务名称 diff --git a/src/main/java/com/zhiyun/zhiyun03/textual/controller/TextualController.java b/src/main/java/com/zhiyun/zhiyun03/textual/controller/TextualController.java index b774824..fbd5490 100644 --- a/src/main/java/com/zhiyun/zhiyun03/textual/controller/TextualController.java +++ b/src/main/java/com/zhiyun/zhiyun03/textual/controller/TextualController.java @@ -1,4 +1,67 @@ package com.zhiyun.zhiyun03.textual.controller; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.zhiyun.zhiyun03.game.vo.GameVo; +import com.zhiyun.zhiyun03.textual.service.TextualService; +import com.zhiyun.zhiyun03.textual.vo.TextualVo; +import com.zhiyun.zhiyun03.utils.common.JsonResult; +import com.zhiyun.zhiyun03.utils.common.ResultCode; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +@RestController +@RequestMapping("/textual") public class TextualController { + @Resource + TextualService textualService; + + @RequestMapping("/queryTextual") + @ApiOperation("查询考证信息") + public JsonResult queryTextual(@RequestParam(name="page") Integer page, + @RequestParam(name="limit") Integer limit){ + Page textualVoPage = textualService.queryTextual(page,limit); + return JsonResult.success(textualVoPage); + } + + @RequestMapping("/addTextual") + @ApiOperation("新增考证信息") + public JsonResult addTextual(@RequestBody TextualVo textualVo){ + int result = textualService.addTextual(textualVo); + if(result>0){ + return JsonResult.success(ResultCode.SUCCESS); + } + return JsonResult.success(ResultCode.Fail); + } + + @RequestMapping("/selectByIdTextual") + @ApiOperation("根据id查询大赛信息") + public JsonResult selectByIdTextual(Integer id){ + TextualVo textualVo = textualService.selectByIdTextual(id); + return JsonResult.success(textualVo); + } + + @RequestMapping("/updateTextual") + @ApiOperation("更新大赛信息") + public JsonResult updateTextual(@RequestBody TextualVo textualVo){ + int result = textualService.updateTextual(textualVo); + if(result>0){ + return JsonResult.success(ResultCode.SUCCESS); + } + return JsonResult.success(ResultCode.Fail); + } + + @RequestMapping("/deleteTextual") + @ApiOperation("删除大赛信息") + public JsonResult deleteTextual(Integer id){ + int result = textualService.deleteGame(id); + if(result>0){ + return JsonResult.success(ResultCode.SUCCESS); + } + return JsonResult.success(ResultCode.Fail); + } } diff --git a/src/main/java/com/zhiyun/zhiyun03/textual/entity/Textual.java b/src/main/java/com/zhiyun/zhiyun03/textual/entity/Textual.java index 233cfc4..3aa35c5 100644 --- a/src/main/java/com/zhiyun/zhiyun03/textual/entity/Textual.java +++ b/src/main/java/com/zhiyun/zhiyun03/textual/entity/Textual.java @@ -21,7 +21,7 @@ public class Textual { * id */ @TableId(value = "id",type = IdType.AUTO) - private int id; + private Integer id; /** * 考证名称 diff --git a/src/main/java/com/zhiyun/zhiyun03/textual/service/TextualService.java b/src/main/java/com/zhiyun/zhiyun03/textual/service/TextualService.java index 2b1e2e9..ba23bb1 100644 --- a/src/main/java/com/zhiyun/zhiyun03/textual/service/TextualService.java +++ b/src/main/java/com/zhiyun/zhiyun03/textual/service/TextualService.java @@ -1,7 +1,18 @@ package com.zhiyun.zhiyun03.textual.service; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.zhiyun.zhiyun03.textual.entity.Textual; +import com.zhiyun.zhiyun03.textual.vo.TextualVo; public interface TextualService extends IService { + Page queryTextual(Integer page,Integer limit); + + int addTextual(TextualVo textualVo); + + TextualVo selectByIdTextual(Integer id); + + int updateTextual(TextualVo textualVo); + + int deleteGame(Integer id); } diff --git a/src/main/java/com/zhiyun/zhiyun03/textual/service/impl/TextualServiceImpl.java b/src/main/java/com/zhiyun/zhiyun03/textual/service/impl/TextualServiceImpl.java index e2a9807..31ecd55 100644 --- a/src/main/java/com/zhiyun/zhiyun03/textual/service/impl/TextualServiceImpl.java +++ b/src/main/java/com/zhiyun/zhiyun03/textual/service/impl/TextualServiceImpl.java @@ -1,11 +1,133 @@ package com.zhiyun.zhiyun03.textual.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.zhiyun.zhiyun03.application.entity.Directory; +import com.zhiyun.zhiyun03.application.mapper.DirectoryMapper; +import com.zhiyun.zhiyun03.game.entity.Game; +import com.zhiyun.zhiyun03.game.vo.GameVo; import com.zhiyun.zhiyun03.textual.entity.Textual; import com.zhiyun.zhiyun03.textual.mapper.TextualMapper; import com.zhiyun.zhiyun03.textual.service.TextualService; +import com.zhiyun.zhiyun03.textual.vo.TextualVo; +import com.zhiyun.zhiyun03.utils.convert.ConvertUtil; +import com.zhiyun.zhiyun03.utils.convert.Switch; import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; + @Service public class TextualServiceImpl extends ServiceImpl implements TextualService { + @Resource + TextualMapper textualMapper; + + @Resource + DirectoryMapper directoryMapper; + + /** + * 考证中心查询 + */ + @Override + public Page queryTextual(Integer page,Integer limit) { + Page page1=new Page(); + page1.setCurrent(limit); + page1.setSize(page); + //查询大赛中心 + QueryWrapper qwt=new QueryWrapper<>(); + Page textualPage = textualMapper.selectPage(page1,qwt); + //查询目录 + QueryWrapper qwd=new QueryWrapper<>(); + List directories = directoryMapper.selectList(qwd); + + ConvertUtil convertUtil=new ConvertUtil(); +// 将实体类转换成vo类 + List textualVos = convertUtil.entityToVoList(textualPage.getRecords(), TextualVo.class); + for (int i = 0; i < textualPage.getRecords().size(); i++) { + for (int j = 0; j pageVo=new Page<>(); + //将List转成page并返回 + Switch aSwitch=new Switch(); + aSwitch.ListToPage(pageVo,textualVos); + return pageVo; + } + + /** + * 考证中心新增 + */ + @Override + public int addTextual(TextualVo textualVo) { + //将vo类转换为实体类 + ConvertUtil convertUtil=new ConvertUtil(); + Textual textual = convertUtil.VoToEntity(textualVo, Textual.class); + //根据目录名称查询目录id + QueryWrapper qwd=new QueryWrapper<>(); + qwd.lambda().eq(Directory::getDirName,textualVo.getDirName()); + Directory directory = directoryMapper.selectOne(qwd); + //将目录id封装到实体类 + textual.setDirId(directory.getId()); + textual.setTextualAddtime(new Date()); + int insert = textualMapper.insert(textual); + return insert; + } + + /** + * 根据id查询考证信息 + */ + @Override + public TextualVo selectByIdTextual(Integer id) { + //根据id查询考证中心 + QueryWrapper qwa=new QueryWrapper<>(); + qwa.lambda().eq(Textual::getId,id); + Textual textual = textualMapper.selectOne(qwa); + //查询目录 + QueryWrapper qwd=new QueryWrapper<>(); + qwd.lambda().eq(Directory::getId,textual.getDirId()); + Directory directory = directoryMapper.selectOne(qwd); + ConvertUtil convertUtil=new ConvertUtil(); + TextualVo textualVo = convertUtil.entityToVo(textual, TextualVo.class); + //给目录名称赋值 + textualVo.setDirName(directory.getDirName()); + return textualVo; + } + + /** + * 考证中心更新 + */ + @Override + public int updateTextual(TextualVo textualVo) { + //将vo类转换为实体类 + ConvertUtil convertUtil=new ConvertUtil(); + Textual textual = convertUtil.VoToEntity(textualVo, Textual.class); + //根据目录名称查询目录id + QueryWrapper qwd=new QueryWrapper<>(); + qwd.lambda().eq(Directory::getDirName,textualVo.getDirName()); + Directory directory = directoryMapper.selectOne(qwd); + //将目录id封装到实体类 + textual.setDirId(directory.getId()); + textual.setTextualUpdatetime(new Date()); + int update = textualMapper.updateById(textual); + return update; + } + + /** + * 考证中心删除 + */ + @Override + public int deleteGame(Integer id) { + if(id!=null){ + int delete = textualMapper.deleteById(id); + return delete; + } + return 0; + } } diff --git a/src/main/java/com/zhiyun/zhiyun03/textual/vo/TextualVo.java b/src/main/java/com/zhiyun/zhiyun03/textual/vo/TextualVo.java new file mode 100644 index 0000000..088e1d5 --- /dev/null +++ b/src/main/java/com/zhiyun/zhiyun03/textual/vo/TextualVo.java @@ -0,0 +1,44 @@ +package com.zhiyun.zhiyun03.textual.vo; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiOperation; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +@Data +@ApiOperation("考证中心") +public class TextualVo { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId + private Integer id; + + /** + * 考证名称 + */ + private String textualName; + + /** + * 考证链接 + */ + private String textualUrl; + + /** + * 目录名称 + */ + private String dirName; + + /** + * 考证图片 + */ + private String textualImg; + +} diff --git a/src/main/java/com/zhiyun/zhiyun03/utils/config/GlobalCrossConfig.java b/src/main/java/com/zhiyun/zhiyun03/utils/config/GlobalCrossConfig.java new file mode 100644 index 0000000..f204a79 --- /dev/null +++ b/src/main/java/com/zhiyun/zhiyun03/utils/config/GlobalCrossConfig.java @@ -0,0 +1,33 @@ +package com.zhiyun.zhiyun03.utils.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; +import org.springframework.web.filter.CorsFilter; + +@Configuration +public class GlobalCrossConfig { + @Bean + public CorsFilter corsFilter() { + //1. 添加 CORS配置信息 + CorsConfiguration config = new CorsConfiguration(); + //放行哪些原始域,*表示所有 + // config.addAllowedOrigin("*"); + // 注意:springboot2.4以上使用该方式 + config.addAllowedOriginPattern("*"); + //是否发送 Cookie + config.setAllowCredentials(true); + //放行哪些请求方式 + config.addAllowedMethod("*"); + //放行哪些原始请求头部信息 + config.addAllowedHeader("*"); + //暴露哪些头部信息 + config.addExposedHeader("*"); + //2. 添加映射路径 + UrlBasedCorsConfigurationSource corsConfigurationSource = new UrlBasedCorsConfigurationSource(); + corsConfigurationSource.registerCorsConfiguration("/**", config); + //3. 返回新的CorsFilter + return new CorsFilter(corsConfigurationSource); + } +} diff --git a/src/main/resources/templates/layui-v2.6.8/applicationList.html b/src/main/resources/templates/layui-v2.6.8/applicationList.html new file mode 100644 index 0000000..e103f82 --- /dev/null +++ b/src/main/resources/templates/layui-v2.6.8/applicationList.html @@ -0,0 +1,80 @@ + + + + + Layui + + + + + + + + +
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/layui-v2.6.8/courseList.html b/src/main/resources/templates/layui-v2.6.8/courseList.html index da6688c..b49a074 100644 --- a/src/main/resources/templates/layui-v2.6.8/courseList.html +++ b/src/main/resources/templates/layui-v2.6.8/courseList.html @@ -50,7 +50,7 @@ ,{field:'courseBrief', title:'课程简介', width:120} ,{field:'courseUrl', title:'超链接', width:120} ,{field:'dirName', title:'归属目录', width:120} - // ,{field:'courseIcon', title:'编号', width:120} + ,{field:'courseIcon', title:'编号', width:120} ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150} ]] ,page: true