第二次课
2023-11-07 10:04:28 548浏览
掌上游戏app
请求流程
去除eslint校验
vue.config.js修改
lintOnSave: false
两个vue相互传值
this.$router.push({path:"/appInfo",query:{userType:result.data.userType,account:result.data.account}})
mounted() {
this.account=this.$route.query.account
this.userType=this.$route.query.userType
},
递归查询分类
https://www.jf3q.com/article/detail/6311
递归算法查询课程分类列表(树形)
递归查询效率比较高。
public List<CategoryTreeVo> tree() {
List<CategoryTreeVo> vos= new ArrayList<>();
List<AppCategory> list = appCategoryDao.queryAllBy(new AppCategory());//所有的分类
for (AppCategory category : list) {
CategoryTreeVo vo = new CategoryTreeVo();
BeanUtils.copyProperties(category,vo);
vos.add(vo);
}
List<CategoryTreeVo> treeVoList = new ArrayList<>();
for (CategoryTreeVo vo : vos) {
if (vo.getParentid() !=null && vo.getParentid() ==1L) {
vo.setLevel(1);//一级分类
treeVoList.add(findChildren(vo,vos));//装填二级分类
}
}
return treeVoList;
}
private CategoryTreeVo findChildren(CategoryTreeVo vo, List<CategoryTreeVo> vos) {
vo.setChildren(new ArrayList<>());
for (CategoryTreeVo it : vos) {
if(vo.getId()==it.getParentid()) {
int level = vo.getLevel() + 1;
it.setLevel(level);
vo.getChildren().add(it);//把二级分类挂在一级上面
findChildren(it,vos);//根据二级找三级,根据三级找四级,以此类推
}
}
return vo;
}
新增修改app基础信息接口
@PostMapping("/saveOrUpdate")
public ResultVo saveOrUpdate(
AppInfo appInfo, MultipartFile file, HttpServletRequest request
){
String token = request.getHeader("token");
if (!file.isEmpty()) {
String originalFilename = file.getOriginalFilename();
String fileFormat = FilenameUtils.getExtension(originalFilename);
if (file.getSize()>500*1024) {
return ResultVo.error("文件超过了500k");
}else if(
fileFormat.equalsIgnoreCase("jpg")||
fileFormat.equalsIgnoreCase("jpeg")||
fileFormat.equalsIgnoreCase("png")||
fileFormat.equalsIgnoreCase("gif")
){
//正常传文件
String realPath = request.getServletContext().getRealPath("/upload");
File savePath= new File(realPath);
if (!savePath.exists()) {
savePath.mkdirs();
}
String fileName= UUID.randomUUID().toString().replace("-","");
File saveFile = new File(realPath+"/"+fileName+"."+fileFormat);
try {
file.transferTo(saveFile);
appInfo.setLogopicpath("/upload/"+fileName+"."+fileFormat);
} catch (IOException e) {
e.printStackTrace();
return ResultVo.error("logo图上传失败");
}
}else{
return ResultVo.error("文件格式错误");
}
}
DevUser devUser = (DevUser)SeesionManager.get(token);
if (appInfo.getId()==null) {
appInfo.setDownloads(0L);
appInfo.setDevid(devUser.getId());
appInfo.setCreationdate(new Date());
appInfo.setStatus(1L);
appInfo.setCreatedby(devUser.getId());
}else {
appInfo.setModifyby(devUser.getId());
appInfo.setModifydate(new Date());
}
appInfoService.saveOrUpdate(appInfo);
return ResultVo.success(null);
}
带条件分页查询app基础信息
@PostMapping("/page")
public ResultVo getPage(@RequestBody AppInfoDto appInfoDto ,@RequestParam(defaultValue = "1") Integer pageNum)
{
PageInfo<AppInfo> page =appInfoService.getPage(appInfoDto,pageNum);
return ResultVo.success(page);
}
public PageInfo<AppInfo> getPage(AppInfoDto appInfoDto, Integer pageNum) {
AppInfo appInfo = new AppInfo();
BeanUtils.copyProperties(appInfoDto,appInfo);
PageHelper.startPage(pageNum, SysConstant.pageSize);
List<AppInfo> list = appInfoDao.queryAllBy(appInfo);
PageInfo<AppInfo> page= new PageInfo<>(list);
return page;
}
好博客就要一起分享哦!分享海报
此处可发布评论
评论(0)展开评论
暂无评论,快来写一下吧
展开评论
您可能感兴趣的博客
他的专栏
他感兴趣的技术