服务中心,下载中心,就业中心

main
wanghb 2 years ago
parent 66460c199c
commit 5e5df87aaf

@ -72,8 +72,6 @@ public class DownloadController {
}
@ApiOperation("删除下载")
@PostMapping("/delDownload")
public JsonResult delDownload(Integer id){

@ -1,4 +1,65 @@
package com.zhiyun.zhiyun03.invite.controller;
import com.zhiyun.zhiyun03.course.service.CourseService;
import com.zhiyun.zhiyun03.course.vo.CourseVo;
import com.zhiyun.zhiyun03.course.vo.PageVO;
import com.zhiyun.zhiyun03.invite.service.InviteService;
import com.zhiyun.zhiyun03.invite.vo.InviteVo;
import com.zhiyun.zhiyun03.utils.common.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@Api("就业")
@RestController
@RequestMapping("/api/invite")
public class InviteController {
@Resource
private InviteService inviteService;
@ApiOperation("查询就业")
@GetMapping("/queryInvite")
public JsonResult<PageVO<InviteVo>> queryCourse(@ApiParam @RequestParam(value = "page",required = false,defaultValue = "1")Integer page,
@ApiParam @RequestParam(value = "limit",required = false,defaultValue = "1")Integer limit ){
PageVO<InviteVo> lists = inviteService.queryInvite(page,limit);
return JsonResult.success(lists);
}
@ApiOperation("根据ID查询就业")
@GetMapping("/queryInviteById")
public JsonResult<InviteVo> queryCourseById(Integer id){
InviteVo inviteVo =inviteService.queryInviteById(id);
return JsonResult.success(inviteVo);
}
@ApiOperation("就业添加")
@PostMapping("/addInvite")
public JsonResult addInvite(InviteVo vo){
int count = inviteService.addInvite(vo);
return JsonResult.success();
}
@ApiOperation("删除课程")
@DeleteMapping("delInviteById")
public JsonResult delInviteById(Integer id){
inviteService.delInviteById(id);
return JsonResult.success();
}
@ApiOperation("更新课程")
@PostMapping("updateById")
public JsonResult updateById(InviteVo vo){
int count = inviteService.updateById(vo);
return JsonResult.success();
}
}

@ -21,7 +21,7 @@ public class Invite {
* id
*/
@TableId(value = "id",type = IdType.AUTO)
private int id;
private Integer id;
/**
*
@ -32,8 +32,8 @@ public class Invite {
/**
*
*/
@TableField(value = "invite_biref")
private String inviteBiref;
@TableField(value = "invite_brief")
private String inviteBrief;
/**
*
@ -45,7 +45,7 @@ public class Invite {
* id
*/
@TableField(value = "dir_id")
private int dirId;
private Integer dirId;
/**
*

@ -2,8 +2,16 @@ package com.zhiyun.zhiyun03.invite.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhiyun.zhiyun03.invite.entity.Invite;
import com.zhiyun.zhiyun03.invite.vo.InviteVo;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface InviteMapper extends BaseMapper<Invite> {
List<InviteVo> queryInvite();
int selectByName(String inviteName);
int updateDownloadById(Invite invite);
}

@ -1,7 +1,18 @@
package com.zhiyun.zhiyun03.invite.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zhiyun.zhiyun03.course.vo.PageVO;
import com.zhiyun.zhiyun03.invite.entity.Invite;
import com.zhiyun.zhiyun03.invite.vo.InviteVo;
public interface InviteService extends IService<Invite> {
PageVO<InviteVo> queryInvite(Integer page, Integer limit);
InviteVo queryInviteById(Integer id);
int addInvite(InviteVo vo);
int delInviteById(Integer id);
int updateById(InviteVo vo);
}

@ -1,12 +1,154 @@
package com.zhiyun.zhiyun03.invite.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhiyun.zhiyun03.application.entity.Directory;
import com.zhiyun.zhiyun03.application.mapper.DirectoryMapper;
import com.zhiyun.zhiyun03.course.vo.PageVO;
import com.zhiyun.zhiyun03.download.entity.Download;
import com.zhiyun.zhiyun03.download.vo.DownloadVo;
import com.zhiyun.zhiyun03.invite.entity.Invite;
import com.zhiyun.zhiyun03.invite.mapper.InviteMapper;
import com.zhiyun.zhiyun03.invite.service.InviteService;
import com.zhiyun.zhiyun03.invite.vo.InviteVo;
import com.zhiyun.zhiyun03.serve.mapper.ServeMapper;
import com.zhiyun.zhiyun03.utils.exception.ServiceException;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Service
public class InviteServieImpl extends ServiceImpl<InviteMapper, Invite> implements InviteService {
@Resource
private InviteMapper inviteMapper;
@Resource
private DirectoryMapper directoryMapper;
/*
*
* */
@Override
public PageVO<InviteVo> queryInvite(Integer page, Integer limit) {
//开启分页
PageHelper.startPage(page,limit);
//查询所有下载数据
List<InviteVo> downloadVoList = inviteMapper.queryInvite();
PageInfo<InviteVo> downloadVoPageInfo = new PageInfo<>(downloadVoList);
PageVO<InviteVo> inviteVoPageVO = new PageVO<>();
//获取当前页
inviteVoPageVO.setCurrentPage(downloadVoPageInfo.getPageNum());
//总条数
inviteVoPageVO.setTotal(downloadVoPageInfo.getTotal());
//分页数据
inviteVoPageVO.setList(downloadVoPageInfo.getList());
return inviteVoPageVO;
}
/*
* id
* */
@Override
public InviteVo queryInviteById(Integer id) {
//根据id查询数据
Invite invite = inviteMapper.selectById(id);
//查询目录id
Directory directory = directoryMapper.selectById(invite.getDirId());
InviteVo inviteVo = new InviteVo();
//复制给vo
BeanUtils.copyProperties(invite,inviteVo);
inviteVo.setDirName(directory.getDirName());
return inviteVo;
}
/*
*
* */
@Override
public int addInvite(InviteVo vo) {
//查询就业名称是否已经存在
int count = inviteMapper.selectByName(vo.getInviteName());
if (count>0)
{
throw new ServiceException("403","就业名已存在");
}
//将vo值传给download
Invite invite = new Invite();
BeanUtils.copyProperties(vo,invite);
//查询归属目录id
Integer dirId = directoryMapper.selectByName(vo.getDirName());
invite.setDirId(dirId);
invite.setInviteUpdatetime(new Date());
//添加download
int insert = inviteMapper.insert(invite);
if (insert>0)
{
return insert;
}else
{
throw new ServiceException("400","添加下载失败");
}
}
/*
* id
* */
@Override
public int delInviteById(Integer id) {
if (id == null)
{
throw new ServiceException("400","查询id值为空");
}
//根据id删除
int count = inviteMapper.deleteById(id);
if (count>0)
{
return count;
}else
{
throw new ServiceException("400","删除失败");
}
}
/*
*
* */
@Override
public int updateById(InviteVo vo) {
//查询更新的下载名是否存在
int sum = inviteMapper.selectByName(vo.getInviteName());
if (sum>0)
{
throw new ServiceException("403","下载已存在");
}
//将vo值传给download
Invite invite = new Invite();
BeanUtils.copyProperties(vo,invite);
//查询归属目录id
Integer dirId = directoryMapper.selectByName(vo.getDirName());
invite.setDirId(dirId);
invite.setInviteUpdatetime(new Date());
//添加download
int updated = inviteMapper.updateDownloadById(invite);
if (updated>0)
{
return updated;
}else
{
throw new ServiceException("400","更新失败");
}
}
}

@ -0,0 +1,32 @@
package com.zhiyun.zhiyun03.invite.vo;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
@Data
public class InviteVo {
@TableId
private Integer id;
/**
*
*/
private String inviteName;
/**
*
*/
private String inviteBrief;
/**
*
*/
private String inviteUrl;
/**
*
*/
private String dirName;
/**
*
*/
private String inviteImg;
}

@ -1,4 +1,104 @@
package com.zhiyun.zhiyun03.serve.controller;
import com.zhiyun.zhiyun03.course.vo.PageVO;
import com.zhiyun.zhiyun03.download.service.DownloadService;
import com.zhiyun.zhiyun03.download.vo.DownloadVo;
import com.zhiyun.zhiyun03.serve.service.ServeService;
import com.zhiyun.zhiyun03.serve.vo.ServeVo;
import com.zhiyun.zhiyun03.utils.common.JsonResult;
import com.zhiyun.zhiyun03.utils.oss.AliyunOssUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.File;
import java.io.FileOutputStream;
@Api("服务相关")
@RestController
@RequestMapping("/api/serve")
public class ServeController {
}
@Resource
private AliyunOssUtil ossUtil;
@Resource
private ServeService serveService;
@ApiOperation("查询服务中心")
@GetMapping("/queryServe")
public JsonResult<PageVO<ServeVo>> queryServe(@ApiParam @RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
@ApiParam @RequestParam(value = "limit", required = false, defaultValue = "5") Integer limit) {
PageVO<ServeVo> lists = serveService.queryServe(page, limit);
return JsonResult.success(lists);
}
@ApiOperation("添加服务")
@PostMapping("/addServe")
public JsonResult addServe(ServeVo vo){
int count = serveService.addServe(vo);
return JsonResult.success();
}
@ApiOperation("图片上传")
@PostMapping("/uploadFile")
public JsonResult upload(@RequestParam("file") @RequestPart MultipartFile file){
String upload = null;
try {
if (file != null) {
String fileName = file.getOriginalFilename();
if (!"".equals(fileName.trim())) {
File newFile = new File(fileName);
FileOutputStream os = new FileOutputStream(newFile);
os.write(file.getBytes());
os.close();
//把file里的内容复制到newFile中
file.transferTo(newFile);
upload = ossUtil.upload(newFile);
}
}
} catch (Exception e) {
e.printStackTrace();
}
String path = "https://zhiyun03.oss-cn-beijing.aliyuncs.com/"+ upload;
return JsonResult.success(path);
}
@ApiOperation("删除服务")
@PostMapping("/delServe")
public JsonResult delServe(Integer id){
int count = serveService.delServe(id);
return JsonResult.success();
}
@ApiOperation("根据Id查询")
@PostMapping("/queryServe")
public JsonResult<ServeVo> queryServe(Integer id){
ServeVo serveVo =serveService.queryById(id);
return JsonResult.success(serveVo);
}
@ApiOperation("更新服务")
@PostMapping("/updateServe")
public JsonResult updateServe(ServeVo vo){
int count =serveService.updateServe(vo);
return JsonResult.success();
}
}

