diff --git a/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/operations/CourseCollectController.java b/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/operations/CourseCollectController.java new file mode 100644 index 0000000..201074a --- /dev/null +++ b/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/operations/CourseCollectController.java @@ -0,0 +1,115 @@ +package com.inspur.web.controller.operations; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import com.inspur.operations.domain.CourseCollect; +import com.inspur.operations.service.ICourseCollectService; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.inspur.common.annotation.Log; +import com.inspur.common.core.controller.BaseController; +import com.inspur.common.core.domain.AjaxResult; +import com.inspur.common.enums.BusinessType; +import com.inspur.common.utils.poi.ExcelUtil; +import com.inspur.common.core.page.TableDataInfo; + +/** + * 课程收藏Controller + * + * @author inspur + * @date 2024-04-28 + */ +@RestController +@RequestMapping("/operations/collect") +public class CourseCollectController extends BaseController +{ + @Autowired + private ICourseCollectService courseCollectService; + + /** + * 查询课程收藏列表 + */ + @PreAuthorize("@ss.hasPermi('operations:collect:list')") + @GetMapping("/list") + public TableDataInfo list(CourseCollect courseCollect) + { + startPage(); + List list = courseCollectService.selectCourseCollectList(courseCollect); + return getDataTable(list); + } + + /** + * 导出课程收藏列表 + */ + @PreAuthorize("@ss.hasPermi('operations:collect:export')") + @Log(title = "课程收藏", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, CourseCollect courseCollect) + { + List list = courseCollectService.selectCourseCollectList(courseCollect); + ExcelUtil util = new ExcelUtil(CourseCollect.class); + util.exportExcel(response, list, "课程收藏数据"); + } + + /** + * 获取课程收藏详细信息 + */ + @PreAuthorize("@ss.hasPermi('operations:collect:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") String id) + { + return success(courseCollectService.selectCourseCollectById(id)); + } + + /** + * 新增课程收藏 + */ + @PreAuthorize("@ss.hasPermi('operations:collect:add')") + @Log(title = "课程收藏", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody CourseCollect courseCollect) + { + return toAjax(courseCollectService.insertCourseCollect(courseCollect)); + } + + /** + * 修改课程收藏 + */ + @PreAuthorize("@ss.hasPermi('operations:collect:edit')") + @Log(title = "课程收藏", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody CourseCollect courseCollect) + { + return toAjax(courseCollectService.updateCourseCollect(courseCollect)); + } + + /** + * 删除课程收藏 + */ + @PreAuthorize("@ss.hasPermi('operations:collect:remove')") + @Log(title = "课程收藏", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable String[] ids) + { + return toAjax(courseCollectService.deleteCourseCollectByIds(ids)); + } + + /** + * 课程收藏/取消收藏 + */ + @PreAuthorize("@ss.hasPermi('operations:collect:star')") + @Log(title = "课程收藏/取消收藏", businessType = BusinessType.OTHER) + @PostMapping("/star") + public AjaxResult star(@RequestBody CourseCollect courseCollect){ + return courseCollectService.star(courseCollect); + } +} diff --git a/inspur-service/inspur-operations/src/main/java/com/inspur/operations/domain/CourseCollect.java b/inspur-service/inspur-operations/src/main/java/com/inspur/operations/domain/CourseCollect.java new file mode 100644 index 0000000..59d0984 --- /dev/null +++ b/inspur-service/inspur-operations/src/main/java/com/inspur/operations/domain/CourseCollect.java @@ -0,0 +1,76 @@ +package com.inspur.operations.domain; + +import java.util.Date; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.inspur.common.annotation.Excel; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +/** + * 课程收藏对象 course_collect + * + * @author inspur + * @date 2024-04-28 + */ +@Data +public class CourseCollect { + private static final long serialVersionUID = 1L; + + /** + * id + */ + private String id; + + /** + * 课程id + */ + private String courseId; + + /** + * 课程名称 + */ + @Excel(name = "课程名称") + private String courseName; + + /** + * 用户id + */ + private Long userId; + + /** + * 用户名称 + */ + @Excel(name = "用户名称") + private String userName; + + /** + * 收藏时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "上传时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date collectTime; + + /** + * 课程类型:0 在线课程,1 视频课程,2 培训资料 + */ + private String courseType; + + /** + * 课程类型:0 在线课程,1 视频课程,2 培训资料 + */ + @Excel(name = "课程类型") + private String courseTypeName; + + /** + * 0:收藏,1:取消收藏 + */ + private String type; + + /** + * 课程ids + */ + private List courseIds; +} diff --git a/inspur-service/inspur-operations/src/main/java/com/inspur/operations/domain/CourseDocumentInfo.java b/inspur-service/inspur-operations/src/main/java/com/inspur/operations/domain/CourseDocumentInfo.java index 7e9e2d4..79c453a 100644 --- a/inspur-service/inspur-operations/src/main/java/com/inspur/operations/domain/CourseDocumentInfo.java +++ b/inspur-service/inspur-operations/src/main/java/com/inspur/operations/domain/CourseDocumentInfo.java @@ -66,4 +66,6 @@ public class CourseDocumentInfo extends BaseEntity { */ @Excel(name = "状态",dictType = "sys_normal_disable") private String status; + + private String starId; } diff --git a/inspur-service/inspur-operations/src/main/java/com/inspur/operations/domain/CourseOnlineInfo.java b/inspur-service/inspur-operations/src/main/java/com/inspur/operations/domain/CourseOnlineInfo.java index f14da02..6d4cb57 100644 --- a/inspur-service/inspur-operations/src/main/java/com/inspur/operations/domain/CourseOnlineInfo.java +++ b/inspur-service/inspur-operations/src/main/java/com/inspur/operations/domain/CourseOnlineInfo.java @@ -82,4 +82,9 @@ public class CourseOnlineInfo extends BaseEntity { */ @Excel(name = "状态",dictType = "sys_normal_disable") private String status; + + /** + * 收藏表id + */ + private String starId; } diff --git a/inspur-service/inspur-operations/src/main/java/com/inspur/operations/domain/CourseVideoInfo.java b/inspur-service/inspur-operations/src/main/java/com/inspur/operations/domain/CourseVideoInfo.java index cff7de9..716d358 100644 --- a/inspur-service/inspur-operations/src/main/java/com/inspur/operations/domain/CourseVideoInfo.java +++ b/inspur-service/inspur-operations/src/main/java/com/inspur/operations/domain/CourseVideoInfo.java @@ -74,4 +74,6 @@ public class CourseVideoInfo extends BaseEntity { */ @Excel(name = "状态",dictType = "sys_normal_disable") private String status; + + private String starId; } diff --git a/inspur-service/inspur-operations/src/main/java/com/inspur/operations/mapper/CourseCollectMapper.java b/inspur-service/inspur-operations/src/main/java/com/inspur/operations/mapper/CourseCollectMapper.java new file mode 100644 index 0000000..a456584 --- /dev/null +++ b/inspur-service/inspur-operations/src/main/java/com/inspur/operations/mapper/CourseCollectMapper.java @@ -0,0 +1,66 @@ +package com.inspur.operations.mapper; + +import com.inspur.operations.domain.CourseCollect; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 课程收藏Mapper接口 + * + * @author inspur + * @date 2024-04-28 + */ +public interface CourseCollectMapper +{ + /** + * 查询课程收藏 + * + * @param id 课程收藏主键 + * @return 课程收藏 + */ + public CourseCollect selectCourseCollectById(String id); + + /** + * 查询课程收藏列表 + * + * @param courseCollect 课程收藏 + * @return 课程收藏集合 + */ + public List selectCourseCollectList(CourseCollect courseCollect); + + /** + * 新增课程收藏 + * + * @param courseCollect 课程收藏 + * @return 结果 + */ + public int insertCourseCollect(CourseCollect courseCollect); + + /** + * 修改课程收藏 + * + * @param courseCollect 课程收藏 + * @return 结果 + */ + public int updateCourseCollect(CourseCollect courseCollect); + + /** + * 删除课程收藏 + * + * @param id 课程收藏主键 + * @return 结果 + */ + public int deleteCourseCollectById(String id); + + /** + * 批量删除课程收藏 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteCourseCollectByIds(String[] ids); + + + String checkIsExistStar(@Param("courseId") String courseId, @Param("userId") Long userId); +} diff --git a/inspur-service/inspur-operations/src/main/java/com/inspur/operations/service/ICourseCollectService.java b/inspur-service/inspur-operations/src/main/java/com/inspur/operations/service/ICourseCollectService.java new file mode 100644 index 0000000..5308908 --- /dev/null +++ b/inspur-service/inspur-operations/src/main/java/com/inspur/operations/service/ICourseCollectService.java @@ -0,0 +1,78 @@ +package com.inspur.operations.service; + +import com.inspur.common.core.domain.AjaxResult; +import com.inspur.operations.domain.CourseCollect; + +import java.util.List; + +/** + * 课程收藏Service接口 + * + * @author inspur + * @date 2024-04-28 + */ +public interface ICourseCollectService +{ + /** + * 查询课程收藏 + * + * @param id 课程收藏主键 + * @return 课程收藏 + */ + CourseCollect selectCourseCollectById(String id); + + /** + * 查询课程收藏列表 + * + * @param courseCollect 课程收藏 + * @return 课程收藏集合 + */ + List selectCourseCollectList(CourseCollect courseCollect); + + /** + * 新增课程收藏 + * + * @param courseCollect 课程收藏 + * @return 结果 + */ + int insertCourseCollect(CourseCollect courseCollect); + + /** + * 修改课程收藏 + * + * @param courseCollect 课程收藏 + * @return 结果 + */ + int updateCourseCollect(CourseCollect courseCollect); + + /** + * 批量删除课程收藏 + * + * @param ids 需要删除的课程收藏主键集合 + * @return 结果 + */ + int deleteCourseCollectByIds(String[] ids); + + /** + * 删除课程收藏信息 + * + * @param id 课程收藏主键 + * @return 结果 + */ + int deleteCourseCollectById(String id); + + /** + * 判断是否存在 + * + * @Author xusd + * @Date 9:16 2024/4/29 + * @param courseId 课程id + * @return String 课程收藏表id + */ + String checkIsExistStar(String courseId); + + /** + * 课程收藏/取消收藏 + */ + AjaxResult star(CourseCollect courseCollect); +} diff --git a/inspur-service/inspur-operations/src/main/java/com/inspur/operations/service/impl/CourseCollectServiceImpl.java b/inspur-service/inspur-operations/src/main/java/com/inspur/operations/service/impl/CourseCollectServiceImpl.java new file mode 100644 index 0000000..a2b23d0 --- /dev/null +++ b/inspur-service/inspur-operations/src/main/java/com/inspur/operations/service/impl/CourseCollectServiceImpl.java @@ -0,0 +1,138 @@ +package com.inspur.operations.service.impl; + +import java.util.Date; +import java.util.List; +import java.util.Objects; + +import com.inspur.common.core.domain.AjaxResult; +import com.inspur.common.utils.SecurityUtils; +import com.inspur.common.utils.StringUtils; +import com.inspur.common.utils.uuid.IdUtils; +import com.inspur.operations.domain.CourseCollect; +import com.inspur.operations.mapper.CourseCollectMapper; +import com.inspur.operations.service.ICourseCollectService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * 课程收藏Service业务层处理 + * + * @author inspur + * @date 2024-04-28 + */ +@Service +public class CourseCollectServiceImpl implements ICourseCollectService { + @Autowired + private CourseCollectMapper courseCollectMapper; + + /** + * 查询课程收藏 + * + * @param id 课程收藏主键 + * @return 课程收藏 + */ + @Override + public CourseCollect selectCourseCollectById(String id) { + return courseCollectMapper.selectCourseCollectById(id); + } + + /** + * 查询课程收藏列表 + * + * @param courseCollect 课程收藏 + * @return 课程收藏 + */ + @Override + public List selectCourseCollectList(CourseCollect courseCollect) { + courseCollect.setUserId(SecurityUtils.getUserId()); + return courseCollectMapper.selectCourseCollectList(courseCollect); + } + + /** + * 新增课程收藏 + * + * @param courseCollect 课程收藏 + * @return 结果 + */ + @Override + public int insertCourseCollect(CourseCollect courseCollect) { + courseCollect.setId(IdUtils.fastSimpleUUID()); + courseCollect.setUserId(SecurityUtils.getUserId()); + courseCollect.setCollectTime(new Date()); + return courseCollectMapper.insertCourseCollect(courseCollect); + } + + /** + * 修改课程收藏 + * + * @param courseCollect 课程收藏 + * @return 结果 + */ + @Override + public int updateCourseCollect(CourseCollect courseCollect) { + return courseCollectMapper.updateCourseCollect(courseCollect); + } + + /** + * 批量删除课程收藏 + * + * @param ids 需要删除的课程收藏主键 + * @return 结果 + */ + @Override + public int deleteCourseCollectByIds(String[] ids) { + return courseCollectMapper.deleteCourseCollectByIds(ids); + } + + /** + * 删除课程收藏信息 + * + * @param id 课程收藏主键 + * @return 结果 + */ + @Override + public int deleteCourseCollectById(String id) { + return courseCollectMapper.deleteCourseCollectById(id); + } + + /** + * 判断是否存在 + * + * @param courseId 课程id + * @return int + * @Author xusd + * @Date 9:16 2024/4/29 + */ + @Override + public String checkIsExistStar(String courseId) { + return courseCollectMapper.checkIsExistStar(courseId, SecurityUtils.getUserId()); + } + + /** + * 课程收藏/取消收藏 + */ + @Override + public AjaxResult star(CourseCollect courseCollect) { + if (!"0".equals(courseCollect.getType()) && !"1".equals(courseCollect.getType())) { + return AjaxResult.error("参数异常"); + } else { + String id = checkIsExistStar(courseCollect.getCourseId()); + //收藏 + if ("0".equals(courseCollect.getType())) { + if (StringUtils.isNotEmpty(id)){ + return AjaxResult.error("课程已收藏,请勿重复收藏"); + }else { + this.insertCourseCollect(courseCollect); + return AjaxResult.success("收藏成功"); + } + } else { + if (StringUtils.isNotEmpty(id)){ + this.deleteCourseCollectById(id); + return AjaxResult.success("取消收藏成功"); + }else { + return AjaxResult.error("课程未收藏,请勿先收藏"); + } + } + } + } +} diff --git a/inspur-service/inspur-operations/src/main/java/com/inspur/operations/service/impl/CourseDocumentInfoServiceImpl.java b/inspur-service/inspur-operations/src/main/java/com/inspur/operations/service/impl/CourseDocumentInfoServiceImpl.java index 5c305df..6622260 100644 --- a/inspur-service/inspur-operations/src/main/java/com/inspur/operations/service/impl/CourseDocumentInfoServiceImpl.java +++ b/inspur-service/inspur-operations/src/main/java/com/inspur/operations/service/impl/CourseDocumentInfoServiceImpl.java @@ -2,14 +2,20 @@ package com.inspur.operations.service.impl; import java.util.Date; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import cn.hutool.core.util.StrUtil; import com.inspur.common.utils.DateUtils; import com.inspur.common.utils.SecurityUtils; +import com.inspur.common.utils.StringUtils; import com.inspur.common.utils.file.FileTypeUtils; import com.inspur.common.utils.uuid.IdUtils; +import com.inspur.operations.domain.CourseCollect; import com.inspur.operations.domain.CourseDocumentInfo; +import com.inspur.operations.domain.CourseVideoInfo; import com.inspur.operations.mapper.CourseDocumentInfoMapper; +import com.inspur.operations.service.ICourseCollectService; import com.inspur.operations.service.ICourseDocumentInfoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -26,6 +32,9 @@ public class CourseDocumentInfoServiceImpl implements ICourseDocumentInfoService @Autowired private CourseDocumentInfoMapper courseDocumentInfoMapper; + @Autowired + private ICourseCollectService courseCollectService; + /** * 查询课程培训资料 * @@ -47,7 +56,17 @@ public class CourseDocumentInfoServiceImpl implements ICourseDocumentInfoService @Override public List selectCourseDocumentInfoList(CourseDocumentInfo courseDocumentInfo) { - return courseDocumentInfoMapper.selectCourseDocumentInfoList(courseDocumentInfo); + List list = courseDocumentInfoMapper.selectCourseDocumentInfoList(courseDocumentInfo); + //设置starId前端判断显示收藏按钮使用 + if (StringUtils.isNotEmpty(list)){ + List courseIds = list.stream().map(CourseDocumentInfo::getDocId).collect(Collectors.toList()); + CourseCollect courseCollect = new CourseCollect(); + courseCollect.setCourseIds(courseIds); + List courseCollectList = courseCollectService.selectCourseCollectList(courseCollect); + Map courseCollectMap = courseCollectList.stream().collect(Collectors.toMap(CourseCollect::getCourseId, CourseCollect::getId)); + list.forEach(item-> item.setStarId(courseCollectMap.get(item.getDocId()))); + } + return list; } /** diff --git a/inspur-service/inspur-operations/src/main/java/com/inspur/operations/service/impl/CourseOnlineInfoServiceImpl.java b/inspur-service/inspur-operations/src/main/java/com/inspur/operations/service/impl/CourseOnlineInfoServiceImpl.java index e5f778a..d7d9408 100644 --- a/inspur-service/inspur-operations/src/main/java/com/inspur/operations/service/impl/CourseOnlineInfoServiceImpl.java +++ b/inspur-service/inspur-operations/src/main/java/com/inspur/operations/service/impl/CourseOnlineInfoServiceImpl.java @@ -1,11 +1,17 @@ package com.inspur.operations.service.impl; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + import com.inspur.common.utils.DateUtils; import com.inspur.common.utils.SecurityUtils; +import com.inspur.common.utils.StringUtils; import com.inspur.common.utils.uuid.IdUtils; +import com.inspur.operations.domain.CourseCollect; import com.inspur.operations.domain.CourseOnlineInfo; import com.inspur.operations.mapper.CourseOnlineInfoMapper; +import com.inspur.operations.service.ICourseCollectService; import com.inspur.operations.service.ICourseOnlineInfoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -22,6 +28,9 @@ public class CourseOnlineInfoServiceImpl implements ICourseOnlineInfoService @Autowired private CourseOnlineInfoMapper courseOnlineInfoMapper; + @Autowired + private ICourseCollectService courseCollectService; + /** * 查询在线课程信息 * @@ -43,7 +52,17 @@ public class CourseOnlineInfoServiceImpl implements ICourseOnlineInfoService @Override public List selectCourseOnlineInfoList(CourseOnlineInfo courseOnlineInfo) { - return courseOnlineInfoMapper.selectCourseOnlineInfoList(courseOnlineInfo); + List list = courseOnlineInfoMapper.selectCourseOnlineInfoList(courseOnlineInfo); + //设置starId前端判断显示收藏按钮使用 + if (StringUtils.isNotEmpty(list)){ + List classIds = list.stream().map(CourseOnlineInfo::getClassId).collect(Collectors.toList()); + CourseCollect courseCollect = new CourseCollect(); + courseCollect.setCourseIds(classIds); + List courseCollectList = courseCollectService.selectCourseCollectList(courseCollect); + Map courseCollectMap = courseCollectList.stream().collect(Collectors.toMap(CourseCollect::getCourseId, CourseCollect::getId)); + list.forEach(item-> item.setStarId(courseCollectMap.get(item.getClassId()))); + } + return list; } /** diff --git a/inspur-service/inspur-operations/src/main/java/com/inspur/operations/service/impl/CourseVideoInfoServiceImpl.java b/inspur-service/inspur-operations/src/main/java/com/inspur/operations/service/impl/CourseVideoInfoServiceImpl.java index 726afe2..f191267 100644 --- a/inspur-service/inspur-operations/src/main/java/com/inspur/operations/service/impl/CourseVideoInfoServiceImpl.java +++ b/inspur-service/inspur-operations/src/main/java/com/inspur/operations/service/impl/CourseVideoInfoServiceImpl.java @@ -1,11 +1,18 @@ package com.inspur.operations.service.impl; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + import com.inspur.common.utils.DateUtils; import com.inspur.common.utils.SecurityUtils; +import com.inspur.common.utils.StringUtils; import com.inspur.common.utils.uuid.IdUtils; +import com.inspur.operations.domain.CourseCollect; +import com.inspur.operations.domain.CourseOnlineInfo; import com.inspur.operations.domain.CourseVideoInfo; import com.inspur.operations.mapper.CourseVideoInfoMapper; +import com.inspur.operations.service.ICourseCollectService; import com.inspur.operations.service.ICourseVideoInfoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -22,6 +29,9 @@ public class CourseVideoInfoServiceImpl implements ICourseVideoInfoService @Autowired private CourseVideoInfoMapper courseVideoInfoMapper; + @Autowired + private ICourseCollectService courseCollectService; + /** * 查询视频课程信息 * @@ -43,7 +53,17 @@ public class CourseVideoInfoServiceImpl implements ICourseVideoInfoService @Override public List selectCourseVideoInfoList(CourseVideoInfo courseVideoInfo) { - return courseVideoInfoMapper.selectCourseVideoInfoList(courseVideoInfo); + List list = courseVideoInfoMapper.selectCourseVideoInfoList(courseVideoInfo); + //设置starId前端判断显示收藏按钮使用 + if (StringUtils.isNotEmpty(list)){ + List courseIds = list.stream().map(CourseVideoInfo::getCourseId).collect(Collectors.toList()); + CourseCollect courseCollect = new CourseCollect(); + courseCollect.setCourseIds(courseIds); + List courseCollectList = courseCollectService.selectCourseCollectList(courseCollect); + Map courseCollectMap = courseCollectList.stream().collect(Collectors.toMap(CourseCollect::getCourseId, CourseCollect::getId)); + list.forEach(item-> item.setStarId(courseCollectMap.get(item.getCourseId()))); + } + return list; } /** diff --git a/inspur-service/inspur-operations/src/main/resources/mapper/CourseCollectMapper.xml b/inspur-service/inspur-operations/src/main/resources/mapper/CourseCollectMapper.xml new file mode 100644 index 0000000..0f03d3a --- /dev/null +++ b/inspur-service/inspur-operations/src/main/resources/mapper/CourseCollectMapper.xml @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + SELECT + a.id, + a.course_id, + a.user_id, + a.course_type, + a.collect_time, + a.class_name, + su.nick_name, + CASE + WHEN a.course_type = '0' THEN + '在线课程' + WHEN a.course_type = '1' THEN + '视频课程' + WHEN a.course_type = '2' THEN + '培训资料' ELSE '' + END AS course_type_name + FROM + ( + SELECT + cc.id, + cc.course_id, + cc.user_id, + cc.course_type, + cc.collect_time, + coi.class_name + FROM + course_collect AS cc + JOIN course_online_info AS coi ON cc.course_id = coi.class_id and cc.course_type = '0' UNION ALL + SELECT + cc.id, + cc.course_id, + cc.user_id, + cc.course_type, + cc.collect_time, + cvi.course_name + FROM + course_collect AS cc + JOIN course_video_info AS cvi ON cc.course_id = cvi.course_id and cc.course_type = '1' UNION ALL + SELECT + cc.id, + cc.course_id, + cc.user_id, + cc.course_type, + cc.collect_time, + cdi.doc_name + FROM + course_collect AS cc + JOIN course_document_info AS cdi ON cc.course_id = cdi.doc_id and cc.course_type = '2' + ) AS a + LEFT JOIN sys_user AS su ON a.user_id = su.user_id + + + + + + + + + + insert into course_collect + + id, + course_id, + user_id, + collect_time, + course_type, + + + #{id}, + #{courseId}, + #{userId}, + #{collectTime}, + #{courseType}, + + + + + update course_collect + + course_id = #{courseId}, + user_id = #{userId}, + collect_time = #{collectTime}, + course_type = #{courseType}, + + where id = #{id} + + + + delete from course_collect where id = #{id} + + + + delete from course_collect where id in + + #{id} + + + \ No newline at end of file diff --git a/inspur-ui/src/api/operations/collect.js b/inspur-ui/src/api/operations/collect.js new file mode 100644 index 0000000..3018fa6 --- /dev/null +++ b/inspur-ui/src/api/operations/collect.js @@ -0,0 +1,53 @@ +import request from '@/utils/request' + +// 查询课程收藏列表 +export function listCollect(query) { + return request({ + url: '/operations/collect/list', + method: 'get', + params: query + }) +} + +// 查询课程收藏详细 +export function getCollect(id) { + return request({ + url: '/operations/collect/' + id, + method: 'get' + }) +} + +// 新增课程收藏 +export function addCollect(data) { + return request({ + url: '/operations/collect', + method: 'post', + data: data + }) +} + +// 修改课程收藏 +export function updateCollect(data) { + return request({ + url: '/operations/collect', + method: 'put', + data: data + }) +} + +// 删除课程收藏 +export function delCollect(id) { + return request({ + url: '/operations/collect/' + id, + method: 'delete' + }) +} + +// 收藏/取消收藏 +export function star(data) { + return request({ + url: '/operations/collect/star', + method: 'post', + data: data + }) +} diff --git a/inspur-ui/src/views/operations/collect/index.vue b/inspur-ui/src/views/operations/collect/index.vue new file mode 100644 index 0000000..e765f92 --- /dev/null +++ b/inspur-ui/src/views/operations/collect/index.vue @@ -0,0 +1,273 @@ + + + diff --git a/inspur-ui/src/views/operations/courseOnline/index.vue b/inspur-ui/src/views/operations/courseOnline/index.vue index 772c89b..583e044 100644 --- a/inspur-ui/src/views/operations/courseOnline/index.vue +++ b/inspur-ui/src/views/operations/courseOnline/index.vue @@ -125,6 +125,20 @@ @click="handleDelete(scope.row)" v-hasPermi="['operations:courseOnline:remove']" >删除 + 收藏 + 已收藏 import { listCourseOnline, getCourseOnline, delCourseOnline, addCourseOnline, updateCourseOnline,changeStatus } from "@/api/operations/courseOnline"; +import { star } from "@/api/operations/collect"; export default { name: "CourseOnline", @@ -266,6 +281,34 @@ export default { this.getList(); }, methods: { + //取消收藏 + handleUnStar(row){ + this.loading = true; + const data = { + courseId : row.classId, + courseType : "0", + type : "1" + } + star(data).then((res)=>{ + this.$modal.msgSuccess(res.msg); + this.getList() + this.loading = false; + }) + }, + //收藏 + handleStar(row){ + this.loading = true; + const data = { + courseId : row.classId, + courseType : "0", + type : "0" + } + star(data).then((res)=>{ + this.$modal.msgSuccess(res.msg); + this.getList() + this.loading = false; + }) + }, handleStart(row){ this.loading = true; const form = { diff --git a/inspur-ui/src/views/operations/courseVideo/index.vue b/inspur-ui/src/views/operations/courseVideo/index.vue index 9c06f7d..5d8a734 100644 --- a/inspur-ui/src/views/operations/courseVideo/index.vue +++ b/inspur-ui/src/views/operations/courseVideo/index.vue @@ -112,6 +112,20 @@ @click="handleDelete(scope.row)" v-hasPermi="['operations:courseVideo:remove']" >删除 + 收藏 + 已收藏 import { listCourseVideo, getCourseVideo, delCourseVideo, addCourseVideo, updateCourseVideo,changeStatus } from "@/api/operations/courseVideo"; +import { star } from "@/api/operations/collect"; export default { name: "CourseVideo", @@ -250,6 +265,34 @@ export default { this.getList(); }, methods: { + //取消收藏 + handleUnStar(row){ + this.loading = true; + const data = { + courseId : row.courseId, + courseType : "1", + type : "1" + } + star(data).then((res)=>{ + this.$modal.msgSuccess(res.msg); + this.getList() + this.loading = false; + }) + }, + //收藏 + handleStar(row){ + this.loading = true; + const data = { + courseId : row.courseId, + courseType : "1", + type : "0" + } + star(data).then((res)=>{ + this.$modal.msgSuccess(res.msg); + this.getList() + this.loading = false; + }) + }, handleStart(row){ this.loading = true; const form = { diff --git a/inspur-ui/src/views/operations/document/index.vue b/inspur-ui/src/views/operations/document/index.vue index 28ab43a..9612268 100644 --- a/inspur-ui/src/views/operations/document/index.vue +++ b/inspur-ui/src/views/operations/document/index.vue @@ -114,6 +114,20 @@ @click="handleDelete(scope.row)" v-hasPermi="['operations:document:remove']" >删除 + 收藏 + 已收藏 { + this.$modal.msgSuccess(res.msg); + this.getList() + this.loading = false; + }) + }, + //收藏 + handleStar(row){ + this.loading = true; + const data = { + courseId : row.docId, + courseType : "2", + type : "0" + } + star(data).then((res)=>{ + this.$modal.msgSuccess(res.msg); + this.getList() + this.loading = false; + }) + }, handleStart(row){ this.loading = true; const form = {