|
@@ -15,6 +15,7 @@ import com.ruoyi.app.service.ITbFamilyService;
|
|
|
import com.ruoyi.app.service.ITbMemberMiddleService;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
+import com.ruoyi.common.utils.bean.BeanUtils;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
@@ -22,9 +23,7 @@ import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.aspectj.weaver.bcel.AtAjAttributes;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
@@ -92,10 +91,34 @@ public class FamilyMemberController extends AppBaseController {
|
|
|
return AjaxResult.success(memberService.getFamilyTree(familyId));
|
|
|
}
|
|
|
|
|
|
- //TODO 添加成员到家族树
|
|
|
- public AjaxResult addToTree(@LoginAppUser TbAppUser user, Long familyId){
|
|
|
- return null;
|
|
|
+ @ApiOperation("添加成员-家族树")
|
|
|
+ @PostMapping("/addToTree")
|
|
|
+ public AjaxResult addToTree(@LoginAppUser TbAppUser user, @RequestBody TbMemberMiddle member){
|
|
|
+ if (member == null) {
|
|
|
+ return AjaxResult.error("数据为空");
|
|
|
+ }
|
|
|
+ if (member.getFamilyId()==null) {
|
|
|
+ return AjaxResult.error("家族id不能为空");
|
|
|
+ }
|
|
|
+ if (member.getParentId()==null) {
|
|
|
+ return AjaxResult.error("父辈不能为空");
|
|
|
+ }
|
|
|
+ if (member.getMemberId()==null) {
|
|
|
+ return AjaxResult.error("姓名不能为空");
|
|
|
+ }
|
|
|
+ TbMemberMiddle middle = middleService.getOne(new LambdaQueryWrapper<TbMemberMiddle>()
|
|
|
+ .eq(TbMemberMiddle::getFamilyId,member.getFamilyId())
|
|
|
+ .eq(TbMemberMiddle::getMemberId,member.getMemberId())
|
|
|
+ .last("limit 1")
|
|
|
+ );
|
|
|
+ middle.setParentId(member.getParentId());
|
|
|
+ if(!middleService.updateById(middle)){
|
|
|
+ return AjaxResult.error("添加失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ return AjaxResult.success("添加成功");
|
|
|
}
|
|
|
|
|
|
- //TODO 逻辑删除家族树的成员,是删除成员,还是从家族树撤下来;或者是已删除,但parentId还在
|
|
|
+ //TODO 逻辑删除家族树的成员(去掉parentId);如果这一代只有他一个,则不允许删除,否则家族树会断开
|
|
|
+
|
|
|
}
|