Browse Source

实名认证

liujc 2 years ago
parent
commit
c0822177cf

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ImGroup.java

@@ -31,7 +31,7 @@ public class ImGroup extends BaseEntity {
 	
 	private String img;
 
-	/** 乐团群 MUSIC,班级群 CLASS,训练营 TRAINING */
+	/** 乐团群 MUSIC,班级群 CLASS,训练营 TRAINING 学校SCHOOL*/
 	private String type;
 
 	public enum GroupTypeEnum implements BaseEnum<String,GroupTypeEnum> {

+ 16 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SchoolStaffService.java

@@ -74,4 +74,20 @@ public interface SchoolStaffService extends IService<SchoolStaff>  {
      * @param id 用户ID
      */
     Boolean del(Long id);
+
+    /**
+     * 实名认证
+     *
+     * @param realName 姓名
+     * @param idcardNo 身份证号
+     */
+    void realNameAuthentication(Integer userId,String realName, String idcardNo);
+
+    /**
+     * 查询学校员工信息
+     *
+     * @param userId 用户ID
+     * @return SchoolStaff
+     */
+    SchoolStaff getByUserId(Integer userId);
 }

+ 47 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SchoolStaffServiceImpl.java

@@ -19,6 +19,8 @@ import com.ym.mec.biz.dal.wrapper.StatGroupWrapper;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
+import com.ym.mec.thirdparty.user.realname.RealnameAuthenticationPluginContext;
+import com.ym.mec.thirdparty.user.realname.provider.LinkfaceRealnameAuthenticationPlugin;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -64,6 +66,8 @@ public class SchoolStaffServiceImpl extends ServiceImpl<SchoolStaffMapper, Schoo
     private ImUserFriendDao imUserFriendDao;
 
 
+    @Autowired
+    private RealnameAuthenticationPluginContext realnameAuthenticationPluginContext;
 
     @Value("${message.debugMode:false}")
     private boolean debugMode;
@@ -535,5 +539,48 @@ public class SchoolStaffServiceImpl extends ServiceImpl<SchoolStaffMapper, Schoo
 
     }
 
+    /**
+     * 实名认证
+     *
+     * @param realName 姓名
+     * @param idcardNo 身份证号
+     */
+    @Override
+    public void realNameAuthentication(Integer userId,String realName, String idcardNo) {
+
+
+        SchoolStaff schoolStaff = schoolStaffService.getByUserId(userId);
+        if (schoolStaff == null) {
+            throw new BizException("用户信息不存在");
+        }
+
+        // 验证数据合法
+        if (!debugMode) {
+            realnameAuthenticationPluginContext.getRealnameAuthenticationPlugin(LinkfaceRealnameAuthenticationPlugin.getName()).verify(realName, idcardNo);
+        }
+
+        // 保存到sys_user表中
+        SysUser user = new SysUser();
+        user.setRealName(realName);
+        user.setIdCardNo(idcardNo);
+        user.setUpdateTime(new Date());
+        teacherDao.updateUser(user);
+    }
+
+    /**
+     * 查询学校员工信息
+     *
+     * @param userId 用户ID
+     * @return SchoolStaff
+     */
+    @Override
+    public SchoolStaff getByUserId(Integer userId) {
+        return this.lambdaQuery()
+                .eq(SchoolStaff::getUserId, userId)
+                .ne(SchoolStaff::getStatus, -1)
+                .last("limit 1")
+                .one();
+    }
+
 
 }

+ 19 - 0
mec-web/src/main/java/com/ym/mec/web/controller/school/SchoolStaffController.java

@@ -20,6 +20,8 @@ import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.page.PageUtil;
 import com.ym.mec.common.tenant.TenantContextHolder;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -231,4 +233,21 @@ public class SchoolStaffController extends BaseController {
         return succeed();
     }
 
+
+    @ApiOperation(value = "实名认证")
+    @PostMapping("/realNameAuthentication")
+    @ApiImplicitParams({ @ApiImplicitParam(name = "realName", value = "姓名", required = true, dataType = "String"),
+            @ApiImplicitParam(name = "idcardNo", value = "身份证号码", required = true, dataType = "String")})
+    public Object realNameAuthentication(String realName, String idcardNo) {
+
+        if (StringUtils.isEmpty(realName)) {
+            throw new BizException("姓名不能为空");
+        }
+        if (StringUtils.isEmpty(idcardNo)) {
+            throw new BizException("身份证号不能为空");
+        }
+        schoolStaffService.realNameAuthentication(sysUserFeignService.queryUserInfo().getId(),realName, idcardNo);
+        return succeed();
+    }
+
 }