e84823c81f345e7b43e4e100b479edbc79ed58a4.svn-base 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package org.jeecg.config.thirdapp;
  2. import org.springframework.beans.factory.annotation.Autowired;
  3. import org.springframework.beans.factory.annotation.Value;
  4. import org.springframework.context.annotation.Configuration;
  5. /**
  6. * 第三方App对接配置
  7. */
  8. @Configuration
  9. public class ThirdAppConfig {
  10. /**
  11. * 钉钉
  12. */
  13. public final static String DINGTALK = "DINGTALK";
  14. /**
  15. * 企业微信
  16. */
  17. public final static String WECHAT_ENTERPRISE = "WECHAT_ENTERPRISE";
  18. /**
  19. * 是否启用 第三方App对接
  20. */
  21. @Value("${third-app.enabled:false}")
  22. private boolean enabled;
  23. /**
  24. * 系统类型,目前支持:WECHAT_ENTERPRISE(企业微信);DINGTALK (钉钉)
  25. */
  26. @Autowired
  27. private ThirdAppTypeConfig type;
  28. public boolean isEnabled() {
  29. return enabled;
  30. }
  31. public ThirdAppConfig setEnabled(boolean enabled) {
  32. this.enabled = enabled;
  33. return this;
  34. }
  35. /**
  36. * 获取企业微信配置
  37. */
  38. public ThirdAppTypeItemVo getWechatEnterprise() {
  39. return this.type.getWECHAT_ENTERPRISE();
  40. }
  41. /**
  42. * 获取钉钉配置
  43. */
  44. public ThirdAppTypeItemVo getDingtalk() {
  45. return this.type.getDINGTALK();
  46. }
  47. /**
  48. * 获取企业微信是否启用
  49. */
  50. public boolean isWechatEnterpriseEnabled() {
  51. try {
  52. return this.enabled && this.getWechatEnterprise().isEnabled();
  53. } catch (Exception e) {
  54. return false;
  55. }
  56. }
  57. /**
  58. * 获取钉钉是否启用
  59. */
  60. public boolean isDingtalkEnabled() {
  61. try {
  62. return this.enabled && this.getDingtalk().isEnabled();
  63. } catch (Exception e) {
  64. return false;
  65. }
  66. }
  67. }