血脉初建
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.PointCategoryEntity;
|
||||
import com.peanut.modules.book.service.PointCategoryService;
|
||||
import com.peanut.modules.book.service.PointService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("book/point")
|
||||
public class PointController {
|
||||
@Autowired
|
||||
private PointService pointService;
|
||||
@Autowired
|
||||
private PointCategoryService pointCategoryService;
|
||||
|
||||
/**
|
||||
* 获取脉穴分类列表-树形结构
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getPointCategoryList")
|
||||
public R getPointCategoryList(){
|
||||
List<PointCategoryEntity> categoryList = pointCategoryService.getCategoryList();
|
||||
return R.ok().put("categorys",categoryList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加脉穴分类
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/addPointCategory")
|
||||
public R addPointCategory(@RequestBody PointCategoryEntity p){
|
||||
pointCategoryService.save(p);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除脉穴分类
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/delPointCategory")
|
||||
public R delPointCategory(@RequestBody Map<String,Object> map){
|
||||
Integer id = Integer.valueOf(map.get("pointCategoryId").toString());
|
||||
pointCategoryService.removeById(id);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改脉穴分类
|
||||
* @param p
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/editPointCategory")
|
||||
public R editPointCategory(@RequestBody PointCategoryEntity p){
|
||||
pointCategoryService.updateById(p);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
package com.peanut.modules.book.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@TableName("point_category")
|
||||
@@ -23,5 +22,10 @@ public class PointCategoryEntity implements Serializable {
|
||||
|
||||
private Date createTime;
|
||||
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<PointCategoryEntity> children;
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.peanut.modules.book.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -35,5 +36,6 @@ public class PointEntity implements Serializable {
|
||||
|
||||
private Date createTime;
|
||||
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
}
|
||||
|
||||
@@ -3,5 +3,9 @@ package com.peanut.modules.book.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.book.entity.PointCategoryEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface PointCategoryService extends IService<PointCategoryEntity> {
|
||||
|
||||
List<PointCategoryEntity> getCategoryList();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,33 @@
|
||||
package com.peanut.modules.book.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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.service.PointCategoryService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service("pointCategoryService")
|
||||
public class PointCategoryServiceImpl extends ServiceImpl<PointCategoryDao, PointCategoryEntity> implements PointCategoryService {
|
||||
|
||||
|
||||
@Override
|
||||
public List<PointCategoryEntity> getCategoryList() {
|
||||
LambdaQueryWrapper<PointCategoryEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(PointCategoryEntity::getPid,0);
|
||||
wrapper.orderByDesc(PointCategoryEntity::getSort);
|
||||
List<PointCategoryEntity> list = list(wrapper);
|
||||
for (PointCategoryEntity p : list){
|
||||
LambdaQueryWrapper<PointCategoryEntity> wrapper1 = new LambdaQueryWrapper<>();
|
||||
wrapper1.eq(PointCategoryEntity::getPid,p.getId());
|
||||
wrapper1.orderByDesc(PointCategoryEntity::getSort);
|
||||
List<PointCategoryEntity> list1 = list(wrapper1);
|
||||
p.setChildren(list1);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user