@ -21,7 +21,7 @@ public class Serve {
* id
*/
@TableId(value = "id",type = IdType.AUTO)
private int id;
private Integer id;
/**
*
@ -32,8 +32,8 @@ public class Serve {
/**
*
*/
@TableField(value = "serve_biref")
private String serveBiref;
@TableField(value = "serve_brief")
private String serveBrief;
/**
*

@ -2,8 +2,16 @@ package com.zhiyun.zhiyun03.serve.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhiyun.zhiyun03.serve.entity.Serve;
import com.zhiyun.zhiyun03.serve.vo.ServeVo;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface ServeMapper extends BaseMapper<Serve> {
List<ServeVo> queryService();
int selectByName(String serveName);
int updateDownloadById(Serve serve);
}

@ -1,7 +1,18 @@
package com.zhiyun.zhiyun03.serve.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zhiyun.zhiyun03.course.vo.PageVO;
import com.zhiyun.zhiyun03.serve.entity.Serve;
import com.zhiyun.zhiyun03.serve.vo.ServeVo;
public interface ServeService extends IService<Serve> {
PageVO<ServeVo> queryServe(Integer page, Integer limit);
int addServe(ServeVo vo);
int delServe(Integer id);
ServeVo queryById(Integer id);
int updateServe(ServeVo vo);
}

@ -1,11 +1,143 @@
package com.zhiyun.zhiyun03.serve.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhiyun.zhiyun03.application.entity.Directory;
import com.zhiyun.zhiyun03.application.mapper.DirectoryMapper;
import com.zhiyun.zhiyun03.course.vo.PageVO;
import com.zhiyun.zhiyun03.invite.entity.Invite;
import com.zhiyun.zhiyun03.invite.vo.InviteVo;
import com.zhiyun.zhiyun03.serve.entity.Serve;
import com.zhiyun.zhiyun03.serve.mapper.ServeMapper;
import com.zhiyun.zhiyun03.serve.service.ServeService;
import com.zhiyun.zhiyun03.serve.vo.ServeVo;
import com.zhiyun.zhiyun03.utils.exception.ServiceException;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Service
public class ServeServiceImpl extends ServiceImpl<ServeMapper, Serve> implements ServeService {
@Resource
private ServeMapper serveMapper;
@Resource
private DirectoryMapper directoryMapper;
/*
*
* */
@Override
public PageVO<ServeVo> queryServe(Integer page, Integer limit) {
//开启分页
PageHelper.startPage(page,limit);
//查询所有下载数据
List<ServeVo> serveVoList = serveMapper.queryService();
PageInfo<ServeVo> serveVoPageInfo = new PageInfo<>(serveVoList);
PageVO<ServeVo> serveVoPageVO = new PageVO<>();
//获取当前页
serveVoPageVO.setCurrentPage(serveVoPageInfo.getPageNum());
//总条数
serveVoPageVO.setTotal(serveVoPageInfo.getTotal());
//分页数据
serveVoPageVO.setList(serveVoPageInfo.getList());
return serveVoPageVO;
}
/*
*
* */
@Override
public int addServe(ServeVo vo) {
//查询就业名称是否已经存在
int count = serveMapper.selectByName(vo.getServeName());
if (count>0)
{
throw new ServiceException("403","就业名已存在");
}
//将vo值传给download
Serve serve = new Serve();
BeanUtils.copyProperties(vo,serve);
//查询归属目录id
Integer dirId = directoryMapper.selectByName(vo.getDirName());
serve.setDirId(dirId);
serve.setServeUpdatetime(new Date());
//添加download
int insert = serveMapper.insert(serve);
if (insert>0)
{
return insert;
}else
{
throw new ServiceException("400","添加下载失败");
}
}
@Override
public int delServe(Integer id) {
if (id == null)
{
throw new ServiceException("400","查询id值为空");
}
//根据id删除
int count = serveMapper.deleteById(id);
if (count>0)
{
return count;
}else
{
throw new ServiceException("400","删除失败");
}
}
@Override
public ServeVo queryById(Integer id) {
//根据id查询数据
Serve serve = serveMapper.selectById(id);
//查询目录id
Directory directory = directoryMapper.selectById(serve.getDirId());
ServeVo serveVo = new ServeVo();
//复制给vo
BeanUtils.copyProperties(serve,serveVo);
serveVo.setDirName(directory.getDirName());
return serveVo;
}
@Override
public int updateServe(ServeVo vo) {
//查询更新的下载名是否存在
int sum = serveMapper.selectByName(vo.getServeName());
if (sum>0)
{
throw new ServiceException("403","下载已存在");
}
//将vo值传给download
Serve serve = new Serve();
BeanUtils.copyProperties(vo,serve);
//查询归属目录id
Integer dirId = directoryMapper.selectByName(vo.getDirName());
serve.setDirId(dirId);
serve.setServeUpdatetime(new Date());
//添加download
int updated = serveMapper.updateDownloadById(serve);
if (updated>0)
{
return updated;
}else
{
throw new ServiceException("400","更新失败");
}
}
}

