Bladeren bron

添加设置互助组组长,互助组是够锁定,管理互助组内边民功能

loovi 1 jaar geleden
bovenliggende
commit
97de5bbcf6

+ 5 - 2
sp-service/level-one-server/src/main/java/com/pj/tb_group/TbGroup.java

@@ -128,9 +128,12 @@ public class TbGroup extends Model<TbGroup> implements Serializable {
 	/**
 	 * 删除状态(0=禁用,1=启用) 
 	 */
-	private Integer deleteStatus;	
-
+	private Integer deleteStatus;
 
+	/**
+	 * 是否锁定
+	 */
+	private Integer isLock;
 
 
 

+ 123 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_group/TbGroupController.java

@@ -1,8 +1,17 @@
 package com.pj.tb_group;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
+import java.util.Objects;
+
+import cn.dev33.satoken.stp.StpUtil;
+import com.pj.tb_enterprise.TbEnterprise;
+import com.pj.tb_people.TbPeople;
+import com.pj.tb_people.TbPeopleService;
 import com.pj.utils.so.SoMap;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
@@ -26,6 +35,8 @@ public class TbGroupController {
 	/** 底层 Service 对象 */
 	@Autowired
 	TbGroupService tbGroupService;
+	@Autowired
+	TbPeopleService tbPeopleService;
 
 	/** 增 */  
 	@RequestMapping("add")
@@ -125,7 +136,119 @@ public class TbGroupController {
 		return AjaxJson.getError();
 	}
 
+	/**
+	 *设置互助组组长
+	 *
+	 * @author loovi
+	 * @date
+	 */
+	@RequestMapping("setLeader")
+	@SaCheckPermission(TbGroup.PERMISSION_CODE_EDIT)
+	public AjaxJson setLeader(Long groupId,Long leaderId){
+
+		Long loginId = StpUtil.getLoginIdAsLong();
+
+		TbGroup tbGroup = tbGroupService.getById(groupId);
+		TbPeople tbPeople = tbPeopleService.getById(leaderId);
+		if (Objects.isNull(tbGroup)){
+			return AjaxJson.getSuccess("该互助组不存在");
+		}
+		if (Objects.isNull(tbPeople)){
+			return AjaxJson.getSuccess("该用户不存在");
+		}
+		if(tbGroup.getIsLock()==1){
+			return AjaxJson.getSuccess("该互助组已被锁定");
+		}
+		if (tbPeople.getIsLock()==1){
+			return AjaxJson.getSuccess("该用户已被锁定");
+		}
+
+		tbGroup.setLeaderId(tbGroup.getLeaderId());
+		tbGroup.setLeaderName(tbPeople.getName());
+		tbGroup.setLeaderPhone(tbGroup.getLeaderPhone());
+
+		tbGroup.setUpdateBy(String.valueOf(loginId));
+		tbGroupService.update(tbGroup);
+		return AjaxJson.getSuccess();
+	}
+	/**
+	*向互助组添加边民
+	*
+	* @author loovi
+	* @date
+	*/
+	@RequestMapping("groupAddPeople")
+	@SaCheckPermission(TbGroup.PERMISSION_CODE_EDIT)
+	public AjaxJson GroupAddPeople(Long groupId,Long []peopleIds){
+
+		Long loginId = StpUtil.getLoginIdAsLong();
 
+		TbGroup tbGroup = tbGroupService.getById(groupId);
+		if (Objects.isNull(tbGroup)){
+			return AjaxJson.getSuccess("该互助组不存在");
+		}
+		if(tbGroup.getIsLock()==1){
+			return AjaxJson.getSuccess("该互助组已被锁定");
+		}
+		List<Long> list = Arrays.asList(peopleIds);
+
+		list.forEach(peopleId->{
+			TbPeople tbPeople = tbPeopleService.getById(peopleId);
+			tbPeople.setGroupId(tbGroup.getId());
+			tbPeople.setGroupName(tbGroup.getName());
+			tbGroup.setUpdateBy(String.valueOf(loginId));
+			tbPeopleService.updateById(tbPeople);
+		});
+		return AjaxJson.getSuccess();
+	}
+	/**
+	 *互助组删除边民
+	 *
+	 * @author loovi
+	 * @date
+	 */
+	@RequestMapping("groupDelPeople")
+	@SaCheckPermission(TbGroup.PERMISSION_CODE_EDIT)
+	public AjaxJson GroupDelPeople(Long groupId,Long []peopleIds){
+
+		Long loginId = StpUtil.getLoginIdAsLong();
+
+		TbGroup tbGroup = tbGroupService.getById(groupId);
+		if (Objects.isNull(tbGroup)){
+			return AjaxJson.getSuccess("该互助组不存在");
+		}
+		if(tbGroup.getIsLock()==1){
+			return AjaxJson.getSuccess("该互助组已被锁定");
+		}
+		List<Long> list = Arrays.asList(peopleIds);
+
+		list.forEach(peopleId->{
+			TbPeople tbPeople = tbPeopleService.getById(peopleId);
+			tbPeople.setGroupId(0L);
+			tbPeople.setGroupName("");
+			tbGroup.setUpdateBy(String.valueOf(loginId));
+			tbPeopleService.updateById(tbPeople);
+		});
+		return AjaxJson.getSuccess();
+	}
+	/**
+	 *是否锁住互助组
+	 *
+	 * @author loovi
+	 * @date
+	 */
+	@RequestMapping("isLock")
+	@SaCheckPermission(TbGroup.PERMISSION_CODE_EDIT)
+	public AjaxJson isLock(Long id, Integer isLock) {
+		Long loginId = StpUtil.getLoginIdAsLong();
+		TbGroup tbGroup = tbGroupService.getById(id);
+		if (Objects.isNull(tbGroup)) {
+			return AjaxJson.getSuccess("该互助组不存在");
+		}
+		int line = SP.publicMapper.updateColumnById(TbGroup.TABLE_NAME, "is_lock", isLock, id);
+		tbGroup.setUpdateBy(String.valueOf(loginId));
+		return AjaxJson.getByLine(line);
+	}