feat:获取专题栏目

new-v20240713
wangxy 1 week ago
parent 2271b61649
commit 8b5068c226

@ -2,13 +2,15 @@ package com.ruoyi.web.controller.home;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.domain.SysColumn; import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.SysColumnVO;
import com.ruoyi.system.service.ISysColumnService; import com.ruoyi.system.service.ISysColumnService;
import com.ruoyi.system.service.ISysSpecialService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -16,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
/** /**
@ -41,6 +44,12 @@ public class ColumnTreeController extends BaseController {
@Autowired @Autowired
private ISysColumnService columnService; private ISysColumnService columnService;
@Autowired
private ISysSpecialService specialService;
@ApiOperation("类别树") @ApiOperation("类别树")
@GetMapping("/getTree") @GetMapping("/getTree")
public R<List<SysColumnVO>> getTree(@RequestParam(required = false, defaultValue = "2") String columnType) { public R<List<SysColumnVO>> getTree(@RequestParam(required = false, defaultValue = "2") String columnType) {
@ -70,4 +79,47 @@ public class ColumnTreeController extends BaseController {
children.forEach(this::buildChildren); children.forEach(this::buildChildren);
pNode.setChildren(children); pNode.setChildren(children);
} }
@ApiOperation("获取专题栏目")
@GetMapping("/getColumn")
public R<List<SysColumn>> getColumn(@RequestParam(required = false, defaultValue = "2") String columnType) {
LambdaQueryWrapper<SysColumn> queryWrapper= new LambdaQueryWrapper<>();
queryWrapper.eq(SysColumn::getColumnType, columnType);
queryWrapper.eq(SysColumn::getColumnGrade, COLUMN_GRADE);
queryWrapper.eq(SysColumn::getStatus,STATUS);
queryWrapper.orderByAsc(SysColumn::getOrderNum);
List<SysColumn> specialColumns = columnService.list(queryWrapper);
return R.ok(specialColumns);
}
@ApiOperation("获取专题栏目")
@GetMapping("/getSpecial")
public R<PageInfo<SysSpecialVo>> getSpecial(@RequestParam(required = false) String id,
@RequestParam(required = false) String columnId) {
List<SysSpecialVo> sysSpecialVos = new ArrayList<>();
LambdaQueryWrapper<SysColumn> queryWrapper= new LambdaQueryWrapper<>();
if(StringUtils.isNotEmpty(columnId)){
queryWrapper.eq(SysColumn::getColumnId, columnId);
}else{
queryWrapper.eq(SysColumn::getParentId, id);
}
queryWrapper.eq(SysColumn::getStatus,STATUS);
queryWrapper.orderByAsc(SysColumn::getOrderNum);
List<SysColumn> specialColumns = columnService.list(queryWrapper);
specialColumns.forEach(column->{
SysSpecialVo sysSpecialVo = new SysSpecialVo();
sysSpecialVo.setColumnId(column.getColumnId());
sysSpecialVo.setColumnName(column.getColumnName());
SysSpecial sysSpecial = new SysSpecial();
sysSpecial.setStatus(STATUS);
sysSpecial.setColumnId(column.getColumnId());
List<SysSpecial> specialList = specialService.selectSysSpecialList(sysSpecial);
sysSpecialVo.setSysSpecials(specialList);
sysSpecialVos.add(sysSpecialVo);
});
PageInfo<SysSpecialVo> page = PageInfo.of(sysSpecialVos);
return R.ok(page);
}
} }

@ -0,0 +1,27 @@
package com.ruoyi.system.domain;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
*
* @TableName sys_Special
* @author wangxy
*/
@Data
public class SysSpecialVo implements Serializable {
private static final long serialVersionUID = 1L;
private String columnId;
/** 菜单名称 */
private String columnName;
private List<SysSpecial> sysSpecials ;
}
Loading…
Cancel
Save