parent
3225117afa
commit
04969a5460
@ -0,0 +1,28 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
const api_name = '/classroom-service-vod/admin/vod/subject'
|
||||
|
||||
export default {
|
||||
//课程分类列表
|
||||
getChildList(id) {
|
||||
return request({
|
||||
url: `${api_name}/getChildSubject/${id}`,
|
||||
method: 'get'
|
||||
})
|
||||
},
|
||||
|
||||
addSubject(pid, subjectName) {
|
||||
return request({
|
||||
url: `${api_name}/addSubject/${pid}`,
|
||||
method: 'post',
|
||||
params:subjectName
|
||||
})
|
||||
},
|
||||
|
||||
delSubject(id) {
|
||||
return request({
|
||||
url: `${api_name}/delSubject/${id}`,
|
||||
method: 'delete',
|
||||
})
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.xjs.apitools.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xjs.apitools.domain.ApiBeautyPicture;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xiejs
|
||||
* @since 2022-07-02
|
||||
*/
|
||||
public interface BeautyPictureMapper extends BaseMapper<ApiBeautyPicture> {
|
||||
|
||||
List<ApiBeautyPicture> getRandomPicture();
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.xjs.apitools.service;
|
||||
|
||||
import com.xjs.apitools.domain.ApiBeautyPicture;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xiejs
|
||||
* @since 2022-07-02
|
||||
*/
|
||||
public interface BeautyPictureService {
|
||||
/**
|
||||
* 获取随机的图片
|
||||
* @return list
|
||||
*/
|
||||
List<ApiBeautyPicture> getRandomPicture();
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.xjs.apitools.service.impl;
|
||||
|
||||
import com.xjs.apitools.domain.ApiBeautyPicture;
|
||||
import com.xjs.apitools.mapper.BeautyPictureMapper;
|
||||
import com.xjs.apitools.service.BeautyPictureService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xiejs
|
||||
* @since 2022-07-02
|
||||
*/
|
||||
@Service
|
||||
public class BeautyPictureServiceImpl implements BeautyPictureService {
|
||||
|
||||
@Resource
|
||||
private BeautyPictureMapper beautyPictureMapper;
|
||||
|
||||
@Override
|
||||
public List<ApiBeautyPicture> getRandomPicture() {
|
||||
List<ApiBeautyPicture> beautyPictureList = beautyPictureMapper.getRandomPicture();
|
||||
|
||||
return beautyPictureList;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?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.xjs.apitools.mapper.BeautyPictureMapper">
|
||||
|
||||
<resultMap id="beautyPictureMap" type="com.xjs.apitools.domain.ApiBeautyPicture">
|
||||
<result property="id" column="id"/>
|
||||
<result property="imageUrl" column="url"/>
|
||||
<result property="imageSize" column="size"/>
|
||||
<result property="imageFileLength" column="length"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="getRandomPicture" resultMap="beautyPictureMap">
|
||||
SELECT url
|
||||
FROM api_beauty_picture
|
||||
ORDER BY RAND()
|
||||
LIMIT 10
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,90 @@
|
||||
package com.xjs.classroom.vod.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.xjs.classroom.model.vod.Subject;
|
||||
import com.xjs.classroom.vod.service.ISubjectService;
|
||||
import com.xjs.exception.BusinessException;
|
||||
import com.xjs.utils.Result;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程科目 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xiejs
|
||||
* @since 2022-06-30
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/admin/vod/subject")
|
||||
@Api(tags = "课程科目接口")
|
||||
public class SubjectController {
|
||||
|
||||
@Autowired
|
||||
private ISubjectService subjectService;
|
||||
|
||||
//课程分类列表
|
||||
//懒加载,每次查询一层数据
|
||||
@ApiOperation("课程分类列表")
|
||||
@GetMapping("getChildSubject/{id}")
|
||||
public Result<List<Subject>> getChildSubject(@PathVariable Long id) {
|
||||
List<Subject> list = subjectService.selectSubjectList(id);
|
||||
return Result.ok(list);
|
||||
}
|
||||
|
||||
@ApiOperation("课程分类添加")
|
||||
@PostMapping("addSubject/{pid}")
|
||||
public Result<Subject> addSubject(@PathVariable Long pid, @RequestParam("subjectName") String subjectName) {
|
||||
if (pid == null) {
|
||||
pid = 0L;
|
||||
}
|
||||
Subject subject = new Subject();
|
||||
subject.setParentId(pid);
|
||||
subject.setTitle(subjectName);
|
||||
subjectService.save(subject);
|
||||
|
||||
return Result.ok(null);
|
||||
}
|
||||
|
||||
@ApiOperation("课程分类删除")
|
||||
@DeleteMapping("delSubject/{id}")
|
||||
public Result<Subject> delSubject(@PathVariable("id") Long id) {
|
||||
Subject subject_p = subjectService.getById(id);
|
||||
|
||||
List<Subject> list = subjectService.list(new LambdaQueryWrapper<Subject>().eq(Subject::getParentId, subject_p.getId()));
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
subjectService.removeById(id);
|
||||
return Result.ok(null);
|
||||
}else {
|
||||
throw new BusinessException("存在子节点");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//课程分类导出
|
||||
@ApiOperation("课程分类导出")
|
||||
@GetMapping("exportData")
|
||||
public void exportData(HttpServletResponse response) {
|
||||
subjectService.exportData(response);
|
||||
}
|
||||
|
||||
//课程分类导入
|
||||
@ApiOperation("课程分类导入")
|
||||
@PostMapping("importData")
|
||||
public Result importData(MultipartFile file) {
|
||||
subjectService.importData(file);
|
||||
return Result.ok(null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
package com.xjs.classroom.vod.listener;
|
||||
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.event.AnalysisEventListener;
|
||||
import com.xjs.classroom.model.vod.Subject;
|
||||
import com.xjs.classroom.vo.vod.SubjectEeVo;
|
||||
import com.xjs.classroom.vod.mapper.SubjectMapper;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Component
|
||||
public class SubjectListener extends AnalysisEventListener<SubjectEeVo> {
|
||||
|
||||
//注入mapper
|
||||
@Resource
|
||||
private SubjectMapper subjectMapper;
|
||||
|
||||
//一行一行,从第二行
|
||||
@Override
|
||||
public void invoke(SubjectEeVo subjectEeVo, AnalysisContext analysisContext) {
|
||||
Subject subject = new Subject();
|
||||
// SubjectEeVo -- Subject
|
||||
BeanUtils.copyProperties(subjectEeVo,subject);
|
||||
//添加
|
||||
subjectMapper.insert(subject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.xjs.classroom.vod.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xjs.classroom.model.vod.Subject;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程科目 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xiejs
|
||||
* @since 2022-06-30
|
||||
*/
|
||||
public interface SubjectMapper extends BaseMapper<Subject> {
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
<?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.xjs.classroom.vod.mapper.SubjectMapper">
|
||||
|
||||
</mapper>
|
@ -0,0 +1,32 @@
|
||||
package com.xjs.classroom.vod.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xjs.classroom.model.vod.Subject;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 课程科目 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xiejs
|
||||
* @since 2022-06-30
|
||||
*/
|
||||
public interface ISubjectService extends IService<Subject> {
|
||||
|
||||
/**
|
||||
* 查询科目集合
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<Subject> selectSubjectList(Long id);
|
||||
|
||||
//课程分类导出
|
||||
void exportData(HttpServletResponse response);
|
||||
|
||||
//课程分类导入
|
||||
void importData(MultipartFile file);
|
||||
}
|
Loading…
Reference in new issue