@ -0,0 +1,36 @@
package com.zhiyun.zhiyun03.serve.vo;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
@Data
public class ServeVo {
/**
* id
*/
@TableId
private Integer id;
/**
*
*/
private String serveName;
/**
*
*/
private String serveBrief;
/**
*
*/
private String serveUrl;
/**
* id
*/
private String dirName;
/**
*
*/
private String serveImg;
}

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.zhiyun.zhiyun03.invite.mapper.InviteMapper">
<update id="updateDownloadById">
update invite
<set >
<if test="inviteName != null" >
invite_name=#{inviteName},
</if>
<if test="inviteBrief != null" >
invite_brief=#{inviteBrief},
</if>
<if test="inviteUrl != null" >
invite_url=#{inviteUrl},
</if>
<if test="dirId != null" >
dir_id=#{dirId},
</if>
<if test="inviteImg != null" >
invite_img=#{inviteImg}
</if>
</set>
<where>
<if test="id!=null">
id = #{id}
</if>
</where>
</update>
<select id="queryInvite" resultType="com.zhiyun.zhiyun03.invite.vo.InviteVo">
select i.id,i.invite_name,i.invite_brief,i.invite_url,d.dir_name
from invite as i
inner join
(select id,dir_name from directory) as d
on i.dir_id = d.id
</select>
<select id="selectByName" resultType="java.lang.Integer">
select count(1) from invite where invite_name =#{inviteName}
</select>
</mapper>

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.zhiyun.zhiyun03.serve.mapper.ServeMapper">
<update id="updateDownloadById">
update serve
<set >
<if test="serveName != null" >
serve_name=#{serveName},
</if>
<if test="serveBrief != null" >
serve_brief=#{serveBrief},
</if>
<if test="serveUrl != null" >
serve_url=#{serveUrl},
</if>
<if test="dirId != null" >
dir_id=#{dirId},
</if>
<if test="serveImg != null" >
serve_img=#{serveImg}
</if>
</set>
<where>
<if test="id!=null">
id = #{id}
</if>
</where>
</update>
<select id="queryService" resultType="com.zhiyun.zhiyun03.serve.vo.ServeVo">
select s.id,s.serve_name,s.serve_brief,s.serve_url,d.dir_name
from serve as s
inner join
(select id,dir_name from directory) as d
on s.dir_id = d.id
</select>
<select id="selectByName" resultType="java.lang.Integer">
select count(1) from serve where serve_name =#{serveName}
</select>
</mapper>
Loading…
Cancel
Save