springboot mybatis不写xml 文件直接通过sql进行查询
·
增加@Select标签,直接进行sql查询
@Mapper
public interface DicClassCategoryMapper extends BaseMapper {
// 查询一级分类
@Select("select tt.detail_id, tt.label, tt.value,tt.dict_sort " +
"from sys_dict t1 " +
"join sys_dict_detail tt on t1.dict_id = tt.dict_id " +
“where t1.name = ‘category_level1’ and tt.detail_id in (13,14)”)
List getLevel1();
// 查询二级分类
@Select("select tt2.detail_id, tt2.label, tt2.value, tt2.dict_sort " +
"from sys_dict_detail tt2 " +
"where tt2.parent_dict_id = #{parentId}")
List<DicClassCategory> getLevel2(Long parentId);
}
更多推荐
所有评论(0)