diff --git a/ruoyi-abuwx/src/main/java/com/ruoyi/abuwxapi/WxLoginController.java b/ruoyi-abuwx/src/main/java/com/ruoyi/abuwxapi/WxLoginController.java index 3e5441e..f912475 100644 --- a/ruoyi-abuwx/src/main/java/com/ruoyi/abuwxapi/WxLoginController.java +++ b/ruoyi-abuwx/src/main/java/com/ruoyi/abuwxapi/WxLoginController.java @@ -133,7 +133,7 @@ public class WxLoginController extends BaseController { String filePath = RuoYiConfig.getUploadPath(); // 上传并返回新文件名称 String fileName = FileUploadUtils.upload(filePath, file); - String url = serverConfig.getUrl() + fileName; + String url = serverConfig.getUrl() + "/prod-api"+ fileName; AjaxResult ajax = success(); ajax.put("url", url); ajax.put("fileName", fileName); @@ -216,6 +216,13 @@ public class WxLoginController extends BaseController { String username = sysUser.getUserName(); String password = sysUser.getPassword(); String openid = sysUser.getOpenid(); + List userList = iSysUserService.selectList(); + List collect = userList.stream().filter(data -> data.getOpenid() != null + && data.getOpenid().equals(openid)).collect(Collectors.toList()); + if(collect.size() != 0){ + //当前用户已绑定过角色 + return error("当前用户已绑定过角色!"); + } //校验传递的用户名、密码、openid都不为空 if(StringUtils.isEmpty(username) || StringUtils.isEmpty(password) || StringUtils.isEmpty(openid)){ return error(); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java index 256367b..4e6eecd 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java @@ -1,21 +1,5 @@ package com.ruoyi.web.controller.system; -import java.util.List; -import java.util.stream.Collectors; -import javax.servlet.http.HttpServletResponse; -import org.apache.commons.lang3.ArrayUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; @@ -31,10 +15,20 @@ import com.ruoyi.system.service.ISysDeptService; import com.ruoyi.system.service.ISysPostService; import com.ruoyi.system.service.ISysRoleService; import com.ruoyi.system.service.ISysUserService; +import org.apache.commons.lang3.ArrayUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.stream.Collectors; /** * 用户信息 - * + * * @author ruoyi */ @RestController @@ -248,4 +242,15 @@ public class SysUserController extends BaseController { return success(deptService.selectDeptTreeList(dept)); } + + /** + * 解绑操作,将此用户openid置为空 + * @param userId 用户表id + * @return + */ + @RequestMapping(value = "/unbinding") + public AjaxResult unbinding(@RequestParam Long userId){ + SysUser user = userService.unbinding(userId); + return success(user); + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java index 6e2156d..baaeedc 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java @@ -216,4 +216,11 @@ public interface ISysUserService * @return */ public List selectList(); + + /** + * 解绑操作 + * @param userId + * @return + */ + public SysUser unbinding(Long userId); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index 9f92225..9f97cdc 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -568,4 +568,17 @@ public class SysUserServiceImpl implements ISysUserService List userList = userMapper.selectList(); return userList; } + + /** + * 解绑操作 + * @param userId 用户表id + * @return + */ + @Override + public SysUser unbinding(Long userId) { + SysUser user = iSysUserService.selectUserById(userId); + user.setOpenid(""); + userMapper.updateUser(user); + return user; + } }