|
@@ -15,6 +15,7 @@ import com.ruoyi.app.service.ITbFamilyService;
|
|
import com.ruoyi.app.service.ITbMemberMiddleService;
|
|
import com.ruoyi.app.service.ITbMemberMiddleService;
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
import com.ruoyi.common.utils.bean.BeanUtils;
|
|
import com.ruoyi.common.utils.bean.BeanUtils;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
@@ -119,6 +120,55 @@ public class FamilyMemberController extends AppBaseController {
|
|
return AjaxResult.success("添加成功");
|
|
return AjaxResult.success("添加成功");
|
|
}
|
|
}
|
|
|
|
|
|
- //TODO 逻辑删除家族树的成员(去掉parentId);如果这一代只有他一个,则不允许删除,否则家族树会断开
|
|
|
|
|
|
+ @ApiOperation(value = "逻辑删除家族树的成员", notes = "逻辑删除家族树的成员(去掉parentId);如果这一代只有他一个,则不允许删除,否则家族树会断开")
|
|
|
|
+ @PostMapping("/delToTree")
|
|
|
|
+ public AjaxResult delToTree(Long memberId, Long familyId) {
|
|
|
|
+ if (memberId == null || familyId ==null) {
|
|
|
|
+ return AjaxResult.error("参数不能为空");
|
|
|
|
+ }
|
|
|
|
+ TbMemberMiddle middle = middleService.getOne(new LambdaQueryWrapper<TbMemberMiddle>()
|
|
|
|
+ .eq(TbMemberMiddle::getFamilyId,familyId)
|
|
|
|
+ .eq(TbMemberMiddle::getMemberId,memberId)
|
|
|
|
+ .last("limit 1")
|
|
|
|
+ );
|
|
|
|
+ if (middle == null) {
|
|
|
|
+ return AjaxResult.error("删除失败");
|
|
|
|
+ }
|
|
|
|
+ if (middle.getParentId() == null) {
|
|
|
|
+ return AjaxResult.error("该成员没有在家族树中");
|
|
|
|
+ }
|
|
|
|
+ List<TbMemberMiddle> middleList = middleService.list(new LambdaQueryWrapper<TbMemberMiddle>()
|
|
|
|
+ .eq(TbMemberMiddle::getParentId, middle.getParentId())
|
|
|
|
+ );
|
|
|
|
+ if (middleList.size() == 1) {
|
|
|
|
+ return AjaxResult.error("这一代只有一位成员,不允许删除");
|
|
|
|
+ }
|
|
|
|
+ // 设置parentId为空
|
|
|
|
+ middle.setParentId(null);
|
|
|
|
+ if(!middleService.updateById(middle)){
|
|
|
|
+ return AjaxResult.error("删除失败");
|
|
|
|
+ }
|
|
|
|
+ return AjaxResult.success("删除成功");
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ @ApiOperation("编辑成员")
|
|
|
|
+ @PostMapping("/edit")
|
|
|
|
+ public AjaxResult edit(@RequestBody AppMemberVo member) {
|
|
|
|
+ if (member == null) {
|
|
|
|
+ return AjaxResult.error("成员信息不能为空");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(member.getMobile())){
|
|
|
|
+ return AjaxResult.error("手机号不能为空");
|
|
|
|
+ }
|
|
|
|
+ AppMemberVo memberVo = appUserService.getAppMember(null,member.getMobile());
|
|
|
|
+ if (memberVo == null) {
|
|
|
|
+ return AjaxResult.error("保存失败,成员信息不能为空");
|
|
|
|
+ }
|
|
|
|
+ // TODO copy后,id不知道还有没有
|
|
|
|
+ BeanUtils.copyBeanProp(memberVo,member);
|
|
|
|
+ if(!appUserService.saveOrUpdate(memberVo)){
|
|
|
|
+ return AjaxResult.error("保存失败");
|
|
|
|
+ }
|
|
|
|
+ return AjaxResult.success("保存成功");
|
|
|
|
+ }
|
|
}
|
|
}
|