ソースを参照

:sparkles: 添加新特性。完善後台綁定的代碼

冷冷 7 年 前
コミット
9dfd44766c
18 ファイル変更497 行追加141 行削除
  1. 1 27
      pigx-auth/src/main/java/com/pig4cloud/pigx/auth/service/PigxUserDetailsServiceImpl.java
  2. 6 0
      pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/SecurityConstants.java
  3. 1 13
      pigx-config/src/main/resources/config/pigx-auth-dev.yml
  4. 87 0
      pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysSocialDetails.java
  5. 3 5
      pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteUserService.java
  6. 3 5
      pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/fallback/RemoteUserServiceFallbackImpl.java
  7. 1 1
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/config/ResourceServerConfigurer.java
  8. 132 0
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysSocialDetailsController.java
  9. 0 24
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/UserController.java
  10. 33 0
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysSocialDetailsMapper.java
  11. 50 0
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysSocialDetailsService.java
  12. 0 9
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysUserService.java
  13. 118 0
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysSocialDetailsServiceImpl.java
  14. 1 32
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserServiceImpl.java
  15. 37 0
      pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysSocialDetailsMapper.xml
  16. 5 9
      pigx-visual/pigx-codegen/src/main/resources/template/Controller.java.vm
  17. 10 10
      pigx-visual/pigx-codegen/src/main/resources/template/crud.js.vm
  18. 9 6
      pigx-visual/pigx-codegen/src/main/resources/template/index.vue.vm

+ 1 - 27
pigx-auth/src/main/java/com/pig4cloud/pigx/auth/service/PigxUserDetailsServiceImpl.java

@@ -21,7 +21,6 @@ package com.pig4cloud.pigx.auth.service;
 
 import cn.hutool.core.util.ArrayUtil;
 import cn.hutool.core.util.StrUtil;
-import cn.hutool.json.JSONUtil;
 import com.pig4cloud.pigx.admin.api.dto.UserInfo;
 import com.pig4cloud.pigx.admin.api.entity.SysUser;
 import com.pig4cloud.pigx.admin.api.feign.RemoteUserService;
@@ -29,7 +28,6 @@ import com.pig4cloud.pigx.common.core.constant.CommonConstant;
 import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
 import com.pig4cloud.pigx.common.core.constant.enums.EnumLoginType;
 import com.pig4cloud.pigx.common.core.util.R;
-import com.pig4cloud.pigx.common.security.social.WxSocialConfig;
 import com.pig4cloud.pigx.common.security.util.PigxUserDetailsService;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -39,7 +37,6 @@ import org.springframework.security.core.userdetails.User;
 import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.security.core.userdetails.UsernameNotFoundException;
 import org.springframework.stereotype.Service;
-import org.springframework.web.client.RestTemplate;
 
 import java.util.Arrays;
 import java.util.Collection;
@@ -55,12 +52,7 @@ import java.util.Set;
 @Service
 @AllArgsConstructor
 public class PigxUserDetailsServiceImpl implements PigxUserDetailsService {
-	private static final String WX_AUTHORIZATION_CODE_URL = "https://api.weixin.qq.com/sns/oauth2/access_token" +
-		"?appid=%s&secret=%s&code=%s&grant_type=authorization_code";
-	private static final String REGEX = "@";
-	private final RestTemplate restTemplate;
 	private final RemoteUserService remoteUserService;
-	private final WxSocialConfig wxSocialConfig;
 
 	/**
 	 * 用户密码登录
@@ -85,25 +77,7 @@ public class PigxUserDetailsServiceImpl implements PigxUserDetailsService {
 	 */
 	@Override
 	public UserDetails loadUserBySocial(String inStr) throws UsernameNotFoundException {
-		String[] codeStr = inStr.split(REGEX);
-		String type = codeStr[0];
-		String code = codeStr[1];
-
-		R<UserInfo> userInfo = null;
-		if (EnumLoginType.WECHAT.getType().equals(type)) {
-			String url = String.format(WX_AUTHORIZATION_CODE_URL
-				, wxSocialConfig.getAppid(), wxSocialConfig.getSecret(), code);
-			String result = restTemplate.getForObject(url, String.class);
-			log.debug("微信响应报文:{}", result);
-
-			Object obj = JSONUtil.parseObj(result).get("openid");
-			if (obj != null) {
-				userInfo = remoteUserService.social(EnumLoginType.WECHAT.getType(), obj.toString());
-			}
-
-		}
-
-		return getUserDetails(userInfo);
+		return getUserDetails(remoteUserService.social(inStr));
 	}
 
 	/**

+ 6 - 0
pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/constant/SecurityConstants.java

@@ -78,4 +78,10 @@ public interface SecurityConstants {
 	 * 手机号登录URL
 	 */
 	String MOBILE_TOKEN_URL = "/mobile/token";
+
+	/**
+	 * 微信获取OPENID
+	 */
+	String WX_AUTHORIZATION_CODE_URL = "https://api.weixin.qq.com/sns/oauth2/access_token" +
+		"?appid=%s&secret=%s&code=%s&grant_type=authorization_code";
 }

+ 1 - 13
pigx-config/src/main/resources/config/pigx-auth-dev.yml

@@ -5,16 +5,4 @@ spring:
     driver-class-name: com.mysql.jdbc.Driver
     username: root
     password: root
-    url: jdbc:mysql://mysql:3306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
-
-# 社交登录配置新
-social:
-  wx:
-    appid: wxd1678d3f83b1d83a
-    secret: 6ddb043f94da5d2172926abe8533504f
-
-# 社交登录配置新
-social:
-  wx:
-    appid: wxd1678d3f83b1d83a
-    secret: 6ddb043f94da5d2172926abe8533504f
+    url: jdbc:mysql://114.116.45.246:13306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false

+ 87 - 0
pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysSocialDetails.java

@@ -0,0 +1,87 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.admin.api.entity;
+
+import com.baomidou.mybatisplus.activerecord.Model;
+import com.baomidou.mybatisplus.annotations.TableId;
+import com.baomidou.mybatisplus.annotations.TableLogic;
+import com.baomidou.mybatisplus.annotations.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+  import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * 系统社交登录账号表
+ *
+ * @author pigx code generator
+ * @date 2018-08-16 21:30:41
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@TableName("sys_social_details")
+public class SysSocialDetails extends Model<SysSocialDetails> {
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 主鍵
+	 */
+	@TableId
+	private Integer id;
+	/**
+	 * 类型
+	 */
+	private String type;
+	/**
+	 * 描述
+	 */
+	private String remark;
+	/**
+	 * appid
+	 */
+	private String appId;
+	/**
+	 * app_secret
+	 */
+	private String appSecret;
+	/**
+	 * 回调地址
+	 */
+	private String redirectUrl;
+	/**
+	 * 创建时间
+	 */
+	private LocalDateTime createTime;
+	/**
+	 * 更新时间
+	 */
+	private LocalDateTime updateTime;
+	/**
+	 * 删除标记
+	 */
+	@TableLogic
+	private String delFlag;
+
+  /**
+   * 主键值
+   */
+  @Override
+  protected Serializable pkVal() {
+    return this.id;
+  }
+}

+ 3 - 5
pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteUserService.java

@@ -48,11 +48,9 @@ public interface RemoteUserService {
 	/**
 	 * 通过社交账号查询用户、角色信息
 	 *
-	 * @param type   社交账号类型 (QQ/WX)
-	 * @param openid 账号
+	 * @param inStr appid@code
 	 * @return
 	 */
-	@GetMapping("/user/social/{type}/{openid}")
-	R<UserInfo> social(@PathVariable("type") String type
-		, @PathVariable("openid") String openid);
+	@GetMapping("/social/info/{inStr}")
+	R<UserInfo> social(@PathVariable("inStr") String inStr);
 }

+ 3 - 5
pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/fallback/RemoteUserServiceFallbackImpl.java

@@ -48,14 +48,12 @@ public class RemoteUserServiceFallbackImpl implements RemoteUserService {
 	/**
 	 * 通过社交账号查询用户、角色信息
 	 *
-	 * @param type   社交账号类型 (QQ/WX)
-	 * @param openid 账号
+	 * @param inStr appid@code
 	 * @return
 	 */
 	@Override
-	public R<UserInfo> social(String type, String openid) {
-		log.error("feign 查询用户信息失败:{}", openid);
+	public R<UserInfo> social(String inStr) {
+		log.error("feign 查询用户信息失败:{}", inStr);
 		return null;
 	}
-
 }

+ 1 - 1
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/config/ResourceServerConfigurer.java

@@ -46,7 +46,7 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
 		http.authorizeRequests()
 			.antMatchers("/actuator/**"
 				, "/user/info/*"
-				, "/user/social/**"
+				, "/social/info/**"
 				, "/log/**"
 				, "/v2/api-docs").permitAll()
 			.anyRequest().authenticated()

+ 132 - 0
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysSocialDetailsController.java

@@ -0,0 +1,132 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.admin.controller;
+
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.baomidou.mybatisplus.plugins.Page;
+import com.pig4cloud.pigx.admin.api.dto.UserInfo;
+import com.pig4cloud.pigx.admin.api.entity.SysSocialDetails;
+import com.pig4cloud.pigx.admin.service.SysSocialDetailsService;
+import com.pig4cloud.pigx.admin.service.SysUserService;
+import com.pig4cloud.pigx.common.core.util.Query;
+import com.pig4cloud.pigx.common.core.util.R;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Arrays;
+import java.util.Map;
+
+
+/**
+ * 系统社交登录账号表
+ *
+ * @author pigx code generator
+ * @date 2018-08-16 21:30:41
+ */
+@RestController
+@RequestMapping("/social")
+@AllArgsConstructor
+public class SysSocialDetailsController {
+	private final SysUserService sysUserService;
+	private final SysSocialDetailsService sysSocialDetailsService;
+
+
+	/**
+	 * 列表
+	 *
+	 * @param params
+	 * @return
+	 */
+	@GetMapping("/page")
+	public Page page(@RequestParam Map<String, Object> params) {
+		return sysSocialDetailsService.selectPage(new Query<>(params), new EntityWrapper<>());
+	}
+
+
+	/**
+	 * 信息
+	 *
+	 * @param id
+	 * @return R
+	 */
+	@GetMapping("/{id}")
+	public R info(@PathVariable("id") Integer id) {
+		SysSocialDetails sysSocialDetails = sysSocialDetailsService.selectById(id);
+		return new R<>(sysSocialDetails);
+	}
+
+	/**
+	 * 保存
+	 *
+	 * @param sysSocialDetails
+	 * @return R
+	 */
+	@PostMapping
+	public R save(@RequestBody SysSocialDetails sysSocialDetails) {
+		sysSocialDetailsService.insert(sysSocialDetails);
+		return new R<>(Boolean.TRUE);
+	}
+
+	/**
+	 * 修改
+	 *
+	 * @param sysSocialDetails
+	 * @return R
+	 */
+	@PutMapping
+	public R update(@RequestBody SysSocialDetails sysSocialDetails) {
+		sysSocialDetailsService.updateById(sysSocialDetails);
+		return new R<>(Boolean.TRUE);
+	}
+
+	/**
+	 * 删除
+	 *
+	 * @param ids
+	 * @return R
+	 */
+	@DeleteMapping
+	public R delete(@RequestBody Integer[] ids) {
+		sysSocialDetailsService.deleteBatchIds(Arrays.asList(ids));
+		return new R<>(Boolean.TRUE);
+	}
+
+	/**
+	 * 通过社交账号查询用户、角色信息
+	 *
+	 * @param inStr appid@code
+	 * @return
+	 */
+	@GetMapping("/info/{inStr}")
+	public R<UserInfo> social(@PathVariable String inStr) {
+		Map<String,String> result = sysSocialDetailsService.findOpenId(inStr);
+		return new R<>(sysUserService.findUserInfo(result.get("type"), result.get("openId")));
+	}
+
+	/**
+	 * 绑定社交账号
+	 *
+	 * @param state 类型
+	 * @param code  code
+	 * @return
+	 */
+	@PostMapping("/bind")
+	public R<Boolean> bind(String state, String code) {
+		return new R<>(sysSocialDetailsService.bindSocial(state, code));
+	}
+}

+ 0 - 24
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/UserController.java

@@ -79,30 +79,6 @@ public class UserController {
 		return new R<>(userService.findUserInfo(EnumLoginType.PWD.getType(), username));
 	}
 
-	/**
-	 * 通过社交账号查询用户、角色信息
-	 *
-	 * @param type   社交账号类型 (QQ/WX)
-	 * @param openid 账号
-	 * @return
-	 */
-	@GetMapping("/social/{type}/{openid}")
-	public R<UserInfo> social(@PathVariable String type, @PathVariable String openid) {
-		return new R<>(userService.findUserInfo(type, openid));
-	}
-
-	/**
-	 * 绑定社交账号
-	 *
-	 * @param state 类型
-	 * @param code  code
-	 * @return
-	 */
-	@PostMapping("/social/bind")
-	public R<Boolean> bind(String state, String code) {
-		return new R<>(userService.bindSocial(state, code));
-	}
-
 	/**
 	 * 通过ID查询当前用户信息
 	 *

+ 33 - 0
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysSocialDetailsMapper.java

@@ -0,0 +1,33 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.admin.mapper;
+
+import com.baomidou.mybatisplus.mapper.BaseMapper;
+import com.pig4cloud.pigx.admin.api.entity.SysSocialDetails;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 系统社交登录账号表
+ *
+ * @author pigx code generator
+ * @date 2018-08-16 21:30:41
+ */
+@Mapper
+public interface SysSocialDetailsMapper extends BaseMapper<SysSocialDetails> {
+
+}

+ 50 - 0
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysSocialDetailsService.java

@@ -0,0 +1,50 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.admin.service;
+
+import com.baomidou.mybatisplus.service.IService;
+import com.pig4cloud.pigx.admin.api.entity.SysSocialDetails;
+
+import java.util.Map;
+
+/**
+ * 系统社交登录账号表
+ *
+ * @author pigx code generator
+ * @date 2018-08-16 21:30:41
+ */
+public interface SysSocialDetailsService extends IService<SysSocialDetails> {
+
+	/**
+	 * 绑定社交账号
+	 *
+	 * @param state 类型
+	 * @param code  code
+	 * @return
+	 */
+	Boolean bindSocial(String state, String code);
+
+	/**
+	 * 通过客户端信息查询openId
+	 *
+	 * @param inStr appid @ code
+	 * @return
+	 */
+	Map<String, String> findOpenId(String inStr);
+}
+

+ 0 - 9
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysUserService.java

@@ -83,13 +83,4 @@ public interface SysUserService extends IService<SysUser> {
 	 * @return 用户信息
 	 */
 	UserVO selectUserVoById(Integer id);
-
-	/**
-	 * 绑定社交账号
-	 *
-	 * @param state 类型
-	 * @param code  code
-	 * @return
-	 */
-	Boolean bindSocial(String state, String code);
 }

+ 118 - 0
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysSocialDetailsServiceImpl.java

@@ -0,0 +1,118 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.admin.service.impl;
+
+import cn.hutool.json.JSONUtil;
+import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.pig4cloud.pigx.admin.api.entity.SysSocialDetails;
+import com.pig4cloud.pigx.admin.api.entity.SysUser;
+import com.pig4cloud.pigx.admin.mapper.SysSocialDetailsMapper;
+import com.pig4cloud.pigx.admin.mapper.SysUserMapper;
+import com.pig4cloud.pigx.admin.service.SysSocialDetailsService;
+import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
+import com.pig4cloud.pigx.common.core.constant.enums.EnumLoginType;
+import com.pig4cloud.pigx.common.security.util.SecurityUtils;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.cache.CacheManager;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author lengleng
+ * @date 2018年08月16日
+ */
+@Slf4j
+@AllArgsConstructor
+@Service("sysSocialDetailsService")
+public class SysSocialDetailsServiceImpl extends ServiceImpl<SysSocialDetailsMapper, SysSocialDetails> implements SysSocialDetailsService {
+	private final CacheManager cacheManager;
+	private final RestTemplate restTemplate;
+	private final SysUserMapper sysUserMapper;
+
+	/**
+	 * 通过客户端信息查询openId
+	 *
+	 * @param inStr appid @ code
+	 * @return
+	 */
+	@Override
+	public Map<String, String> findOpenId(String inStr) {
+		String[] inStrs = inStr.split("@");
+		return getOpenId(inStrs[0], inStrs[1]);
+	}
+
+	/**
+	 * 绑定社交账号
+	 *
+	 * @param appId appId
+	 * @param code  code
+	 * @return
+	 */
+	@Override
+	public Boolean bindSocial(String appId, String code) {
+		Map<String, String> result = getOpenId(appId, code);
+
+		SysUser condition = new SysUser();
+		condition.setUsername(SecurityUtils.getUser());
+		SysUser sysUser = sysUserMapper.selectOne(condition);
+		sysUser.setWxOpenid(result.get("openId"));
+
+		sysUserMapper.updateAllColumnById(sysUser);
+		//更新緩存
+		cacheManager.getCache("user_details").evict(result.get("openId"));
+		return Boolean.TRUE;
+	}
+
+	/**
+	 * 通过appid 、code 获得openID
+	 *
+	 * @param appId
+	 * @param code
+	 * @return
+	 */
+	private Map<String, String> getOpenId(String appId, String code) {
+		SysSocialDetails condition = new SysSocialDetails();
+		condition.setAppId(appId);
+		SysSocialDetails socialDetails = this.baseMapper.selectOne(condition);
+
+		String openId = null;
+		//微信登录
+		if (EnumLoginType.WECHAT.getType().equals(socialDetails.getType())) {
+			String url = String.format(SecurityConstants.WX_AUTHORIZATION_CODE_URL
+				, socialDetails.getAppId(), socialDetails.getAppSecret(), code);
+			String result = restTemplate.getForObject(url, String.class);
+			log.debug("微信响应报文:{}", result);
+
+			Object obj = JSONUtil.parseObj(result).get("openid");
+			if (obj == null) {
+				return null;
+			}
+			openId = obj.toString();
+		}
+
+		Map<String, String> result = new HashMap<>(2);
+		result.put("type", socialDetails.getType());
+		result.put("openId", openId);
+		return result;
+	}
+
+}

+ 1 - 32
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserServiceImpl.java

@@ -41,6 +41,7 @@ import com.pig4cloud.pigx.admin.service.SysUserService;
 import com.pig4cloud.pigx.common.core.constant.enums.EnumLoginType;
 import com.pig4cloud.pigx.common.core.util.Query;
 import com.pig4cloud.pigx.common.core.util.R;
+import com.pig4cloud.pigx.common.security.social.WxSocialConfig;
 import com.pig4cloud.pigx.common.security.util.SecurityUtils;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -69,12 +70,8 @@ import java.util.Set;
 @AllArgsConstructor
 public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {
 	private static final PasswordEncoder ENCODER = new BCryptPasswordEncoder();
-	private static final String WX_AUTHORIZATION_CODE_URL = "https://api.weixin.qq.com/sns/oauth2/access_token" +
-		"?appid=%s&secret=%s&code=%s&grant_type=authorization_code";
 	private final SysMenuService sysMenuService;
 	private final SysUserMapper sysUserMapper;
-	private final CacheManager cacheManager;
-	private final RestTemplate restTemplate;
 	private final SysRoleService sysRoleService;
 	private final SysUserRoleService sysUserRoleService;
 
@@ -127,34 +124,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
 		return userInfo;
 	}
 
-	/**
-	 * 绑定社交账号
-	 *
-	 * @param state 类型
-	 * @param code  code
-	 * @return
-	 */
-	@Override
-	public Boolean bindSocial(String state, String code) {
-		String result = restTemplate.getForObject(WX_AUTHORIZATION_CODE_URL, String.class);
-		log.debug("微信响应报文:{}", result);
-
-		Object obj = JSONUtil.parseObj(result).get("openid");
-		if (obj == null) {
-			return Boolean.FALSE;
-		}
-
-		SysUser condition = new SysUser();
-		condition.setUsername(SecurityUtils.getUser());
-		SysUser sysUser = this.selectOne(new EntityWrapper<>(condition));
-		sysUser.setWxOpenid(obj.toString());
-		sysUserMapper.updateAllColumnById(sysUser);
-
-		//更新緩存
-		cacheManager.getCache("user_details").evict(sysUser.getUsername());
-		return Boolean.TRUE;
-	}
-
 	@Override
 	public Page selectWithRolePage(Query query) {
 		Object username = query.getCondition().get("username");

+ 37 - 0
pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysSocialDetailsMapper.xml

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~    Copyright (c) 2018-2025, lengleng All rights reserved.
+  ~
+  ~ Redistribution and use in source and binary forms, with or without
+  ~ modification, are permitted provided that the following conditions are met:
+  ~
+  ~ Redistributions of source code must retain the above copyright notice,
+  ~ this list of conditions and the following disclaimer.
+  ~ Redistributions in binary form must reproduce the above copyright
+  ~ notice, this list of conditions and the following disclaimer in the
+  ~ documentation and/or other materials provided with the distribution.
+  ~ Neither the name of the pig4cloud.com developer nor the names of its
+  ~ contributors may be used to endorse or promote products derived from
+  ~ this software without specific prior written permission.
+  ~ Author: lengleng (wangiegie@gmail.com)
+  -->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="com.pig4cloud.pigx.generator.mapper.SysSocialDetailsMappper">
+
+	<!-- 可根据自己的需求,是否要使用 -->
+    <resultMap type="com.pig4cloud.pigx.admin.api.entity.SysSocialDetails" id="sysSocialDetailsMap">
+        <result property="id" column="id"/>
+        <result property="type" column="type"/>
+        <result property="remark" column="remark"/>
+        <result property="appId" column="app_id"/>
+        <result property="appSecret" column="app_secret"/>
+        <result property="redirectUrl" column="redirect_url"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="delFlag" column="del_flag"/>
+    </resultMap>
+
+
+</mapper>

+ 5 - 9
pigx-visual/pigx-codegen/src/main/resources/template/Controller.java.vm

@@ -46,8 +46,7 @@ public class ${className}Controller {
     @GetMapping("/{${pk.lowerAttrName}}")
     public R info(@PathVariable("${pk.lowerAttrName}") ${pk.attrType} ${pk.lowerAttrName}){
 			${className} ${classname} = ${classname}Service.selectById(${pk.lowerAttrName});
-
-			  return new R<>(${classname});
+			return new R<>(${classname});
     }
 
     /**
@@ -55,11 +54,10 @@ public class ${className}Controller {
      * @param ${classname}
      * @return R
      */
-    @PostMapping("/save")
+    @PostMapping
     public R save(@RequestBody ${className} ${classname}){
 			${classname}Service.insert(${classname});
-
-			  return new R<>(Boolean.TRUE);
+			return new R<>(Boolean.TRUE);
     }
 
     /**
@@ -67,10 +65,9 @@ public class ${className}Controller {
      * @param ${classname}
      * @return R
      */
-    @PutMapping("/update")
+    @PutMapping
     public R update(@RequestBody ${className} ${classname}){
 			${classname}Service.updateById(${classname});
-
       return new R<>(Boolean.TRUE);
     }
 
@@ -79,10 +76,9 @@ public class ${className}Controller {
      * @param ${pk.lowerAttrName}s
      * @return R
      */
-    @DeleteMapping("/delete")
+    @DeleteMapping
     public R delete(@RequestBody ${pk.attrType}[] ${pk.lowerAttrName}s){
 			${classname}Service.deleteBatchIds(Arrays.asList(${pk.lowerAttrName}s));
-
       return new R<>(Boolean.TRUE);
     }
 

+ 10 - 10
pigx-visual/pigx-codegen/src/main/resources/template/crud.js.vm

@@ -16,16 +16,16 @@
  */
 
 export const tableOption = {
-  "border": true,
-  "index": true,
-  "stripe": true,
-  "menuAlign": "center",
-  "align": "center",
-  "editBtn": false,
-  "delBtn": false,
-  "addBtn": false,
-  "dic": [],
-  "column": [
+  'border': true,
+  'index': true,
+  'stripe': true,
+  'menuAlign': "center",
+  'align': "center",
+  'editBtn': false,
+  'delBtn': false,
+  'addBtn': false,
+  'dic': [],
+  'column': [
 #foreach ($column in $columns)
 	  {
       label: '$column.comments',

+ 9 - 6
pigx-visual/pigx-codegen/src/main/resources/template/index.vue.vm

@@ -70,6 +70,10 @@
           currentPage: 1, // 当前页数
           pageSize: 20 // 每页显示多少条
         },
+        listQuery: {
+          page: 1,
+          limit: 20
+        },
         tableLoading: false,
         tableOption: tableOption
       }
@@ -84,21 +88,20 @@
   methods: {
     getList() {
       this.tableLoading = true
-      fetchList({
-        page: this.page.currentPage,
-        limit: this.page.pageSize
-      }).then(response => {
+      fetchList(this.listQuery).then(response => {
         this.tableData = response.data.records
-      this.page.total = response.data.total
-      this.tableLoading = false
+        this.page.total = response.data.total
+        this.tableLoading = false
     })
     },
     currentChange(val) {
       this.page.currentPage = val
+      this.listQuery.page = val
       this.getList()
     },
     sizeChange(val) {
       this.page.pageSize = val
+      this.listQuery.limit = val
       this.getList()
     },
     /**