forked from github/dataease
feat(飞书): 工作台免登进入DataEase
This commit is contained in:
parent
826a7d57de
commit
62242d67cc
@ -107,6 +107,7 @@ public class ShiroServiceImpl implements ShiroService {
|
|||||||
filterChainDefinitionMap.put("/plugin/lark/callBack*", ANON);
|
filterChainDefinitionMap.put("/plugin/lark/callBack*", ANON);
|
||||||
filterChainDefinitionMap.put("/plugin/lark/bind*", ANON);
|
filterChainDefinitionMap.put("/plugin/lark/bind*", ANON);
|
||||||
filterChainDefinitionMap.put("/plugin/lark/getQrParam", ANON);
|
filterChainDefinitionMap.put("/plugin/lark/getQrParam", ANON);
|
||||||
|
filterChainDefinitionMap.put("/plugin/lark/appId", ANON);
|
||||||
filterChainDefinitionMap.put("/plugin/larksuite/callBack*", ANON);
|
filterChainDefinitionMap.put("/plugin/larksuite/callBack*", ANON);
|
||||||
filterChainDefinitionMap.put("/plugin/larksuite/bind*", ANON);
|
filterChainDefinitionMap.put("/plugin/larksuite/bind*", ANON);
|
||||||
filterChainDefinitionMap.put("/plugin/larksuite/getQrParam", ANON);
|
filterChainDefinitionMap.put("/plugin/larksuite/getQrParam", ANON);
|
||||||
|
@ -6,6 +6,7 @@ import io.dataease.auth.service.AuthUserService;
|
|||||||
import io.dataease.auth.util.JWTUtils;
|
import io.dataease.auth.util.JWTUtils;
|
||||||
import io.dataease.commons.constants.SysLogConstants;
|
import io.dataease.commons.constants.SysLogConstants;
|
||||||
import io.dataease.commons.exception.DEException;
|
import io.dataease.commons.exception.DEException;
|
||||||
|
import io.dataease.commons.utils.BeanUtils;
|
||||||
import io.dataease.commons.utils.DeLogUtils;
|
import io.dataease.commons.utils.DeLogUtils;
|
||||||
import io.dataease.commons.utils.LogUtil;
|
import io.dataease.commons.utils.LogUtil;
|
||||||
import io.dataease.commons.utils.ServletUtils;
|
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.config.SpringContextUtil;
|
||||||
|
|
||||||
import io.dataease.plugins.xpack.display.dto.response.SysSettingDto;
|
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.LarkQrResult;
|
||||||
import io.dataease.plugins.xpack.lark.dto.entity.LarkUserInfo;
|
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.dto.response.LarkInfo;
|
||||||
import io.dataease.plugins.xpack.lark.service.LarkXpackService;
|
import io.dataease.plugins.xpack.lark.service.LarkXpackService;
|
||||||
import io.dataease.service.sys.SysUserService;
|
import io.dataease.service.sys.SysUserService;
|
||||||
@ -48,6 +51,13 @@ public class XLarkServer {
|
|||||||
@Resource
|
@Resource
|
||||||
private SysUserService sysUserService;
|
private SysUserService sysUserService;
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@GetMapping("/appId")
|
||||||
|
public String getAppId() {
|
||||||
|
LarkXpackService larkXpackService = SpringContextUtil.getBean(LarkXpackService.class);
|
||||||
|
return larkXpackService.appId();
|
||||||
|
}
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@GetMapping("/info")
|
@GetMapping("/info")
|
||||||
public LarkInfo getLarkInfo() {
|
public LarkInfo getLarkInfo() {
|
||||||
@ -81,8 +91,12 @@ public class XLarkServer {
|
|||||||
return larkXpackService.getQrParam();
|
return larkXpackService.getQrParam();
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/callBack")
|
@GetMapping("/callBackWithoutLogin")
|
||||||
public ModelAndView callBack(@RequestParam("code") String code, @RequestParam("state") String state) {
|
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:/");
|
ModelAndView modelAndView = new ModelAndView("redirect:/");
|
||||||
HttpServletResponse response = ServletUtils.response();
|
HttpServletResponse response = ServletUtils.response();
|
||||||
LarkXpackService larkXpackService = null;
|
LarkXpackService larkXpackService = null;
|
||||||
@ -96,7 +110,14 @@ public class XLarkServer {
|
|||||||
if (!isOpen) {
|
if (!isOpen) {
|
||||||
DEException.throwException("未开启飞书");
|
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();
|
String username = larkUserInfo.getUser_id();
|
||||||
SysUserEntity sysUserEntity = authUserService.getUserByLarkId(username);
|
SysUserEntity sysUserEntity = authUserService.getUserByLarkId(username);
|
||||||
if (null == sysUserEntity) {
|
if (null == sysUserEntity) {
|
||||||
@ -140,6 +161,11 @@ public class XLarkServer {
|
|||||||
return modelAndView;
|
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) {
|
private void bindError(HttpServletResponse response, String url, String errorMsg) {
|
||||||
Cookie cookie_error = new Cookie("LarkError", errorMsg);
|
Cookie cookie_error = new Cookie("LarkError", errorMsg);
|
||||||
cookie_error.setPath("/");
|
cookie_error.setPath("/");
|
||||||
|
@ -130,6 +130,13 @@ export function larkStatus() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function larkAppId() {
|
||||||
|
return request({
|
||||||
|
url: '/plugin/lark/appId',
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export function larksuiteStatus() {
|
export function larksuiteStatus() {
|
||||||
return request({
|
return request({
|
||||||
url: '/api/auth/isOpenLarksuite',
|
url: '/api/auth/isOpenLarksuite',
|
||||||
|
@ -4,45 +4,98 @@
|
|||||||
class="de-auto-login"
|
class="de-auto-login"
|
||||||
>
|
>
|
||||||
<plugin-com
|
<plugin-com
|
||||||
v-if="dingtalkOpen && corpId"
|
v-if="isDingTalkLink && dingtalkOpen && corpId"
|
||||||
ref="DTWithoutLogin"
|
ref="DTWithoutLogin"
|
||||||
:corp-id="corpId"
|
:corp-id="corpId"
|
||||||
component-name="DTWithoutLogin"
|
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
|
<div
|
||||||
v-if="!loading && !dingtalkOpen"
|
v-if="isDingTalkLink && !loading && !dingtalkOpen"
|
||||||
class="auto-login-missing"
|
class="auto-login-missing"
|
||||||
>
|
>
|
||||||
<span>未开启钉钉</span>
|
<span>未开启钉钉</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
v-else-if="!loading && !corpId"
|
v-else-if="isDingTalkLink && !loading && !corpId"
|
||||||
class="auto-login-missing"
|
class="auto-login-missing"
|
||||||
>
|
>
|
||||||
<span>缺失企业ID参数</span>
|
<span>缺失企业ID参数</span>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import PluginCom from '@/views/system/plugin/PluginCom'
|
import PluginCom from '@/views/system/plugin/PluginCom'
|
||||||
import { dingtalkStatus } from '@/api/user'
|
import { dingtalkStatus, larkStatus, larksuiteStatus, larkAppId } from '@/api/user'
|
||||||
export default {
|
export default {
|
||||||
name: 'DeAutoLogin',
|
name: 'DeAutoLogin',
|
||||||
components: { PluginCom },
|
components: { PluginCom },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
type: 'dingtalk',
|
||||||
corpId: null,
|
corpId: null,
|
||||||
|
appId: null,
|
||||||
dingtalkOpen: false,
|
dingtalkOpen: false,
|
||||||
|
larkOpen: false,
|
||||||
|
larksuiteOpen: false,
|
||||||
loading: true
|
loading: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
isDingTalkLink() {
|
||||||
|
return this.type === 'dingtalk' || !this.type
|
||||||
|
},
|
||||||
|
isLarkLink() {
|
||||||
|
return this.type === 'lark'
|
||||||
|
},
|
||||||
|
isLarksuiteLink() {
|
||||||
|
return this.type === 'larksuite'
|
||||||
|
}
|
||||||
|
},
|
||||||
created() {
|
created() {
|
||||||
this.corpId = this.$route.query.corpId
|
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) {
|
if (res.success && res.data) {
|
||||||
this.dingtalkOpen = true
|
this.dingtalkOpen = true
|
||||||
}
|
}
|
||||||
@ -50,6 +103,27 @@ export default {
|
|||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
this.loading = false
|
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: {
|
methods: {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user