Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
wangjiahao 2022-12-06 17:22:04 +08:00
commit 5fc59d7801
4 changed files with 117 additions and 9 deletions

View File

@ -107,6 +107,7 @@ public class ShiroServiceImpl implements ShiroService {
filterChainDefinitionMap.put("/plugin/lark/callBack*", ANON);
filterChainDefinitionMap.put("/plugin/lark/bind*", ANON);
filterChainDefinitionMap.put("/plugin/lark/getQrParam", ANON);
filterChainDefinitionMap.put("/plugin/lark/appId", ANON);
filterChainDefinitionMap.put("/plugin/larksuite/callBack*", ANON);
filterChainDefinitionMap.put("/plugin/larksuite/bind*", ANON);
filterChainDefinitionMap.put("/plugin/larksuite/getQrParam", ANON);

View File

@ -6,6 +6,7 @@ import io.dataease.auth.service.AuthUserService;
import io.dataease.auth.util.JWTUtils;
import io.dataease.commons.constants.SysLogConstants;
import io.dataease.commons.exception.DEException;
import io.dataease.commons.utils.BeanUtils;
import io.dataease.commons.utils.DeLogUtils;
import io.dataease.commons.utils.LogUtil;
import io.dataease.commons.utils.ServletUtils;
@ -15,8 +16,10 @@ import io.dataease.plugins.common.base.domain.SysUserAssist;
import io.dataease.plugins.config.SpringContextUtil;
import io.dataease.plugins.xpack.display.dto.response.SysSettingDto;
import io.dataease.plugins.xpack.lark.dto.entity.LarkAppUserEntity;
import io.dataease.plugins.xpack.lark.dto.entity.LarkQrResult;
import io.dataease.plugins.xpack.lark.dto.entity.LarkUserInfo;
import io.dataease.plugins.xpack.lark.dto.response.LarkAppUserResult;
import io.dataease.plugins.xpack.lark.dto.response.LarkInfo;
import io.dataease.plugins.xpack.lark.service.LarkXpackService;
import io.dataease.service.sys.SysUserService;
@ -48,6 +51,13 @@ public class XLarkServer {
@Resource
private SysUserService sysUserService;
@ResponseBody
@GetMapping("/appId")
public String getAppId() {
LarkXpackService larkXpackService = SpringContextUtil.getBean(LarkXpackService.class);
return larkXpackService.appId();
}
@ResponseBody
@GetMapping("/info")
public LarkInfo getLarkInfo() {
@ -81,8 +91,12 @@ public class XLarkServer {
return larkXpackService.getQrParam();
}
@GetMapping("/callBack")
public ModelAndView callBack(@RequestParam("code") String code, @RequestParam("state") String state) {
@GetMapping("/callBackWithoutLogin")
public ModelAndView callBackWithoutLogin(@RequestParam("code") String code) {
return privateCallBack(code, null, true);
}
private ModelAndView privateCallBack(String code, String state, Boolean withoutLogin) {
ModelAndView modelAndView = new ModelAndView("redirect:/");
HttpServletResponse response = ServletUtils.response();
LarkXpackService larkXpackService = null;
@ -96,7 +110,14 @@ public class XLarkServer {
if (!isOpen) {
DEException.throwException("未开启飞书");
}
LarkUserInfo larkUserInfo = larkXpackService.userInfo(code, state, false);
LarkUserInfo larkUserInfo = null;
if (withoutLogin) {
LarkAppUserResult larkAppUserResult = larkXpackService.userInfoWithoutLogin(code);
LarkAppUserEntity userResultData = larkAppUserResult.getData();
larkUserInfo = BeanUtils.copyBean(new LarkUserInfo(), userResultData);
} else {
larkUserInfo = larkXpackService.userInfo(code, state, false);
}
String username = larkUserInfo.getUser_id();
SysUserEntity sysUserEntity = authUserService.getUserByLarkId(username);
if (null == sysUserEntity) {
@ -140,6 +161,11 @@ public class XLarkServer {
return modelAndView;
}
@GetMapping("/callBack")
public ModelAndView callBack(@RequestParam("code") String code, @RequestParam("state") String state) {
return privateCallBack(code, state, false);
}
private void bindError(HttpServletResponse response, String url, String errorMsg) {
Cookie cookie_error = new Cookie("LarkError", errorMsg);
cookie_error.setPath("/");

View File

@ -130,6 +130,13 @@ export function larkStatus() {
})
}
export function larkAppId() {
return request({
url: '/plugin/lark/appId',
method: 'get'
})
}
export function larksuiteStatus() {
return request({
url: '/api/auth/isOpenLarksuite',

View File

@ -4,45 +4,98 @@
class="de-auto-login"
>
<plugin-com
v-if="dingtalkOpen && corpId"
v-if="isDingTalkLink && dingtalkOpen && corpId"
ref="DTWithoutLogin"
:corp-id="corpId"
component-name="DTWithoutLogin"
/>
<plugin-com
v-else-if="isLarkLink && larkOpen && appId"
ref="LKWithoutLogin"
:app-id="appId"
component-name="LKWithoutLogin"
/>
<plugin-com
v-else-if="isLarksuiteLink && larksuiteOpen"
ref="LKSWithoutLogin"
component-name="LKSWithoutLogin"
/>
<div
v-if="!loading && !dingtalkOpen"
v-if="isDingTalkLink && !loading && !dingtalkOpen"
class="auto-login-missing"
>
<span>未开启钉钉</span>
</div>
<div
v-else-if="!loading && !corpId"
v-else-if="isDingTalkLink && !loading && !corpId"
class="auto-login-missing"
>
<span>缺失企业ID参数</span>
</div>
<div
v-if="isLarkLink && !loading && !larkOpen"
class="auto-login-missing"
>
<span>未开启飞书</span>
</div>
<div
v-else-if="isLarkLink && !loading && !appId"
class="auto-login-missing"
>
<span>缺失应用ID参数</span>
</div>
<div
v-if="isLarksuiteLink && !loading && !larksuiteOpen"
class="auto-login-missing"
>
<span>未开启国际飞书</span>
</div>
</div>
</template>
<script>
import PluginCom from '@/views/system/plugin/PluginCom'
import { dingtalkStatus } from '@/api/user'
import { dingtalkStatus, larkStatus, larksuiteStatus, larkAppId } from '@/api/user'
export default {
name: 'DeAutoLogin',
components: { PluginCom },
data() {
return {
type: 'dingtalk',
corpId: null,
appId: null,
dingtalkOpen: false,
larkOpen: false,
larksuiteOpen: false,
loading: true
}
},
computed: {
isDingTalkLink() {
return this.type === 'dingtalk' || !this.type
},
isLarkLink() {
return this.type === 'lark'
},
isLarksuiteLink() {
return this.type === 'larksuite'
}
},
created() {
this.corpId = this.$route.query.corpId
dingtalkStatus().then(res => {
if (this.$route.query.type) {
this.type = this.$route.query.type
}
this.isDingTalkLink && dingtalkStatus().then(res => {
if (res.success && res.data) {
this.dingtalkOpen = true
}
@ -50,6 +103,27 @@ export default {
}).catch(e => {
this.loading = false
})
this.isLarkLink && larkStatus().then(res => {
if (res.success && res.data) {
larkAppId().then(resp => {
this.appId = resp.data
this.larkOpen = true
this.loading = false
})
}
}).catch(e => {
this.loading = false
})
this.isLarksuiteLink && larksuiteStatus().then(res => {
if (res.success && res.data) {
this.larksuiteOpen = true
}
this.loading = false
}).catch(e => {
this.loading = false
})
},
methods: {