|
|
@ -6,9 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions; |
|
|
|
import org.jeecg.common.api.vo.Result; |
|
|
|
import org.jeecg.common.aspect.annotation.AutoLog; |
|
|
|
import org.jeecg.common.system.base.controller.JeecgController; |
|
|
|
import org.jeecg.common.system.query.QueryGenerator; |
|
|
|
import org.jeecg.common.system.vo.SelectTreeModel; |
|
|
@ -17,64 +15,89 @@ import org.jeecg.modules.sysMiniapp.car.entity.AppCarTree; |
|
|
|
import org.jeecg.modules.sysMiniapp.car.service.IAppCarTreeService; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.servlet.ModelAndView; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description: 汽车品牌 |
|
|
|
* @Author: jeecg-boot |
|
|
|
* @Date: 2025-02-19 |
|
|
|
* @Version: V1.0 |
|
|
|
*/ |
|
|
|
@Api(tags="汽车品牌") |
|
|
|
* @Description: 汽车品牌 |
|
|
|
* @Author: jeecg-boot |
|
|
|
* @Date: 2025-02-19 |
|
|
|
* @Version: V1.0 |
|
|
|
*/ |
|
|
|
@Api(tags = "汽车品牌") |
|
|
|
@RestController |
|
|
|
@RequestMapping("/miniapp/car") |
|
|
|
@Slf4j |
|
|
|
public class CarTreeController extends JeecgController<AppCarTree, IAppCarTreeService>{ |
|
|
|
@Autowired |
|
|
|
private IAppCarTreeService appCarTreeService; |
|
|
|
public class CarTreeController extends JeecgController<AppCarTree, IAppCarTreeService> { |
|
|
|
@Autowired |
|
|
|
private IAppCarTreeService appCarTreeService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 分页列表查询 |
|
|
|
* |
|
|
|
* @param appCarTree |
|
|
|
* @param pageNo |
|
|
|
* @param pageSize |
|
|
|
* @param req |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
//@AutoLog(value = "汽车品牌-分页列表查询") |
|
|
|
@ApiOperation(value="汽车品牌-分页列表查询", notes="汽车品牌-分页列表查询") |
|
|
|
@GetMapping(value = "/rootList") |
|
|
|
public Result<IPage<AppCarTree>> queryPageList(AppCarTree appCarTree, |
|
|
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo, |
|
|
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize, |
|
|
|
HttpServletRequest req) { |
|
|
|
String hasQuery = req.getParameter("hasQuery"); |
|
|
|
if(hasQuery != null && "true".equals(hasQuery)){ |
|
|
|
QueryWrapper<AppCarTree> queryWrapper = QueryGenerator.initQueryWrapper(appCarTree, req.getParameterMap()); |
|
|
|
List<AppCarTree> list = appCarTreeService.queryTreeListNoPage(queryWrapper); |
|
|
|
IPage<AppCarTree> pageList = new Page<>(1, 10, list.size()); |
|
|
|
pageList.setRecords(list); |
|
|
|
return Result.OK(pageList); |
|
|
|
}else{ |
|
|
|
String parentId = appCarTree.getPid(); |
|
|
|
if (oConvertUtils.isEmpty(parentId)) { |
|
|
|
parentId = "0"; |
|
|
|
} |
|
|
|
appCarTree.setPid(null); |
|
|
|
QueryWrapper<AppCarTree> queryWrapper = QueryGenerator.initQueryWrapper(appCarTree, req.getParameterMap()); |
|
|
|
// 使用 eq 防止模糊查询 |
|
|
|
queryWrapper.eq("pid", parentId); |
|
|
|
Page<AppCarTree> page = new Page<AppCarTree>(pageNo, pageSize); |
|
|
|
IPage<AppCarTree> pageList = appCarTreeService.page(page, queryWrapper); |
|
|
|
return Result.OK(pageList); |
|
|
|
} |
|
|
|
} |
|
|
|
/** |
|
|
|
* 分页列表查询 |
|
|
|
* |
|
|
|
* @param appCarTree |
|
|
|
* @param pageNo |
|
|
|
* @param pageSize |
|
|
|
* @param req |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
//@AutoLog(value = "汽车品牌-分页列表查询") |
|
|
|
@ApiOperation(value = "汽车品牌-分页列表查询", notes = "汽车品牌-分页列表查询") |
|
|
|
@GetMapping(value = "/rootList") |
|
|
|
public Result<IPage<AppCarTree>> queryPageList(AppCarTree appCarTree, |
|
|
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
|
|
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, |
|
|
|
HttpServletRequest req) { |
|
|
|
String hasQuery = req.getParameter("hasQuery"); |
|
|
|
if (hasQuery != null && "true".equals(hasQuery)) { |
|
|
|
QueryWrapper<AppCarTree> queryWrapper = QueryGenerator.initQueryWrapper(appCarTree, req.getParameterMap()); |
|
|
|
queryWrapper.orderByAsc("bfirstletter"); |
|
|
|
List<AppCarTree> list = appCarTreeService.queryTreeListNoPage(queryWrapper); |
|
|
|
IPage<AppCarTree> pageList = new Page<>(1, 10, list.size()); |
|
|
|
pageList.setRecords(list); |
|
|
|
return Result.OK(pageList); |
|
|
|
} else { |
|
|
|
String parentId = appCarTree.getPid(); |
|
|
|
if (oConvertUtils.isEmpty(parentId)) { |
|
|
|
parentId = "0"; |
|
|
|
} |
|
|
|
appCarTree.setPid(null); |
|
|
|
QueryWrapper<AppCarTree> queryWrapper = QueryGenerator.initQueryWrapper(appCarTree, req.getParameterMap()); |
|
|
|
queryWrapper.orderByAsc("bfirstletter"); |
|
|
|
// 使用 eq 防止模糊查询 |
|
|
|
queryWrapper.eq("pid", parentId); |
|
|
|
Page<AppCarTree> page = new Page<AppCarTree>(pageNo, pageSize); |
|
|
|
IPage<AppCarTree> pageList = appCarTreeService.page(page, queryWrapper); |
|
|
|
return Result.OK(pageList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 列表查询不分页 |
|
|
|
* |
|
|
|
* @param appCarTree |
|
|
|
* @param req |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
//@AutoLog(value = "汽车品牌-分页列表查询") |
|
|
|
@ApiOperation(value = "汽车品牌-一级列表查询不分页", notes = "汽车品牌-一级列表查询不分页") |
|
|
|
@GetMapping(value = "/getList") |
|
|
|
public Result<List<AppCarTree>> queryList(AppCarTree appCarTree, |
|
|
|
HttpServletRequest req) { |
|
|
|
String parentId = appCarTree.getPid(); |
|
|
|
if (oConvertUtils.isEmpty(parentId)) { |
|
|
|
parentId = "0"; |
|
|
|
} |
|
|
|
appCarTree.setPid(null); |
|
|
|
QueryWrapper<AppCarTree> queryWrapper = QueryGenerator.initQueryWrapper(appCarTree, req.getParameterMap()); |
|
|
|
queryWrapper.orderByAsc("bfirstletter"); |
|
|
|
// 使用 eq 防止模糊查询 |
|
|
|
queryWrapper.eq("pid", parentId); |
|
|
|
List<AppCarTree> list = appCarTreeService.list(queryWrapper); |
|
|
|
return Result.OK(list); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 【vue3专用】加载节点的子数据 |
|
|
@ -139,45 +162,47 @@ public class CarTreeController extends JeecgController<AppCarTree, IAppCarTreeSe |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取子数据 |
|
|
|
* |
|
|
|
* @param appCarTree |
|
|
|
* @param req |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
//@AutoLog(value = "汽车品牌-获取子数据") |
|
|
|
@ApiOperation(value="汽车品牌-获取子数据", notes="汽车品牌-获取子数据") |
|
|
|
@GetMapping(value = "/childList") |
|
|
|
public Result<IPage<AppCarTree>> queryPageList(AppCarTree appCarTree,HttpServletRequest req) { |
|
|
|
QueryWrapper<AppCarTree> queryWrapper = QueryGenerator.initQueryWrapper(appCarTree, req.getParameterMap()); |
|
|
|
List<AppCarTree> list = appCarTreeService.list(queryWrapper); |
|
|
|
IPage<AppCarTree> pageList = new Page<>(1, 10, list.size()); |
|
|
|
pageList.setRecords(list); |
|
|
|
return Result.OK(pageList); |
|
|
|
} |
|
|
|
//@AutoLog(value = "汽车品牌-获取子数据") |
|
|
|
@ApiOperation(value = "汽车品牌-获取子数据", notes = "汽车品牌-获取子数据") |
|
|
|
@GetMapping(value = "/childList") |
|
|
|
public Result<IPage<AppCarTree>> queryPageList(AppCarTree appCarTree, HttpServletRequest req) { |
|
|
|
QueryWrapper<AppCarTree> queryWrapper = QueryGenerator.initQueryWrapper(appCarTree, req.getParameterMap()); |
|
|
|
List<AppCarTree> list = appCarTreeService.list(queryWrapper); |
|
|
|
IPage<AppCarTree> pageList = new Page<>(1, 10, list.size()); |
|
|
|
pageList.setRecords(list); |
|
|
|
return Result.OK(pageList); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 批量查询子节点 |
|
|
|
* |
|
|
|
* @param parentIds 父ID(多个采用半角逗号分割) |
|
|
|
* @return 返回 IPage |
|
|
|
* @param parentIds |
|
|
|
* @return 返回 IPage |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
//@AutoLog(value = "汽车品牌-批量获取子数据") |
|
|
|
@ApiOperation(value="汽车品牌-批量获取子数据", notes="汽车品牌-批量获取子数据") |
|
|
|
@GetMapping("/getChildListBatch") |
|
|
|
public Result getChildListBatch(@RequestParam("parentIds") String parentIds) { |
|
|
|
try { |
|
|
|
QueryWrapper<AppCarTree> queryWrapper = new QueryWrapper<>(); |
|
|
|
List<String> parentIdList = Arrays.asList(parentIds.split(",")); |
|
|
|
queryWrapper.in("pid", parentIdList); |
|
|
|
List<AppCarTree> list = appCarTreeService.list(queryWrapper); |
|
|
|
IPage<AppCarTree> pageList = new Page<>(1, 10, list.size()); |
|
|
|
pageList.setRecords(list); |
|
|
|
return Result.OK(pageList); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error(e.getMessage(), e); |
|
|
|
return Result.error("批量查询子节点失败:" + e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
//@AutoLog(value = "汽车品牌-批量获取子数据") |
|
|
|
@ApiOperation(value = "汽车品牌-批量获取子数据", notes = "汽车品牌-批量获取子数据") |
|
|
|
@GetMapping("/getChildListBatch") |
|
|
|
public Result getChildListBatch(@RequestParam("parentIds") String parentIds) { |
|
|
|
try { |
|
|
|
QueryWrapper<AppCarTree> queryWrapper = new QueryWrapper<>(); |
|
|
|
List<String> parentIdList = Arrays.asList(parentIds.split(",")); |
|
|
|
queryWrapper.in("pid", parentIdList); |
|
|
|
List<AppCarTree> list = appCarTreeService.list(queryWrapper); |
|
|
|
IPage<AppCarTree> pageList = new Page<>(1, 10, list.size()); |
|
|
|
pageList.setRecords(list); |
|
|
|
return Result.OK(pageList); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error(e.getMessage(), e); |
|
|
|
return Result.error("批量查询子节点失败:" + e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |