【优化】教程分类以及教程
This commit is contained in:
@@ -75,5 +75,8 @@ public class Tutorial implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private Long categoryId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String categoryName;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -13,5 +13,7 @@ import org.apache.ibatis.annotations.Param;
|
||||
@Mapper
|
||||
public interface TutorialMapper extends BaseMapper<Tutorial> {
|
||||
|
||||
Page<Tutorial> pageList(Page<Tutorial> page, @Param("categoryId") int categoryId, @Param("tutorialTitle") String tutorialTitle, @Param("lang") String lang);
|
||||
Page<Tutorial> pageList(Page<Tutorial> page, @Param("categoryId") Long categoryId, @Param("tutorialTitle") String tutorialTitle, @Param("lang") String lang);
|
||||
|
||||
Page<Tutorial> page(Page<Tutorial> page, @Param("tutorial") Tutorial tutorial);
|
||||
}
|
||||
|
||||
@@ -96,11 +96,11 @@ public class AppTutorialController {
|
||||
public Result<IPage<Tutorial>> getPageList(
|
||||
@RequestParam(defaultValue = "1") Long current,
|
||||
@RequestParam(defaultValue = "10") Long size,
|
||||
@RequestParam(required = false, defaultValue = "0") Integer categoryId,
|
||||
@RequestParam(required = false, defaultValue = "0") Long categoryId,
|
||||
@RequestParam(required = false) String tutorialTitle) {
|
||||
try {
|
||||
Page<Tutorial> page = new Page<>(current, size);
|
||||
IPage<Tutorial> pageResult = tutorialService.pageList(page, categoryId, tutorialTitle, I18nUtil.getCurrentLocale().getLanguage());
|
||||
Page<Tutorial> pageResult = tutorialService.pageList(page, categoryId, tutorialTitle, I18nUtil.getCurrentLocale().getLanguage());
|
||||
return Result.success(pageResult);
|
||||
} catch (Exception e) {
|
||||
return Result.error(e.getMessage());
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.corewing.app.entity.Tutorial;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
public interface TutorialService extends IService<Tutorial> {
|
||||
IPage<Tutorial> pageList(Page<Tutorial> page, int categoryId, String tutorialTitle, String lang);
|
||||
Page<Tutorial> pageList(Page<Tutorial> page, Long categoryId, String tutorialTitle, String lang);
|
||||
|
||||
Page<Tutorial> page(Tutorial tutorial);
|
||||
|
||||
|
||||
@@ -26,16 +26,14 @@ public class TutorialServiceImpl extends ServiceImpl<TutorialMapper, Tutorial> i
|
||||
private TutorialCategoryRelationService tutorialCategoryRelationService;
|
||||
|
||||
@Override
|
||||
public IPage<Tutorial> pageList(Page<Tutorial> page, int categoryId, String tutorialTitle, String lang) {
|
||||
public Page<Tutorial> pageList(Page<Tutorial> page, Long categoryId, String tutorialTitle, String lang) {
|
||||
return tutorialMapper.pageList(page, categoryId, tutorialTitle, lang);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Tutorial> page(Tutorial tutorial) {
|
||||
Page<Tutorial> page = PageContext.getPage(Tutorial.class);
|
||||
LambdaQueryWrapper<Tutorial> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.like(StringUtils.hasText(tutorial.getTutorialTitle()), Tutorial::getTutorialTitle, tutorial.getTutorialTitle());
|
||||
return page(page, queryWrapper);
|
||||
return tutorialMapper.page(page, tutorial);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
||||
@@ -55,4 +55,8 @@ public class TutorialVO {
|
||||
*/
|
||||
private String categoryTitle;
|
||||
|
||||
private String lang;
|
||||
|
||||
private Long categoryId;
|
||||
|
||||
}
|
||||
|
||||
@@ -11,14 +11,16 @@
|
||||
<result column="view_count" property="viewCount"/>
|
||||
<result column="recommend_status" property="recommendStatus"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="lang" property="lang"/>
|
||||
<result column="category_title" property="categoryTitle"/>
|
||||
<result column="category_id" property="categoryId"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础查询SQL片段 -->
|
||||
<sql id="selectVOSql">
|
||||
select c.*, cc.category_title
|
||||
select c.*, cc.category_title, cc.id as category_id
|
||||
from app_tutorial c
|
||||
left join app_tutorial_category_relation ccr on c.id = ccr.tutorial_id
|
||||
left join app_tutorial_category cc on cc.id = ccr.category_id
|
||||
@@ -36,9 +38,28 @@
|
||||
<if test="tutorialTitle != null and tutorialTitle != ''">
|
||||
AND c.tutorial_title like CONCAT('%', #{tutorialTitle}, '%')
|
||||
</if>
|
||||
|
||||
</where>
|
||||
ORDER BY c.recommend_status,c.create_time asc
|
||||
</select>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="page" resultMap="VOResultMap">
|
||||
<include refid="selectVOSql"/>
|
||||
<where>
|
||||
<if test="tutorial.categoryId != null and tutorial.categoryId != 0">
|
||||
AND cc.id = #{tutorial.categoryId}
|
||||
</if>
|
||||
<if test="tutorial.tutorialTitle != null and tutorial.tutorialTitle != ''">
|
||||
AND c.tutorial_title like CONCAT('%', #{tutorial.tutorialTitle}, '%')
|
||||
</if>
|
||||
<if test="tutorial.lang != null and tutorial.lang != ''">
|
||||
AND c.lang = #{tutorial.lang}
|
||||
</if>
|
||||
<if test="tutorial.status != null">
|
||||
AND c.status = #{tutorial.status}
|
||||
</if>
|
||||
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -514,6 +514,7 @@
|
||||
status: 1,
|
||||
recommendStatus: 1,
|
||||
lang: 'zh',
|
||||
categoryId: 0,
|
||||
},
|
||||
// 教程分类
|
||||
categoryTableData: [], // 表格数据源
|
||||
@@ -624,7 +625,8 @@
|
||||
}
|
||||
});
|
||||
},
|
||||
categoryQueryData() {
|
||||
categoryQueryData(item) {
|
||||
this.searchParams.categoryId = item.id;
|
||||
this.fetchData();
|
||||
},
|
||||
// 打开新增模态框
|
||||
@@ -705,8 +707,8 @@
|
||||
// 重置搜索
|
||||
resetSearch() {
|
||||
this.searchParams = {
|
||||
firmwareName: '',
|
||||
firmwareType: '',
|
||||
tutorialTitle: '',
|
||||
status: '',
|
||||
};
|
||||
this.pageNum = 1;
|
||||
this.fetchData();
|
||||
@@ -734,6 +736,7 @@
|
||||
openAddModal() {
|
||||
this.addOrEditTitle = '新增';
|
||||
this.clearForm();
|
||||
this.addOrEditDto.categoryId = this.categoryTableData[0]?.id;
|
||||
this.modalInstances['addOrEditModel'].show();
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user