血脉初建
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.PointCategoryEntity;
|
||||
import com.peanut.modules.book.entity.PointEntity;
|
||||
import com.peanut.modules.book.service.PointCategoryService;
|
||||
import com.peanut.modules.book.service.PointService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -61,4 +63,47 @@ public class PointController {
|
||||
pointCategoryService.updateById(p);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取脉穴文章列表
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getPointList")
|
||||
public R getPointList(@RequestBody Map<String,Object> map){
|
||||
Page<PointEntity> pointList = pointService.getPointList(map);
|
||||
return R.ok().put("page",pointList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加脉穴文章
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/addPoint")
|
||||
public R addPoint(@RequestBody PointEntity pointEntity){
|
||||
pointService.save(pointEntity);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除脉穴文章
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/delPoint")
|
||||
public R delPoint(@RequestBody Map<String,Object> map){
|
||||
Integer pointId = Integer.valueOf(map.get("pointId").toString());
|
||||
pointService.removeById(pointId);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改脉穴文章
|
||||
* @param pointEntity
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/editPoint")
|
||||
public R editPoint(@RequestBody PointEntity pointEntity){
|
||||
pointService.updateById(pointEntity);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ public class PointEntity implements Serializable {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private String title;
|
||||
|
||||
private Integer pointCategoryId;
|
||||
|
||||
private String alias;
|
||||
|
||||
@@ -2,10 +2,13 @@ package com.peanut.modules.book.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.book.entity.PointCategoryEntity;
|
||||
import com.peanut.modules.book.entity.PointEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface PointCategoryService extends IService<PointCategoryEntity> {
|
||||
|
||||
List<PointCategoryEntity> getCategoryList();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
package com.peanut.modules.book.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.book.entity.PointEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface PointService extends IService<PointEntity> {
|
||||
|
||||
|
||||
Page<PointEntity> getPointList(Map<String,Object> map);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.book.dao.PointCategoryDao;
|
||||
import com.peanut.modules.book.entity.PointCategoryEntity;
|
||||
import com.peanut.modules.book.entity.PointEntity;
|
||||
import com.peanut.modules.book.service.PointCategoryService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("pointCategoryService")
|
||||
public class PointCategoryServiceImpl extends ServiceImpl<PointCategoryDao, PointCategoryEntity> implements PointCategoryService {
|
||||
@@ -29,5 +32,4 @@ public class PointCategoryServiceImpl extends ServiceImpl<PointCategoryDao, Poin
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,53 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.book.dao.PointCategoryDao;
|
||||
import com.peanut.modules.book.dao.PointDao;
|
||||
import com.peanut.modules.book.entity.PointCategoryEntity;
|
||||
import com.peanut.modules.book.entity.PointEntity;
|
||||
import com.peanut.modules.book.service.PointService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("pointService")
|
||||
public class PointServiceImpl extends ServiceImpl<PointDao, PointEntity> implements PointService {
|
||||
|
||||
@Autowired
|
||||
private PointCategoryDao pointCategoryDao;
|
||||
|
||||
|
||||
@Override
|
||||
public Page<PointEntity> getPointList(Map<String, Object> map) {
|
||||
Integer limit = Integer.valueOf(map.get("limit").toString());
|
||||
Integer page = Integer.valueOf(map.get("page").toString());
|
||||
LambdaQueryWrapper<PointEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
if(map.containsKey("pointCategoryId")&& StringUtils.isNotBlank(map.get("pointCategoryId").toString())){
|
||||
Integer id = Integer.valueOf(map.get("pointCategoryId").toString());
|
||||
List<Integer> ids = new ArrayList<>();
|
||||
createIds(id,ids);
|
||||
wrapper.in(PointEntity::getPointCategoryId,ids);
|
||||
}
|
||||
wrapper.orderByDesc(PointEntity::getSort);
|
||||
Page<PointEntity> pointEntityPage = getBaseMapper().selectPage(new Page<>(page, limit), wrapper);
|
||||
return pointEntityPage;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void createIds(Integer id,List<Integer> list){
|
||||
LambdaQueryWrapper<PointCategoryEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(PointCategoryEntity::getPid,id);
|
||||
List<PointCategoryEntity> pointCategoryEntities = pointCategoryDao.selectList(wrapper);
|
||||
for (PointCategoryEntity p :pointCategoryEntities){
|
||||
createIds(p.getId(),list);
|
||||
}
|
||||
list.add(id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user