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,140 @@
|
||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-table
|
||||||
|
:data="list"
|
||||||
|
style="width: 100%"
|
||||||
|
row-key="id"
|
||||||
|
border
|
||||||
|
lazy
|
||||||
|
:load="load"
|
||||||
|
:tree-props="{children: 'children', hasChildren: 'hasChildren'}">
|
||||||
|
<el-table-column
|
||||||
|
prop="title"
|
||||||
|
label="名称"
|
||||||
|
width="150">
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
prop="createTime"
|
||||||
|
width="200"
|
||||||
|
label="创建时间">
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" width="200" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
|
||||||
|
<el-button @click="open(scope.row)" type="text" size="mini">添加</el-button>
|
||||||
|
|
||||||
|
<el-button type="text" size="mini">修改</el-button>
|
||||||
|
<el-button type="text" size="mini" @click="delSubject(scope.row.id)">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<div class="el-toolbar">
|
||||||
|
<div class="el-toolbar-body" style="justify-content: flex-start;">
|
||||||
|
<el-button type="text" @click="exportData"><i class="fa fa-plus"/> 导出</el-button>
|
||||||
|
<el-button type="text" @click="importData"><i class="fa fa-plus"/> 导入</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-dialog title="导入" :visible.sync="dialogImportVisible" width="480px">
|
||||||
|
<el-form label-position="right" label-width="170px">
|
||||||
|
<el-form-item label="文件">
|
||||||
|
<el-upload
|
||||||
|
:multiple="false"
|
||||||
|
:on-success="onUploadSuccess"
|
||||||
|
:action="'http://localhost:8080/classroom-service-vod/admin/vod/subject/importData'"
|
||||||
|
class="upload-demo">
|
||||||
|
<el-button size="small" type="primary">点击上传</el-button>
|
||||||
|
<div slot="tip" class="el-upload__tip">只能上传xls文件,且不超过500kb</div>
|
||||||
|
</el-upload>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button @click="dialogImportVisible = false">取消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import subjectApi from '@/api/classroom/vod/subject'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dialogImportVisible: false,
|
||||||
|
list: [], //数据字典列表数组
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getSubList(0)
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
importData() {
|
||||||
|
this.dialogImportVisible = true
|
||||||
|
},
|
||||||
|
onUploadSuccess(response, file) {
|
||||||
|
this.$message.info('上传成功')
|
||||||
|
this.dialogImportVisible = false
|
||||||
|
this.getSubList(0)
|
||||||
|
},
|
||||||
|
|
||||||
|
//导出
|
||||||
|
exportData() {
|
||||||
|
window.open("http://localhost:8080/classroom-service-vod/admin/vod/subject/exportData")
|
||||||
|
},
|
||||||
|
//数据字典列表
|
||||||
|
getSubList(id) {
|
||||||
|
subjectApi.getChildList(id)
|
||||||
|
.then(response => {
|
||||||
|
this.list = response.data
|
||||||
|
})
|
||||||
|
},
|
||||||
|
load(tree, treeNode, resolve) {
|
||||||
|
subjectApi.getChildList(tree.id).then(response => {
|
||||||
|
resolve(response.data)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
addSubject(data, params) {
|
||||||
|
|
||||||
|
|
||||||
|
subjectApi.addSubject(data.id, params).then(res => {
|
||||||
|
this.getSubList(0)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
open(data) {
|
||||||
|
this.$prompt('请输入名称', '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
}).then(({value}) => {
|
||||||
|
|
||||||
|
let params = {
|
||||||
|
subjectName: value
|
||||||
|
}
|
||||||
|
this.addSubject(data, params)
|
||||||
|
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: "添加成功"
|
||||||
|
});
|
||||||
|
}).catch(() => {
|
||||||
|
this.$message({
|
||||||
|
type: 'info',
|
||||||
|
message: '取消输入'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
delSubject(id) {
|
||||||
|
subjectApi.delSubject(id).then(res =>{
|
||||||
|
this.$modal.notifySuccess("删除成功")
|
||||||
|
this.list=[]
|
||||||
|
this.getSubList(0)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
@ -3,16 +3,16 @@
|
||||||
<!-- 输入表单 -->
|
<!-- 输入表单 -->
|
||||||
<el-form label-width="120px" :model="teacher" :rules="rules" ref="form">
|
<el-form label-width="120px" :model="teacher" :rules="rules" ref="form">
|
||||||
<el-form-item label="讲师名称" prop="name">
|
<el-form-item label="讲师名称" prop="name">
|
||||||
<el-input v-model="teacher.name"/>
|
<el-input v-model="teacher.name" :disabled="onlyRead"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="入驻时间" prop="joinDate">
|
<el-form-item label="入驻时间" prop="joinDate">
|
||||||
<el-date-picker v-model="teacher.joinDate" value-format="yyyy-MM-dd"/>
|
<el-date-picker v-model="teacher.joinDate" value-format="yyyy-MM-dd" :disabled="onlyRead"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="讲师排序" prop="sort">
|
<el-form-item label="讲师排序" prop="sort">
|
||||||
<el-input-number v-model="teacher.sort" :min="0"/>
|
<el-input-number v-model="teacher.sort" :min="0" :disabled="onlyRead"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="讲师头衔" prop="level">
|
<el-form-item label="讲师头衔" prop="level">
|
||||||
<el-select v-model="teacher.level">
|
<el-select v-model="teacher.level" :disabled="onlyRead">
|
||||||
<!--
|
<!--
|
||||||
数据类型一定要和取出的json中的一致,否则没法回填
|
数据类型一定要和取出的json中的一致,否则没法回填
|
||||||
因此,这里value使用动态绑定的值,保证其数据类型是number
|
因此,这里value使用动态绑定的值,保证其数据类型是number
|
||||||
|
|
@ -22,16 +22,17 @@
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="讲师简介" prop="intro">
|
<el-form-item label="讲师简介" prop="intro">
|
||||||
<el-input v-model="teacher.intro"/>
|
<el-input v-model="teacher.intro" :disabled="onlyRead"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="讲师资历" prop="career">
|
<el-form-item label="讲师资历" prop="career">
|
||||||
<el-input v-model="teacher.career" :rows="10" type="textarea"/>
|
<el-input v-model="teacher.career" :rows="10" type="textarea" :disabled="onlyRead"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<!-- 讲师头像 -->
|
<!-- 讲师头像 -->
|
||||||
<!-- 讲师头像 -->
|
<!-- 讲师头像 -->
|
||||||
<el-form-item label="讲师头像" prop="avatar" >
|
<el-form-item label="讲师头像" prop="avatar" >
|
||||||
<el-upload
|
<el-upload
|
||||||
|
:disabled=onlyRead
|
||||||
ref="avatar"
|
ref="avatar"
|
||||||
:on-success="handleAvatarSuccess"
|
:on-success="handleAvatarSuccess"
|
||||||
:before-upload="beforeAvatarUpload"
|
:before-upload="beforeAvatarUpload"
|
||||||
|
|
@ -48,7 +49,7 @@
|
||||||
</el-upload>
|
</el-upload>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item>
|
<el-form-item v-if="!onlyRead">
|
||||||
<el-button type="primary" @click="saveOrUpdate()">保存</el-button>
|
<el-button type="primary" @click="saveOrUpdate()">保存</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
@ -69,6 +70,8 @@ export default {
|
||||||
avatar: null
|
avatar: null
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onlyRead: false,
|
||||||
|
|
||||||
fileList: [],
|
fileList: [],
|
||||||
|
|
||||||
rules: {
|
rules: {
|
||||||
|
|
@ -102,6 +105,7 @@ export default {
|
||||||
if (this.$route.query.id) {
|
if (this.$route.query.id) {
|
||||||
const id = this.$route.query.id
|
const id = this.$route.query.id
|
||||||
this.fetchDataById(id)
|
this.fetchDataById(id)
|
||||||
|
this.onlyRead = this.$route.query.onlyRead
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
|
|
||||||
<!--查询表单-->
|
<!--查询表单-->
|
||||||
<el-card class="operate-container" shadow="never">
|
<el-card class="operate-container" shadow="hover">
|
||||||
<el-form :inline="true" class="demo-form-inline">
|
<el-form :inline="true" class="demo-form-inline" style="height: 40px">
|
||||||
<el-form-item label="名称">
|
<el-form-item label="名称">
|
||||||
<el-input v-model="searchObj.name" placeholder="讲师名"/>
|
<el-input v-model="searchObj.name" placeholder="讲师名"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<!-- 工具按钮 -->
|
<!-- 工具按钮 -->
|
||||||
<el-card class="operate-container" shadow="never">
|
<el-card class="operate-container" shadow="hover">
|
||||||
<i class="el-icon-tickets" style="margin-top: 5px"></i>
|
<i class="el-icon-tickets" style="margin-top: 5px"></i>
|
||||||
<span style="margin-top: 5px">数据列表</span>
|
<span style="margin-top: 5px">数据列表</span>
|
||||||
<el-button class="btn-add" @click="add()" style="margin-left: 10px;">添加</el-button>
|
<el-button class="btn-add" @click="add()" style="margin-left: 10px;">添加</el-button>
|
||||||
|
|
@ -67,6 +67,9 @@
|
||||||
<el-table-column prop="joinDate" label="入驻时间" width="160"/>
|
<el-table-column prop="joinDate" label="入驻时间" width="160"/>
|
||||||
<el-table-column label="操作" width="200" align="center">
|
<el-table-column label="操作" width="200" align="center">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
|
<router-link :to="{path:'/classroom/classroom-teacher/teacher-form/',query:{id:scope.row.id,onlyRead:true}}">
|
||||||
|
<el-button type="text" size="mini">查看</el-button>
|
||||||
|
</router-link>
|
||||||
<router-link :to="{path:'/classroom/classroom-teacher/teacher-form/',query:{id:scope.row.id}}">
|
<router-link :to="{path:'/classroom/classroom-teacher/teacher-form/',query:{id:scope.row.id}}">
|
||||||
<el-button type="text" size="mini">修改</el-button>
|
<el-button type="text" size="mini">修改</el-button>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
package com.xjs.apitools.domain;
|
package com.xjs.apitools.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* api mm图片实体
|
* api mm图片实体
|
||||||
|
|
@ -11,24 +16,35 @@ import java.io.Serializable;
|
||||||
* @since 2022-01-19
|
* @since 2022-01-19
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@TableName("api_beauty_picture")
|
||||||
public class ApiBeautyPicture implements Serializable {
|
public class ApiBeautyPicture implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 福利图片链接
|
* 福利图片链接
|
||||||
*/
|
*/
|
||||||
|
@TableField("url")
|
||||||
private String imageUrl;
|
private String imageUrl;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 福利图片尺寸
|
* 福利图片尺寸
|
||||||
*/
|
*/
|
||||||
|
@TableField("size")
|
||||||
private String imageSize;
|
private String imageSize;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 福利图片文件大小
|
* 福利图片文件大小
|
||||||
*/
|
*/
|
||||||
|
@TableField("length")
|
||||||
private String imageFileLength;
|
private String imageFileLength;
|
||||||
|
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private Date createTime;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
}
|
||||||
|
|
@ -4,21 +4,27 @@ import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.date.ChineseDate;
|
import cn.hutool.core.date.ChineseDate;
|
||||||
import cn.hutool.core.date.DateTime;
|
import cn.hutool.core.date.DateTime;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.xjs.apitools.domain.*;
|
import com.xjs.apitools.domain.*;
|
||||||
import com.xjs.apitools.factory.ApiToolsFactory;
|
import com.xjs.apitools.factory.ApiToolsFactory;
|
||||||
import com.xjs.apitools.factory.impl.*;
|
import com.xjs.apitools.factory.impl.*;
|
||||||
|
import com.xjs.apitools.mapper.BeautyPictureMapper;
|
||||||
import com.xjs.apitools.service.ApiToolsService;
|
import com.xjs.apitools.service.ApiToolsService;
|
||||||
import com.xjs.exception.ApiException;
|
import com.xjs.exception.ApiException;
|
||||||
import com.xjs.utils.WeekUtils;
|
import com.xjs.utils.WeekUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -35,6 +41,9 @@ public class ApiToolsServiceImpl implements ApiToolsService {
|
||||||
*/
|
*/
|
||||||
public static final String KB = "KB";
|
public static final String KB = "KB";
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BeautyPictureMapper beautyPictureMapper;
|
||||||
|
|
||||||
private ApiToolsFactory<ApiHoliday, Object> holidayFactory;
|
private ApiToolsFactory<ApiHoliday, Object> holidayFactory;
|
||||||
private ApiToolsFactory<ApiMobileBelong, RequestBody> mobileBelongFactory;
|
private ApiToolsFactory<ApiMobileBelong, RequestBody> mobileBelongFactory;
|
||||||
private ApiToolsFactory<ApiNowWeather, RequestBody> nowWeatherFactory;
|
private ApiToolsFactory<ApiNowWeather, RequestBody> nowWeatherFactory;
|
||||||
|
|
@ -166,9 +175,9 @@ public class ApiToolsServiceImpl implements ApiToolsService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ApiBeautyPicture> getBeautyPictureList() {
|
public List<ApiBeautyPicture> getBeautyPictureList() {
|
||||||
List<ApiBeautyPicture> apiBeautyPictureList = beautyPictureFactory.apiDataList();
|
List<ApiBeautyPicture> apiBeautyPictureList = Optional.ofNullable(beautyPictureFactory.apiDataList()).orElseGet(ArrayList::new);
|
||||||
if (CollUtil.isEmpty(apiBeautyPictureList)) {
|
if (CollUtil.isEmpty(apiBeautyPictureList)) {
|
||||||
throw new ApiException("获取的mm图片数据为空");
|
return apiBeautyPictureList;
|
||||||
}
|
}
|
||||||
apiBeautyPictureList.forEach(bp -> {
|
apiBeautyPictureList.forEach(bp -> {
|
||||||
String imageFileLength = bp.getImageFileLength();
|
String imageFileLength = bp.getImageFileLength();
|
||||||
|
|
@ -176,8 +185,15 @@ public class ApiToolsServiceImpl implements ApiToolsService {
|
||||||
BigDecimal decimal = new BigDecimal(imageFileLength);
|
BigDecimal decimal = new BigDecimal(imageFileLength);
|
||||||
BigDecimal divide = decimal.divide(new BigDecimal(1024), 0, RoundingMode.HALF_UP);
|
BigDecimal divide = decimal.divide(new BigDecimal(1024), 0, RoundingMode.HALF_UP);
|
||||||
bp.setImageFileLength(divide.toPlainString() + KB);
|
bp.setImageFileLength(divide.toPlainString() + KB);
|
||||||
|
|
||||||
|
//保存到数据库
|
||||||
|
List<ApiBeautyPicture> pictureList = beautyPictureMapper.selectList(new LambdaQueryWrapper<ApiBeautyPicture>().eq(ApiBeautyPicture::getImageUrl, bp.getImageUrl()));
|
||||||
|
if (CollectionUtils.isEmpty(pictureList)) {
|
||||||
|
beautyPictureMapper.insert(bp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return apiBeautyPictureList;
|
return apiBeautyPictureList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -10,6 +10,7 @@ import com.ruoyi.system.api.domain.SysOperLog;
|
||||||
import com.ruoyi.system.api.model.LoginUser;
|
import com.ruoyi.system.api.model.LoginUser;
|
||||||
import com.xjs.apitools.domain.ApiBeautyPicture;
|
import com.xjs.apitools.domain.ApiBeautyPicture;
|
||||||
import com.xjs.apitools.service.ApiToolsService;
|
import com.xjs.apitools.service.ApiToolsService;
|
||||||
|
import com.xjs.apitools.service.BeautyPictureService;
|
||||||
import com.xjs.business.english.RemoteEnglishFeign;
|
import com.xjs.business.english.RemoteEnglishFeign;
|
||||||
import com.xjs.business.english.domain.EnglishWordDTO;
|
import com.xjs.business.english.domain.EnglishWordDTO;
|
||||||
import com.xjs.business.log.RemoteLogFeign;
|
import com.xjs.business.log.RemoteLogFeign;
|
||||||
|
|
@ -78,6 +79,8 @@ public class IndexController {
|
||||||
private ApiToolsService apiToolsService;
|
private ApiToolsService apiToolsService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IPService ipService;
|
private IPService ipService;
|
||||||
|
@Autowired
|
||||||
|
private BeautyPictureService beautyPictureService;
|
||||||
|
|
||||||
@GetMapping("showData")
|
@GetMapping("showData")
|
||||||
@ApiOperation("展示数据")
|
@ApiOperation("展示数据")
|
||||||
|
|
@ -174,11 +177,13 @@ public class IndexController {
|
||||||
.map(ApiBeautyPicture::getImageUrl).collect(Collectors.toList()), executor);
|
.map(ApiBeautyPicture::getImageUrl).collect(Collectors.toList()), executor);
|
||||||
|
|
||||||
CompletableFuture<List<String>> twoFuture = CompletableFuture.supplyAsync(() ->
|
CompletableFuture<List<String>> twoFuture = CompletableFuture.supplyAsync(() ->
|
||||||
apiToolsService.getBeautyPictureList().stream()
|
//apiToolsService.getBeautyPictureList().stream()
|
||||||
|
beautyPictureService.getRandomPicture().stream()
|
||||||
.map(ApiBeautyPicture::getImageUrl).collect(Collectors.toList()), executor);
|
.map(ApiBeautyPicture::getImageUrl).collect(Collectors.toList()), executor);
|
||||||
|
|
||||||
CompletableFuture<List<String>> threeFuture = CompletableFuture.supplyAsync(() ->
|
CompletableFuture<List<String>> threeFuture = CompletableFuture.supplyAsync(() ->
|
||||||
apiToolsService.getBeautyPictureList().stream()
|
//apiToolsService.getBeautyPictureList().stream()
|
||||||
|
beautyPictureService.getRandomPicture().stream()
|
||||||
.map(ApiBeautyPicture::getImageUrl).collect(Collectors.toList()), executor);
|
.map(ApiBeautyPicture::getImageUrl).collect(Collectors.toList()), executor);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,112 @@
|
||||||
|
package com.xjs.classroom.vod.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.excel.EasyExcel;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.xjs.classroom.model.vod.Subject;
|
||||||
|
import com.xjs.classroom.vo.vod.SubjectEeVo;
|
||||||
|
import com.xjs.classroom.vod.listener.SubjectListener;
|
||||||
|
import com.xjs.classroom.vod.mapper.SubjectMapper;
|
||||||
|
import com.xjs.classroom.vod.service.ISubjectService;
|
||||||
|
import com.xjs.exception.BusinessException;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 课程科目 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-06-30
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> implements ISubjectService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SubjectListener subjectListener;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Subject> selectSubjectList(Long id) {
|
||||||
|
|
||||||
|
LambdaQueryWrapper<Subject> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
wrapper.eq(Subject::getParentId, id);
|
||||||
|
|
||||||
|
List<Subject> subjectList = baseMapper.selectList(wrapper);
|
||||||
|
//subjectList遍历,得到每个subject对象,判断是否有下一层数据,有hasChildren=true
|
||||||
|
for (Subject subject : subjectList) {
|
||||||
|
//获取subject的id值
|
||||||
|
Long subjectId = subject.getId();
|
||||||
|
//查询
|
||||||
|
boolean isChild = this.isChildren(subjectId);
|
||||||
|
//封装到对象里面
|
||||||
|
subject.setHasChildren(isChild);
|
||||||
|
}
|
||||||
|
return subjectList;
|
||||||
|
}
|
||||||
|
|
||||||
|
//课程分类导出
|
||||||
|
@Override
|
||||||
|
public void exportData(HttpServletResponse response) {
|
||||||
|
try {
|
||||||
|
//设置下载信息
|
||||||
|
response.setContentType("application/vnd.ms-excel");
|
||||||
|
response.setCharacterEncoding("utf-8");
|
||||||
|
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
|
||||||
|
String fileName = URLEncoder.encode("课程分类", "UTF-8");
|
||||||
|
response.setHeader("Content-disposition", "attachment;filename="+ fileName + ".xlsx");
|
||||||
|
|
||||||
|
//查询课程分类表所有数据
|
||||||
|
List<Subject> subjectList = baseMapper.selectList(null);
|
||||||
|
|
||||||
|
//List<Subject> --- List<SubjectEeVo>
|
||||||
|
List<SubjectEeVo> subjectEeVoList = new ArrayList<>();
|
||||||
|
for (Subject subject: subjectList) {
|
||||||
|
SubjectEeVo subjectEeVo = new SubjectEeVo();
|
||||||
|
// subjectEeVo.setId(subject.getId());
|
||||||
|
// subjectEeVo.setParentId(subject.getParentId());
|
||||||
|
BeanUtils.copyProperties(subject,subjectEeVo);
|
||||||
|
subjectEeVoList.add(subjectEeVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
//EasyExcel写操作
|
||||||
|
EasyExcel.write(response.getOutputStream(), SubjectEeVo.class)
|
||||||
|
.sheet("课程分类")
|
||||||
|
.doWrite(subjectEeVoList);
|
||||||
|
}catch(Exception e) {
|
||||||
|
throw new BusinessException("导出失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//课程分类导入
|
||||||
|
@Override
|
||||||
|
public void importData(MultipartFile file) {
|
||||||
|
try {
|
||||||
|
EasyExcel.read(file.getInputStream(),
|
||||||
|
SubjectEeVo.class,
|
||||||
|
subjectListener).sheet().doRead();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new BusinessException("导入失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//判断是否有下一层数据
|
||||||
|
private boolean isChildren(Long subjectId) {
|
||||||
|
QueryWrapper<Subject> wrapper = new QueryWrapper<>();
|
||||||
|
wrapper.eq("parent_id", subjectId);
|
||||||
|
Long count = baseMapper.selectCount(wrapper);
|
||||||
|
// 1>0 true 0>0 false
|
||||||
|
return count > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -8,7 +8,7 @@ public class CodeGet {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
FastAutoGenerator.create("jdbc:mysql://localhost:3306/xjs-srb-core?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8",
|
FastAutoGenerator.create("jdbc:mysql://localhost:3306/xjs-classroom?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8",
|
||||||
"root", "root")
|
"root", "root")
|
||||||
.globalConfig(builder -> {
|
.globalConfig(builder -> {
|
||||||
builder.author("xiejs") // 设置作者
|
builder.author("xiejs") // 设置作者
|
||||||
|
|
@ -22,7 +22,7 @@ public class CodeGet {
|
||||||
.pathInfo(Collections.singletonMap(OutputFile.mapperXml, "D:\\Dev\\IdeaPerject\\GitHub\\Cloud\\xjs-business\\xjs-project-classroom\\classroom-service\\classroom-service-vod\\src\\main\\resources\\mapper")); // 设置mapperXml生成路径
|
.pathInfo(Collections.singletonMap(OutputFile.mapperXml, "D:\\Dev\\IdeaPerject\\GitHub\\Cloud\\xjs-business\\xjs-project-classroom\\classroom-service\\classroom-service-vod\\src\\main\\resources\\mapper")); // 设置mapperXml生成路径
|
||||||
})
|
})
|
||||||
.strategyConfig(builder -> {
|
.strategyConfig(builder -> {
|
||||||
builder.addInclude("integral_grade")
|
builder.addInclude("subject")
|
||||||
.entityBuilder()
|
.entityBuilder()
|
||||||
.enableLombok()
|
.enableLombok()
|
||||||
.logicDeleteColumnName("is_deleted")
|
.logicDeleteColumnName("is_deleted")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue