Przeglądaj źródła

feat: mini program : invite to dept

Blizzard 1 rok temu
rodzic
commit
e3a5d839e2

+ 37 - 0
blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/ApplyJoin.java

@@ -0,0 +1,37 @@
+package com.wtkj.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author Blizzard
+ * @create at 2023-10-06 10:37
+ * @describe
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@TableName("blade_apply_join")
+public class ApplyJoin extends BaseEntity {
+
+	private static final long serialVersionUID = 1L;
+
+	@JsonSerialize(using = ToStringSerializer.class)
+	@TableField("user_id")
+	@NotNull(message = "userId can't be null")
+	private Long userId;
+
+	@JsonSerialize(using = ToStringSerializer.class)
+	@TableField("dept_id")
+	@NotNull(message = "deptId can't be null")
+	private Long deptId;
+
+	@TableField("is_agree")
+	private Integer isAgree = 0;
+}

+ 20 - 0
blade-service-api/wt-okr-api/src/main/java/com/wtkj/vo/ApplyJoinVO.java

@@ -0,0 +1,20 @@
+package com.wtkj.vo;
+
+import com.wtkj.entity.ApplyJoin;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.system.user.entity.User;
+
+/**
+ * @author Blizzard
+ * @create at 2023-10-06 10:59
+ * @describe
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class ApplyJoinVO extends ApplyJoin {
+	private static final long serialVersionUID = 1L;
+
+	private User user;
+
+}

+ 42 - 4
blade-service/wt-okr/src/main/java/com/wtkj/controller/QrCodeController.java

@@ -1,12 +1,19 @@
 package com.wtkj.controller;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import com.wtkj.dto.InviteToDeptDTO;
+import com.wtkj.entity.ApplyJoin;
 import com.wtkj.entity.FileShare;
+import com.wtkj.service.IApplyJoinService;
 import com.wtkj.service.IQrcodeService;
+import com.wtkj.wrapper.ApplyJoinWrapper;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
 import org.springframework.web.bind.annotation.*;
@@ -25,6 +32,7 @@ import javax.validation.Valid;
 public class QrCodeController {
 
 	private final IQrcodeService qrcodeService;
+	private final IApplyJoinService applyJoinService;
 
 	/**
 	 * 生成二维码
@@ -46,12 +54,41 @@ public class QrCodeController {
 		return R.status(qrcodeService.inviteToDept(dto.getCreateUser(), dto.getType(), dto.getQrcodeId(), AuthUtil.getUserId(), dto.getDeptId()));
 	}
 
+
+	@PostMapping("/apply-to-dept")
+	@ApiOperation(value = "申请加入机构", notes = "")
+	@ApiOperationSupport(order = 3)
+	public R applyToDept(@RequestBody @Valid ApplyJoin join) {
+		return R.status(applyJoinService.saveOrUpdate(join));
+	}
+
+	/**
+	 * 申请列表
+	 */
+	@GetMapping("/apply-page")
+	@ApiOperation(value = "申请列表", notes = "传入当前登录用户顶级机构id")
+	@ApiOperationSupport(order = 4)
+	public R applyPage(@RequestParam Long topDept, Query query) {
+		IPage<ApplyJoin> page = applyJoinService.page(Condition.getPage(query), new LambdaQueryWrapper<ApplyJoin>().eq(ApplyJoin::getDeptId, topDept));
+		return R.data(ApplyJoinWrapper.build().pageVO(page));
+	}
+
+	/**
+	 * 同意加入组织
+	 */
+	@GetMapping("/agree-apply")
+	@ApiOperation(value = "同意加入机构", notes = "传入记录主键id")
+	@ApiOperationSupport(order = 5)
+	public R agreeJoinDept(@RequestParam Long id) {
+		return R.status(applyJoinService.agreeApply(id));
+	}
+
 	/**
 	 * 生成邀请至项目组二维码
 	 */
 	@GetMapping("/create-group-qrcode")
 	@ApiOperation(value = "生成邀请至项目组二维码", notes = "")
-	@ApiOperationSupport(order = 3)
+	@ApiOperationSupport(order = 6)
 	public R createGroupQrcode(@RequestParam Long projectId) {
 		return R.data(qrcodeService.createGroupQrcode(projectId));
 	}
@@ -62,7 +99,7 @@ public class QrCodeController {
 	 */
 	@GetMapping("/invite-to-project")
 	@ApiOperation(value = "接受邀请至项目组", notes = "deptId:服务商的顶级机构id")
-	@ApiOperationSupport(order = 4)
+	@ApiOperationSupport(order = 7)
 	public R inviteToProject(@RequestParam String qrcodeId, @RequestParam Long topDept, @RequestParam Long projectId) {
 		return R.status(qrcodeService.inviteToProject(qrcodeId, topDept, projectId));
 	}
@@ -72,7 +109,7 @@ public class QrCodeController {
 	 * 生成一条分享记录
 	 */
 	@PostMapping("/save-share")
-	@ApiOperationSupport(order = 5)
+	@ApiOperationSupport(order = 8)
 	@ApiOperation(value = "生成文件分享", notes = "ids:文件的")
 	public R saveShare(@RequestBody FileShare share) {
 		return R.data(qrcodeService.savaShare(share));
@@ -82,10 +119,11 @@ public class QrCodeController {
 	 * 查看分享
 	 */
 	@PostMapping("/get-share")
-	@ApiOperationSupport(order = 6)
+	@ApiOperationSupport(order = 9)
 	@ApiOperation(value = "查看文件分享", notes = "传入二维码返回ID")
 	public R getShare(@RequestParam Long id) {
 		return R.data(qrcodeService.getShare(id));
 	}
 
+
 }

+ 12 - 0
blade-service/wt-okr/src/main/java/com/wtkj/mapper/ApplyJoinMapper.java

@@ -0,0 +1,12 @@
+package com.wtkj.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.wtkj.entity.ApplyJoin;
+
+/**
+ * @author Blizzard
+ * @create at 2023-10-06 10:46
+ * @describe
+ */
+public interface ApplyJoinMapper extends BaseMapper<ApplyJoin> {
+}

+ 6 - 0
blade-service/wt-okr/src/main/java/com/wtkj/mapper/ApplyJoinMapper.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.wtkj.mapper.ApplyJoinMapper">
+
+
+</mapper>

+ 13 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/IApplyJoinService.java

@@ -0,0 +1,13 @@
+package com.wtkj.service;
+
+import com.wtkj.entity.ApplyJoin;
+import org.springblade.core.mp.base.BaseService;
+
+/**
+ * @author Blizzard
+ * @create at 2023-10-06 10:47
+ * @describe
+ */
+public interface IApplyJoinService extends BaseService<ApplyJoin> {
+	boolean agreeApply(Long id);
+}

+ 37 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/ApplyJoinServiceImpl.java

@@ -0,0 +1,37 @@
+package com.wtkj.service.impl;
+
+import com.wtkj.entity.ApplyJoin;
+import com.wtkj.mapper.ApplyJoinMapper;
+import com.wtkj.service.IApplyJoinService;
+import io.seata.spring.annotation.GlobalTransactional;
+import lombok.AllArgsConstructor;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.system.user.feign.IUserClient;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author Blizzard
+ * @create at 2023-10-06 10:48
+ * @describe
+ */
+@Service
+@AllArgsConstructor
+public class ApplyJoinServiceImpl extends BaseServiceImpl<ApplyJoinMapper, ApplyJoin> implements IApplyJoinService {
+
+	private final IUserClient userClient;
+
+	@Override
+	@GlobalTransactional(rollbackFor = Exception.class)
+	public boolean agreeApply(Long id) {
+		boolean flag = false;
+		ApplyJoin byId = this.getById(id);
+		if (byId != null) {
+			Long userId = byId.getUserId();
+			Long deptId = byId.getDeptId();
+			userClient.bindUser(userId, deptId);
+			byId.setIsAgree(1);
+			flag = this.updateById(byId);
+		}
+		return flag;
+	}
+}

+ 5 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/QrcodeServiceImpl.java

@@ -41,6 +41,7 @@ public class QrcodeServiceImpl implements IQrcodeService {
 	private final IProjectService projectService;
 	private final IFileShareService fileShareService;
 	private final IFileClient fileClient;
+	private final IApplyJoinService applyJoinService;
 
 	@Override
 	public JSONObject createQrcode() {
@@ -60,6 +61,10 @@ public class QrcodeServiceImpl implements IQrcodeService {
 		boolean exist = isExist(qrcodeId);
 		//二维码可用前提下
 		if (exist) {
+//			ApplyJoin join = new ApplyJoin();
+//			join.setDeptId(deptId);
+//			join.setUserId(userId);
+//			flag = applyJoinService.save(join);
 			//1.绑定机构
 			R<Boolean> rpc = userClient.bindUser(userId, deptId);
 			//2.保存外部联系人

+ 38 - 0
blade-service/wt-okr/src/main/java/com/wtkj/wrapper/ApplyJoinWrapper.java

@@ -0,0 +1,38 @@
+package com.wtkj.wrapper;
+
+import com.wtkj.entity.ApplyJoin;
+import com.wtkj.vo.ApplyJoinVO;
+import org.springblade.core.mp.support.BaseEntityWrapper;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.core.tool.utils.SpringUtil;
+import org.springblade.system.user.entity.User;
+import org.springblade.system.user.feign.IUserClient;
+
+import java.util.Objects;
+
+/**
+ * @author Blizzard
+ * @create at 2023-10-06 11:00
+ * @describe
+ */
+public class ApplyJoinWrapper extends BaseEntityWrapper<ApplyJoin, ApplyJoinVO> {
+
+	private static IUserClient userClient;
+
+	public static ApplyJoinWrapper build() {
+		userClient = SpringUtil.getBean(IUserClient.class);
+		return new ApplyJoinWrapper();
+	}
+
+	@Override
+	public ApplyJoinVO entityVO(ApplyJoin entity) {
+		ApplyJoinVO vo = Objects.requireNonNull(BeanUtil.copy(entity, ApplyJoinVO.class));
+		Long userId = entity.getUserId();
+		R<User> userR = userClient.userInfoById(userId);
+		if (userR.isSuccess()) {
+			vo.setUser(userR.getData());
+		}
+		return vo;
+	}
+}