main
parent
2d5ca1f2a8
commit
1658f5ca18
@ -0,0 +1,9 @@
|
|||||||
|
package com.zhiyun.zhiyun03.course.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.zhiyun.zhiyun03.course.entity.Course;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface CourseMapper extends BaseMapper<Course> {
|
||||||
|
}
|
@ -1,15 +1,17 @@
|
|||||||
package com.zhiyun.zhiyun03.course.service;
|
package com.zhiyun.zhiyun03.course.service;
|
||||||
|
|
||||||
import com.zhiyun.zhiyun03.course.entity.Course;
|
import com.zhiyun.zhiyun03.course.entity.Course;
|
||||||
|
import com.zhiyun.zhiyun03.course.vo.CourseVo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface CourseService {
|
public interface CourseService {
|
||||||
public void addCourse(Course course);
|
// public void addCourse(Course course);
|
||||||
|
//
|
||||||
|
// void delCourseById(Integer id);
|
||||||
|
//
|
||||||
|
// void updateById(Course course);
|
||||||
|
|
||||||
void delCourseById(Integer id);
|
|
||||||
|
|
||||||
void updateById(Course course);
|
List<CourseVo> queryCourse();
|
||||||
|
|
||||||
List<Course> selectAll();
|
|
||||||
}
|
}
|
||||||
|
@ -1,36 +1,76 @@
|
|||||||
package com.zhiyun.zhiyun03.course.service.impl;
|
package com.zhiyun.zhiyun03.course.service.impl;
|
||||||
|
|
||||||
import com.zhiyun.zhiyun03.course.dao.CourseDAO;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
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.application.util.ConvertUtil;
|
||||||
import com.zhiyun.zhiyun03.course.entity.Course;
|
import com.zhiyun.zhiyun03.course.entity.Course;
|
||||||
import com.zhiyun.zhiyun03.course.service.CourseService;
|
import com.zhiyun.zhiyun03.course.service.CourseService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import com.zhiyun.zhiyun03.course.vo.CourseVo;
|
||||||
|
import com.zhiyun.zhiyun03.course.mapper.CourseMapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class CourseServiceImpl implements CourseService {
|
public class CourseServiceImpl extends ServiceImpl<CourseMapper,Course> implements CourseService {
|
||||||
|
|
||||||
@Autowired
|
@Resource
|
||||||
private CourseDAO courseDAO;
|
private CourseMapper courseMapper;
|
||||||
|
|
||||||
@Override
|
@Resource
|
||||||
public void addCourse(Course course) {
|
DirectoryMapper directoryMapper;
|
||||||
courseDAO.insert(course);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delCourseById(Integer id) {
|
|
||||||
courseDAO.deleteByPrimaryKey(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateById(Course course) {
|
|
||||||
courseDAO.updateByPrimaryKey(course);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用中心查询
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Course> selectAll() {
|
public List<CourseVo> queryCourse() {
|
||||||
return courseDAO.selectAll();
|
QueryWrapper<Course> qwa=new QueryWrapper<>();
|
||||||
|
List<Course> courses = courseMapper.selectList(qwa);
|
||||||
|
QueryWrapper<Directory> qwd=new QueryWrapper<>();
|
||||||
|
List<Directory> directories = directoryMapper.selectList(qwd);
|
||||||
|
ConvertUtil convertUtil=new ConvertUtil();
|
||||||
|
List<CourseVo> applicationVos = convertUtil.entityToVoList(courses, CourseVo.class);
|
||||||
|
|
||||||
|
for (int i = 0; i < courses.size(); i++) {
|
||||||
|
for (int j = 0; j <directories.size() ; j++) {
|
||||||
|
if(courses.get(i).getDirId()==directories.get(i).getId()){
|
||||||
|
applicationVos.get(i).setDirName(directories.get(i).getDirName());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return applicationVos;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public void addCourse(Course course) {
|
||||||
|
// courseDAO.insert(course);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void delCourseById(Integer id) {
|
||||||
|
// courseDAO.deleteByPrimaryKey(id);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void updateById(Course course) {
|
||||||
|
// courseDAO.updateByPrimaryKey(course);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public List<CourseVo> queryCourse() {
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public List<Course> selectAll() {
|
||||||
|
// return courseDAO.selectAll();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.zhiyun.zhiyun03.course.vo;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CourseVo{
|
||||||
|
@TableId
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
private String courseName;
|
||||||
|
|
||||||
|
private String courseBrief;
|
||||||
|
|
||||||
|
private String courseUrl;
|
||||||
|
|
||||||
|
private String dirName;
|
||||||
|
|
||||||
|
private String appIcon;
|
||||||
|
}
|
@ -1,33 +0,0 @@
|
|||||||
package com.zhiyun.zhiyun03.directory.controller;
|
|
||||||
|
|
||||||
import com.zhiyun.zhiyun03.course.common.JsonResult;
|
|
||||||
import com.zhiyun.zhiyun03.directory.entity.Directory;
|
|
||||||
import com.zhiyun.zhiyun03.directory.servcie.DirectoryService;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@Api("目录")
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api/directory")
|
|
||||||
public class DirectoryController {
|
|
||||||
@Autowired
|
|
||||||
private DirectoryService directoryService;
|
|
||||||
|
|
||||||
@ApiOperation("添加目录")
|
|
||||||
@PostMapping("/add")
|
|
||||||
public JsonResult addDirectory(Directory directory){
|
|
||||||
directoryService.addDirectory(directory);
|
|
||||||
return JsonResult.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
package com.zhiyun.zhiyun03.directory.servcie;
|
|
||||||
|
|
||||||
import com.zhiyun.zhiyun03.directory.entity.Directory;
|
|
||||||
|
|
||||||
public interface DirectoryService {
|
|
||||||
void addDirectory(Directory directory);
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
package com.zhiyun.zhiyun03.directory.servcie.impl;
|
|
||||||
|
|
||||||
import com.zhiyun.zhiyun03.course.dao.DirectoryDAO;
|
|
||||||
import com.zhiyun.zhiyun03.directory.entity.Directory;
|
|
||||||
import com.zhiyun.zhiyun03.directory.servcie.DirectoryService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class DirectoryServiceImpl implements DirectoryService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private DirectoryDAO directoryDAO;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addDirectory(Directory directory) {
|
|
||||||
directoryDAO.insert(directory);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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.zhiyun.zhiyun03.application.mapper.DirectoryMapper">
|
||||||
|
|
||||||
|
</mapper>
|
@ -1,63 +0,0 @@
|
|||||||
<?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.course.dao.DirectoryDAO">
|
|
||||||
<resultMap id="BaseResultMap" type="com.zhiyun.zhiyun03.directory.entity.Directory">
|
|
||||||
<id column="id" jdbcType="INTEGER" property="id" />
|
|
||||||
<result column="dir_name" jdbcType="VARCHAR" property="dirName" />
|
|
||||||
<result column="dir_img" jdbcType="VARCHAR" property="dirImg" />
|
|
||||||
</resultMap>
|
|
||||||
<sql id="Base_Column_List">
|
|
||||||
id, dir_name, dir_img
|
|
||||||
</sql>
|
|
||||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
|
||||||
select
|
|
||||||
<include refid="Base_Column_List" />
|
|
||||||
from directory
|
|
||||||
where id = #{id,jdbcType=INTEGER}
|
|
||||||
</select>
|
|
||||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
|
||||||
delete from directory
|
|
||||||
where id = #{id,jdbcType=INTEGER}
|
|
||||||
</delete>
|
|
||||||
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.zhiyun.zhiyun03.directory.entity.Directory" useGeneratedKeys="true">
|
|
||||||
insert into directory (id,dir_name, dir_img)
|
|
||||||
values (#{id},#{dirName,jdbcType=VARCHAR}, #{dirImg,jdbcType=VARCHAR})
|
|
||||||
</insert>
|
|
||||||
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.zhiyun.zhiyun03.directory.entity.Directory" useGeneratedKeys="true">
|
|
||||||
insert into directory
|
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="dirName != null">
|
|
||||||
dir_name,
|
|
||||||
</if>
|
|
||||||
<if test="dirImg != null">
|
|
||||||
dir_img,
|
|
||||||
</if>
|
|
||||||
</trim>
|
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
||||||
<if test="dirName != null">
|
|
||||||
#{dirName,jdbcType=VARCHAR},
|
|
||||||
</if>
|
|
||||||
<if test="dirImg != null">
|
|
||||||
#{dirImg,jdbcType=VARCHAR},
|
|
||||||
</if>
|
|
||||||
</trim>
|
|
||||||
</insert>
|
|
||||||
<update id="updateByPrimaryKeySelective" parameterType="com.zhiyun.zhiyun03.directory.entity.Directory">
|
|
||||||
update directory
|
|
||||||
<set>
|
|
||||||
<if test="dirName != null">
|
|
||||||
dir_name = #{dirName,jdbcType=VARCHAR},
|
|
||||||
</if>
|
|
||||||
<if test="dirImg != null">
|
|
||||||
dir_img = #{dirImg,jdbcType=VARCHAR},
|
|
||||||
</if>
|
|
||||||
</set>
|
|
||||||
where id = #{id,jdbcType=INTEGER}
|
|
||||||
</update>
|
|
||||||
<update id="updateByPrimaryKey" parameterType="com.zhiyun.zhiyun03.directory.entity.Directory">
|
|
||||||
update directory
|
|
||||||
set dir_name = #{dirName,jdbcType=VARCHAR},
|
|
||||||
dir_img = #{dirImg,jdbcType=VARCHAR}
|
|
||||||
where id = #{id,jdbcType=INTEGER}
|
|
||||||
</update>
|
|
||||||
</mapper>
|
|
Loading…
Reference in New Issue