应用中心
parent
b7730707c5
commit
77673e42c6
@ -1,4 +1,69 @@
|
|||||||
package com.zhiyun.zhiyun03.academic.controller;
|
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 {
|
public class AcademicController {
|
||||||
|
@Resource
|
||||||
|
AcademicService academicService;
|
||||||
|
|
||||||
|
@RequestMapping("/queryAcademic")
|
||||||
|
@ApiOperation("查询学术信息")
|
||||||
|
public JsonResult<AcademicVo> queryAcademic(@RequestParam(name="page") Integer page,
|
||||||
|
@RequestParam(name="limit") Integer limit){
|
||||||
|
Page<AcademicVo> 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<AcademicVo> 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,19 @@
|
|||||||
package com.zhiyun.zhiyun03.academic.service;
|
package com.zhiyun.zhiyun03.academic.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.zhiyun.zhiyun03.academic.entity.Academic;
|
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<Academic> {
|
public interface AcademicService extends IService<Academic> {
|
||||||
|
Page<AcademicVo> queryAcademic(Integer page,Integer limit);
|
||||||
|
|
||||||
|
int addAcademic(AcademicVo academicVo);
|
||||||
|
|
||||||
|
AcademicVo selectByIdAcademic(Integer id);
|
||||||
|
|
||||||
|
int updateAcademic(AcademicVo academicVo);
|
||||||
|
|
||||||
|
int deleteAcademic(Integer id);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,133 @@
|
|||||||
package com.zhiyun.zhiyun03.academic.service.impl;
|
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.zhiyun.zhiyun03.academic.entity.Academic;
|
import com.zhiyun.zhiyun03.academic.entity.Academic;
|
||||||
import com.zhiyun.zhiyun03.academic.mapper.AcademicMapper;
|
import com.zhiyun.zhiyun03.academic.mapper.AcademicMapper;
|
||||||
import com.zhiyun.zhiyun03.academic.service.AcademicService;
|
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 org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class AcademicServiceImpl extends ServiceImpl<AcademicMapper, Academic> implements AcademicService {
|
public class AcademicServiceImpl extends ServiceImpl<AcademicMapper, Academic> implements AcademicService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
AcademicMapper academicMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
DirectoryMapper directoryMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 学术信息查询
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Page<AcademicVo> queryAcademic(Integer page,Integer limit) {
|
||||||
|
Page page1=new Page();
|
||||||
|
page1.setCurrent(limit);
|
||||||
|
page1.setSize(page);
|
||||||
|
QueryWrapper<Academic> qwa=new QueryWrapper<>();
|
||||||
|
Page<Academic> academicPage = academicMapper.selectPage(page1,qwa);
|
||||||
|
//查询目录
|
||||||
|
QueryWrapper<Directory> qwd=new QueryWrapper<>();
|
||||||
|
List<Directory> directories = directoryMapper.selectList(qwd);
|
||||||
|
|
||||||
|
ConvertUtil convertUtil=new ConvertUtil();
|
||||||
|
// 将实体类转换成vo类
|
||||||
|
List<AcademicVo> academicVos = convertUtil.entityToVoList(academicPage.getRecords(), AcademicVo.class);
|
||||||
|
for (int i = 0; i < academicPage.getRecords().size(); i++) {
|
||||||
|
for (int j = 0; j <directories.size() ; j++) {
|
||||||
|
//判断目录id是否相等
|
||||||
|
if(academicPage.getRecords().get(i).getDirId()==directories.get(j).getId()){
|
||||||
|
//将目录名称添加到vo类中
|
||||||
|
academicVos.get(i).setDirName(directories.get(j).getDirName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Page<AcademicVo> 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<Directory> 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<Academic> qwa=new QueryWrapper<>();
|
||||||
|
qwa.lambda().eq(Academic::getId,id);
|
||||||
|
Academic academic= academicMapper.selectOne(qwa);
|
||||||
|
//查询目录
|
||||||
|
QueryWrapper<Directory> 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<Directory> 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,74 @@
|
|||||||
package com.zhiyun.zhiyun03.game.controller;
|
package com.zhiyun.zhiyun03.game.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.zhiyun.zhiyun03.application.entity.Directory;
|
||||||
|
import com.zhiyun.zhiyun03.application.vo.ApplicationVo;
|
||||||
|
import com.zhiyun.zhiyun03.game.entity.Game;
|
||||||
|
import com.zhiyun.zhiyun03.game.service.GameService;
|
||||||
|
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.ApiModel;
|
||||||
|
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;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/game")
|
||||||
|
@Api("大赛中心")
|
||||||
public class GameController {
|
public class GameController {
|
||||||
|
@Resource
|
||||||
|
GameService gameService;
|
||||||
|
|
||||||
|
@RequestMapping("/queryGame")
|
||||||
|
@ApiOperation("查询大赛信息")
|
||||||
|
public JsonResult<GameVo> queryGame(@RequestParam(name="page") Integer page,
|
||||||
|
@RequestParam(name="limit") Integer limit){
|
||||||
|
Page<GameVo> 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<GameVo> 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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,20 @@
|
|||||||
package com.zhiyun.zhiyun03.game.service;
|
package com.zhiyun.zhiyun03.game.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.zhiyun.zhiyun03.game.entity.Game;
|
import com.zhiyun.zhiyun03.game.entity.Game;
|
||||||
|
import com.zhiyun.zhiyun03.game.vo.GameVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface GameService extends IService<Game> {
|
public interface GameService extends IService<Game> {
|
||||||
|
Page<GameVo> queryGame(Integer page,Integer limit);
|
||||||
|
|
||||||
|
int addApplication(GameVo gameVo);
|
||||||
|
|
||||||
|
GameVo selectByIdGame(Integer id);
|
||||||
|
|
||||||
|
int updateGame(GameVo gameVo);
|
||||||
|
|
||||||
|
int deleteGame(Integer id);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,133 @@
|
|||||||
package com.zhiyun.zhiyun03.game.service.impl;
|
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.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.entity.Game;
|
||||||
import com.zhiyun.zhiyun03.game.mapper.GameMapper;
|
import com.zhiyun.zhiyun03.game.mapper.GameMapper;
|
||||||
import com.zhiyun.zhiyun03.game.service.GameService;
|
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 org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements GameService {
|
public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements GameService {
|
||||||
|
@Resource
|
||||||
|
GameMapper gameMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
DirectoryMapper directoryMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 大赛中心查询
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Page<GameVo> queryGame(Integer page,Integer limit) {
|
||||||
|
Page page1=new Page();
|
||||||
|
page1.setCurrent(limit);
|
||||||
|
page1.setSize(page);
|
||||||
|
//查询大赛中心
|
||||||
|
QueryWrapper<Game> qwg=new QueryWrapper<>();
|
||||||
|
Page<Game> gamePage = gameMapper.selectPage(page1,qwg);
|
||||||
|
//查询目录
|
||||||
|
QueryWrapper<Directory> qwd=new QueryWrapper<>();
|
||||||
|
List<Directory> directories = directoryMapper.selectList(qwd);
|
||||||
|
|
||||||
|
ConvertUtil convertUtil=new ConvertUtil();
|
||||||
|
// 将实体类转换成vo类
|
||||||
|
List<GameVo> gamesVo = convertUtil.entityToVoList(gamePage.getRecords(), GameVo.class);
|
||||||
|
for (int i = 0; i < gamePage.getRecords().size(); i++) {
|
||||||
|
for (int j = 0; j <directories.size() ; j++) {
|
||||||
|
//判断目录id是否相等
|
||||||
|
if(gamePage.getRecords().get(i).getDirId()==directories.get(j).getId()){
|
||||||
|
//将目录名称添加到vo类中
|
||||||
|
gamesVo.get(i).setDirName(directories.get(j).getDirName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Page<GameVo> 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<Directory> 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<Game> qwa=new QueryWrapper<>();
|
||||||
|
qwa.lambda().eq(Game::getId,id);
|
||||||
|
Game game = gameMapper.selectOne(qwa);
|
||||||
|
//查询目录
|
||||||
|
QueryWrapper<Directory> 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<Directory> 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,68 @@
|
|||||||
package com.zhiyun.zhiyun03.knowledge.controller;
|
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 {
|
public class KnowledgeController {
|
||||||
|
@Resource
|
||||||
|
KnowledgeService knowledgeService;
|
||||||
|
|
||||||
|
@RequestMapping("/queryKnowledge")
|
||||||
|
@ApiOperation("查询考证信息")
|
||||||
|
public JsonResult<KnowledgeVo> queryKnowledge(@RequestParam(name="page") Integer page,
|
||||||
|
@RequestParam(name="limit") Integer limit){
|
||||||
|
Page<KnowledgeVo> 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<KnowledgeVo> 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,18 @@
|
|||||||
package com.zhiyun.zhiyun03.knowledge.service;
|
package com.zhiyun.zhiyun03.knowledge.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.zhiyun.zhiyun03.knowledge.entity.Knowledge;
|
import com.zhiyun.zhiyun03.knowledge.entity.Knowledge;
|
||||||
|
import com.zhiyun.zhiyun03.knowledge.vo.KnowledgeVo;
|
||||||
|
|
||||||
public interface KnowledgeService extends IService<Knowledge> {
|
public interface KnowledgeService extends IService<Knowledge> {
|
||||||
|
Page<KnowledgeVo> queryKnowledge(Integer page,Integer limit);
|
||||||
|
|
||||||
|
int addKnowledge(KnowledgeVo knowledgeVo);
|
||||||
|
|
||||||
|
KnowledgeVo selectByIdKnowledge(Integer id);
|
||||||
|
|
||||||
|
int updateKnowledge(KnowledgeVo knowledgeVo);
|
||||||
|
|
||||||
|
int deleteKnowledge(Integer id);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,137 @@
|
|||||||
package com.zhiyun.zhiyun03.knowledge.service.impl;
|
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.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.entity.Knowledge;
|
||||||
import com.zhiyun.zhiyun03.knowledge.mapper.KnowledgeMapper;
|
import com.zhiyun.zhiyun03.knowledge.mapper.KnowledgeMapper;
|
||||||
import com.zhiyun.zhiyun03.knowledge.service.KnowledgeService;
|
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 org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class KnowledgeServiceImpl extends ServiceImpl<KnowledgeMapper,Knowledge> implements KnowledgeService {
|
public class KnowledgeServiceImpl extends ServiceImpl<KnowledgeMapper,Knowledge> implements KnowledgeService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
KnowledgeMapper knowledgeMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
DirectoryMapper directoryMapper;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 知识分享信息查询
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Page<KnowledgeVo> queryKnowledge(Integer page,Integer limit) {
|
||||||
|
Page page1=new Page();
|
||||||
|
page1.setCurrent(limit);
|
||||||
|
page1.setSize(page);
|
||||||
|
//查询知识分享信息
|
||||||
|
QueryWrapper<Knowledge> qwk=new QueryWrapper<>();
|
||||||
|
Page<Knowledge> knowledgePage = knowledgeMapper.selectPage(page1,qwk);
|
||||||
|
//查询目录
|
||||||
|
QueryWrapper<Directory> qwd=new QueryWrapper<>();
|
||||||
|
List<Directory> directories = directoryMapper.selectList(qwd);
|
||||||
|
|
||||||
|
ConvertUtil convertUtil=new ConvertUtil();
|
||||||
|
// 将实体类转换成vo类
|
||||||
|
List<KnowledgeVo> knowledgeVos = convertUtil.entityToVoList(knowledgePage.getRecords(), KnowledgeVo.class);
|
||||||
|
for (int i = 0; i < knowledgePage.getRecords().size(); i++) {
|
||||||
|
for (int j = 0; j <directories.size() ; j++) {
|
||||||
|
//判断目录id是否相等
|
||||||
|
if(knowledgePage.getRecords().get(i).getDirId()==directories.get(j).getId()){
|
||||||
|
//将目录名称添加到vo类中
|
||||||
|
knowledgeVos.get(i).setDirName(directories.get(j).getDirName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Page<KnowledgeVo> 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<Directory> 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<Knowledge> qwa=new QueryWrapper<>();
|
||||||
|
qwa.lambda().eq(Knowledge::getId,id);
|
||||||
|
Knowledge knowledge = knowledgeMapper.selectOne(qwa);
|
||||||
|
//查询目录
|
||||||
|
QueryWrapper<Directory> 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<Directory> 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,67 @@
|
|||||||
package com.zhiyun.zhiyun03.textual.controller;
|
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 {
|
public class TextualController {
|
||||||
|
@Resource
|
||||||
|
TextualService textualService;
|
||||||
|
|
||||||
|
@RequestMapping("/queryTextual")
|
||||||
|
@ApiOperation("查询考证信息")
|
||||||
|
public JsonResult<TextualVo> queryTextual(@RequestParam(name="page") Integer page,
|
||||||
|
@RequestParam(name="limit") Integer limit){
|
||||||
|
Page<TextualVo> 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<TextualVo> 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,18 @@
|
|||||||
package com.zhiyun.zhiyun03.textual.service;
|
package com.zhiyun.zhiyun03.textual.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.zhiyun.zhiyun03.textual.entity.Textual;
|
import com.zhiyun.zhiyun03.textual.entity.Textual;
|
||||||
|
import com.zhiyun.zhiyun03.textual.vo.TextualVo;
|
||||||
|
|
||||||
public interface TextualService extends IService<Textual> {
|
public interface TextualService extends IService<Textual> {
|
||||||
|
Page<TextualVo> queryTextual(Integer page,Integer limit);
|
||||||
|
|
||||||
|
int addTextual(TextualVo textualVo);
|
||||||
|
|
||||||
|
TextualVo selectByIdTextual(Integer id);
|
||||||
|
|
||||||
|
int updateTextual(TextualVo textualVo);
|
||||||
|
|
||||||
|
int deleteGame(Integer id);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,133 @@
|
|||||||
package com.zhiyun.zhiyun03.textual.service.impl;
|
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.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.entity.Textual;
|
||||||
import com.zhiyun.zhiyun03.textual.mapper.TextualMapper;
|
import com.zhiyun.zhiyun03.textual.mapper.TextualMapper;
|
||||||
import com.zhiyun.zhiyun03.textual.service.TextualService;
|
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 org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class TextualServiceImpl extends ServiceImpl<TextualMapper, Textual> implements TextualService {
|
public class TextualServiceImpl extends ServiceImpl<TextualMapper, Textual> implements TextualService {
|
||||||
|
@Resource
|
||||||
|
TextualMapper textualMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
DirectoryMapper directoryMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 考证中心查询
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Page<TextualVo> queryTextual(Integer page,Integer limit) {
|
||||||
|
Page page1=new Page();
|
||||||
|
page1.setCurrent(limit);
|
||||||
|
page1.setSize(page);
|
||||||
|
//查询大赛中心
|
||||||
|
QueryWrapper<Textual> qwt=new QueryWrapper<>();
|
||||||
|
Page<Textual> textualPage = textualMapper.selectPage(page1,qwt);
|
||||||
|
//查询目录
|
||||||
|
QueryWrapper<Directory> qwd=new QueryWrapper<>();
|
||||||
|
List<Directory> directories = directoryMapper.selectList(qwd);
|
||||||
|
|
||||||
|
ConvertUtil convertUtil=new ConvertUtil();
|
||||||
|
// 将实体类转换成vo类
|
||||||
|
List<TextualVo> textualVos = convertUtil.entityToVoList(textualPage.getRecords(), TextualVo.class);
|
||||||
|
for (int i = 0; i < textualPage.getRecords().size(); i++) {
|
||||||
|
for (int j = 0; j <directories.size() ; j++) {
|
||||||
|
//判断目录id是否相等
|
||||||
|
if(textualPage.getRecords().get(i).getDirId()==directories.get(j).getId()){
|
||||||
|
//将目录名称添加到vo类中
|
||||||
|
textualVos.get(i).setDirName(directories.get(j).getDirName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Page<TextualVo> 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<Directory> 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<Textual> qwa=new QueryWrapper<>();
|
||||||
|
qwa.lambda().eq(Textual::getId,id);
|
||||||
|
Textual textual = textualMapper.selectOne(qwa);
|
||||||
|
//查询目录
|
||||||
|
QueryWrapper<Directory> 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<Directory> 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue