浏览代码

Merge remote-tracking branch 'origin/master'

yumeng 3 年之前
父节点
当前提交
0ceb91bf5b

+ 2 - 2
jeecg-boot-module-system/pom.xml

@@ -69,7 +69,7 @@
 			<artifactId>opencv</artifactId>
 			<version>4.2.0</version>
 			<scope>system</scope>
-			<systemPath>${project.basedir}/src/main/resources/lib/opencv-4.2.0.jar</systemPath>
+			<systemPath>${basedir}/../lib/opencv-4.2.0.jar</systemPath>
 		</dependency>
 		<!-- commons -->
 		<dependency>
@@ -99,7 +99,7 @@
 			<artifactId>jave</artifactId>
 			<version>1.0</version>
 			<scope>system</scope>
-			<systemPath>${project.basedir}/src/main/resources/lib/jave-1.0.jar</systemPath>
+			<systemPath>${project.basedir}/../lib/jave-1.0.jar</systemPath>
 		</dependency>
 
 		<dependency>

+ 2 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java

@@ -19,6 +19,7 @@ import com.github.pagehelper.PageInfo;
 import com.tencentcloudapi.mps.v20190612.models.DescribeTaskDetailResponse;
 import it.sauronsoftware.jave.Encoder;
 import it.sauronsoftware.jave.EncoderException;
+import it.sauronsoftware.jave.MultimediaInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.system.vo.LoginUser;
@@ -399,7 +400,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
                     String url = materialInfo.getUrl();
                     log.info("replaceUrl:{}", url);
                     String localUrl = null;
-                    it.sauronsoftware.jave.MultimediaInfo m = null;
+                    MultimediaInfo m = null;
                     FileInputStream fis = null;
                     try {
                         localUrl = LoadFileUtil.downLoadFromUrl(url, downloadUrl);

+ 81 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/LoginController.java

@@ -1,13 +1,23 @@
 package org.jeecg.modules.system.controller;
 
-import cn.com.ctop.common.module.service.ISysDepartService;
-import cn.com.ctop.common.module.service.ISysDictService;
-import cn.com.ctop.common.module.service.ISysUserService;
+import cn.com.ctop.common.module.entity.CtopCorpWexinUser;
+import cn.com.ctop.common.module.entity.WexinConfig;
+import cn.com.ctop.common.module.service.*;
+import cn.com.ctop.common.module.utils.Check;
 import cn.hutool.core.util.RandomUtil;
 import com.alibaba.fastjson.JSONObject;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import lombok.val;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.cp.api.WxCpOAuth2Service;
+import me.chanjar.weixin.cp.api.WxCpUserService;
+import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
+import me.chanjar.weixin.cp.api.impl.WxCpUserServiceImpl;
+import me.chanjar.weixin.cp.bean.WxCpOauth2UserInfo;
+import me.chanjar.weixin.cp.bean.WxCpUser;
+import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.constant.CacheConstant;
@@ -91,6 +101,74 @@ public class LoginController {
 		sysBaseApi.addLog("用户名: " + username + ",登录成功!", CommonConstant.LOG_TYPE_1, null);
 		return result;
 	}
+
+	@Autowired
+	private ICtopCorpWexinUserService ctopCorpWexinUserService;
+	@Autowired
+	private IWexinConfigService wexinConfigService;
+
+	@RequestMapping(value = "/wxlogin", method = RequestMethod.POST)
+	@ApiOperation("企业微信登录接口")
+	public Result<JSONObject> wxlogin(@RequestParam(name = "code") String code, @RequestParam(name = "corpId") String corpId) throws Exception {
+		Result<JSONObject> result = new Result<>();
+		WexinConfig wexinConfig = wexinConfigService.getInfoByCorpId(corpId);
+		if (Check.isNull(wexinConfig)) {
+			result.error500("未找到用户配置,请联系管理员");
+			return result;
+		}
+		val configStorage = new WxCpDefaultConfigImpl();
+		configStorage.setCorpId(wexinConfig.getCorpId());
+		configStorage.setAgentId(wexinConfig.getAgentId());
+		configStorage.setCorpSecret(wexinConfig.getCorpSecret());
+		configStorage.setToken(wexinConfig.getToken());
+		configStorage.setAesKey(wexinConfig.getAesKey());
+		val service = new WxCpServiceImpl();
+		service.setWxCpConfigStorage(configStorage);
+		WxCpOAuth2Service wxCpOAuth2Service = service.getOauth2Service();
+		try {
+			WxCpOauth2UserInfo userInfo = wxCpOAuth2Service.getUserInfo(1000002, code);
+			if (userInfo != null && userInfo.getUserId() != null) {
+				WxCpUserService wxCpUserService = new WxCpUserServiceImpl(service);
+				WxCpUser user = wxCpUserService.getById(userInfo.getUserId());
+				String email = user.getEmail();
+				SysUser sysUser = sysUserService.getUserByEmail(email);
+				if (sysUser == null) {
+					result.error500("该用户未注册系统账户,请联系管理员");
+					return result;
+				}
+				if (sysUser.getStatus() != 1) {
+					result.error500("该用户已冻结,请联系管理员");
+					return result;
+				}
+				String departId = sysDepartService.selectIdByOrdCode(sysUser.getOrgCode());
+				sysUser.setDepartId(departId);
+				result = sysUserService.checkUserIsEffective(sysUser);
+				if (!result.isSuccess()) {
+					return result;
+				}
+				//用户登录信息
+				userInfo(sysUser, result);
+				sysBaseApi.addLog("用户名: " + email + ",登录成功!", CommonConstant.LOG_TYPE_1, null);
+				CtopCorpWexinUser ctopCorpWexinUser = ctopCorpWexinUserService.getById(sysUser.getId());
+				if (ctopCorpWexinUser == null) {
+					ctopCorpWexinUser = new CtopCorpWexinUser();
+					ctopCorpWexinUser.setCorpId(corpId);
+					ctopCorpWexinUser.setUserId(sysUser.getId());
+					ctopCorpWexinUser.setWexinEmail(user.getEmail());
+					ctopCorpWexinUser.setWexinGender(user.getGender().getGenderName());
+					ctopCorpWexinUser.setWexinName(user.getName());
+					ctopCorpWexinUser.setWexinId(user.getUserId());
+					ctopCorpWexinUser.setWexinMobile(user.getMobile());
+					ctopCorpWexinUserService.save(ctopCorpWexinUser);
+				}
+				return result;
+			}
+		} catch (WxErrorException e) {
+			result.error500("企业微信授权错误");
+			e.printStackTrace();
+		}
+		return result;
+	}
 	
 	/**
 	 * 退出登录

+ 10 - 0
jeecg-cloud-module/jeecg-cloud-system-start/pom.xml

@@ -59,6 +59,13 @@
     <build>
         <resources>
             <resource>
+                <directory>../../lib</directory>
+                <targetPath>BOOT-INF/lib/</targetPath>
+                <includes>
+                    <include>**/*.jar</include>
+                </includes>
+            </resource>
+            <resource>
                 <directory>src/main/resources</directory>
                 <!--先排除所有的配置文件-->
                 <excludes>
@@ -79,6 +86,9 @@
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <includeSystemScope>true</includeSystemScope>
+                </configuration>
             </plugin>
         </plugins>
     </build>

jeecg-boot-module-system/src/main/resources/lib/jave-1.0.jar → lib/jave-1.0.jar


jeecg-boot-module-system/src/main/resources/lib/opencv-4.2.0.jar → lib/opencv-4.2.0.jar