소스 검색

add:admin 企微配置

ct 1 주 전
부모
커밋
d446c03e34

+ 162 - 0
fs-admin/src/main/java/com/fs/qw/controller/QwCompanyController.java

@@ -0,0 +1,162 @@
+package com.fs.qw.controller;
+
+import java.util.List;
+
+import cn.hutool.json.JSONUtil;
+import com.fs.common.core.domain.R;
+import com.fs.common.core.domain.model.LoginUser;
+import com.fs.common.utils.ServletUtils;
+import com.fs.course.config.CourseConfig;
+import com.fs.framework.web.service.TokenService;
+import com.fs.qw.param.QwCompanyTenantSetParam;
+import com.fs.qw.vo.QwOptionsVO;
+import com.fs.system.service.ISysConfigService;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.fs.common.annotation.Log;
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.AjaxResult;
+import com.fs.common.enums.BusinessType;
+import com.fs.qw.domain.QwCompany;
+import com.fs.qw.service.IQwCompanyService;
+import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.common.core.page.TableDataInfo;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * 企微主体Controller
+ *
+ * @author fs
+ * @date 2024-10-09
+ */
+@RestController
+@RequestMapping("/qw/qwCompany")
+public class QwCompanyController extends BaseController
+{
+    @Autowired
+    private IQwCompanyService qwCompanyService;
+    @Autowired
+    private TokenService tokenService;
+    @Autowired
+    private ISysConfigService configService;
+
+    /**
+     * 查询企微主体列表
+     */
+    @PreAuthorize("@ss.hasPermi('qw:qwCompany:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(QwCompany qwCompany)
+    {
+
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        String json = configService.selectConfigByKey("course.config");
+        CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
+        if(!loginUser.isAdmin() && config.getDept() != null && config.getDept()){
+            qwCompany.setCreateDeptId(loginUser.getDeptId());
+            qwCompany.setCreateUserId(loginUser.getUserId());
+        }
+        startPage();
+        List<QwCompany> list = qwCompanyService.selectQwCompanyList(qwCompany);
+        return getDataTable(list);
+    }
+
+
+    @GetMapping("/all")
+    public R all()
+    {
+        Long userId = null;
+        Long deptId = null;
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        String json = configService.selectConfigByKey("course.config");
+        CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
+        if(!loginUser.isAdmin() && config.getDept() != null && config.getDept()){
+            deptId = loginUser.getDeptId();
+            if(config.getDept() == null || !config.getDept()){
+                userId = loginUser.getUserId();
+            }
+        }
+        List<QwOptionsVO> list = qwCompanyService.selectQwCompanyListOptionsVO(userId, deptId);
+        return R.ok().put("data", list);
+    }
+    /**
+     * 导出企微主体列表
+     */
+    @PreAuthorize("@ss.hasPermi('qw:qwCompany:export')")
+    @Log(title = "企微主体", businessType = BusinessType.EXPORT, isStoreLog = true)
+    @GetMapping("/export")
+    public AjaxResult export(QwCompany qwCompany)
+    {
+        List<QwCompany> list = qwCompanyService.selectQwCompanyList(qwCompany);
+        ExcelUtil<QwCompany> util = new ExcelUtil<QwCompany>(QwCompany.class);
+        return util.exportExcel(list, "企微主体数据");
+    }
+
+    /**
+     * 获取企微主体详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('qw:qwCompany:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return AjaxResult.success(qwCompanyService.selectQwCompanyById(id));
+    }
+
+    /**
+     * 新增企微主体
+     */
+    @PreAuthorize("@ss.hasPermi('qw:qwCompany:add')")
+    @Log(title = "企微主体", businessType = BusinessType.INSERT, isStoreLog = true)
+    @PostMapping
+    public AjaxResult add(@RequestBody QwCompany qwCompany)
+    {
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+
+        qwCompany.setCreateUserId(loginUser.getUserId());
+        qwCompany.setCreateDeptId(loginUser.getDeptId());
+        return toAjax(qwCompanyService.insertQwCompany(qwCompany));
+    }
+
+    /**
+     * 修改企微主体
+     */
+    @PreAuthorize("@ss.hasPermi('qw:qwCompany:edit')")
+    @Log(title = "企微主体", businessType = BusinessType.UPDATE, isStoreLog = true)
+    @PutMapping
+    public AjaxResult edit(@RequestBody QwCompany qwCompany)
+    {
+        return toAjax(qwCompanyService.updateQwCompany(qwCompany));
+    }
+
+    /**
+     * 删除企微主体
+     */
+    @PreAuthorize("@ss.hasPermi('qw:qwCompany:remove')")
+    @Log(title = "企微主体", businessType = BusinessType.DELETE, isStoreLog = true)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids, HttpServletRequest request)
+    {
+        String tenantCode = request.getHeader("Tenant-Code");
+
+        return toAjax(qwCompanyService.deleteQwCompanyByIds(ids,tenantCode));
+    }
+
+    /**
+     * 租户配置
+     */
+    @PreAuthorize("@ss.hasPermi('qw:qwCompany:tenant')")
+    @Log(title = "企微主体租户配置", businessType = BusinessType.UPDATE, isStoreLog = true)
+    @PostMapping("/setTenant")
+    public R setTenant(@RequestBody QwCompanyTenantSetParam param)
+    {
+        return qwCompanyService.setTenant(param);
+    }
+}

+ 5 - 4
fs-qw-api/src/main/java/com/fs/app/service/QwDataCallbackService.java

@@ -120,11 +120,12 @@ public class QwDataCallbackService {
     /**
      * 代开发模板默认 suite_id(回调 XML 里通常也会带 &lt;SuiteId&gt;,优先用 XML)
      */
-    private static final String DEFAULT_SUITE_ID = "dk348a71ab9e97e43a";
+//    private static final String DEFAULT_SUITE_ID = "dk348a71ab9e97e43a";
+    private static final String DEFAULT_SUITE_ID = "dk82e30f72958ce334";
     /**
      * 代开发模板 suite_secret(与服务商后台一致)
      */
-    private static final String DEFAULT_SUITE_SECRET = "bUdYYGwWPSz4Kg11O5qQfrsIFwlGRh4W-JsJrlVy3A0";
+    private static final String DEFAULT_SUITE_SECRET = "P34chciO0LJ_YcJt5LTOegjxoHz2dUjSHRNzBAqejuQ";
 
     /**
      * 使用临时授权码 auth_code 调用 get_permanent_code,回写当前 qw_company 的 permanent_code。
@@ -1082,7 +1083,7 @@ public class QwDataCallbackService {
                 String SuiteId =root.getElementsByTagName("SuiteId").item(0).getTextContent();
 
                 switch (SuiteId) {
-                    case "dk348a71ab9e97e43a":
+                    case "dk82e30f72958ce334":
                         //代开发应用模板信息
                         redisCache.setCacheObject("qw_suite_ticket:" + qwCorpID,SuiteTicket);
                         break;
@@ -1116,7 +1117,7 @@ public class QwDataCallbackService {
                 QwSuiteTokenParams qwSuiteTokenParams=new QwSuiteTokenParams();
 
                 switch (SuiteId) {
-                    case "dk348a71ab9e97e43a":
+                    case "dk82e30f72958ce334":
                         //代开发应用模板信息
                         NodeList suiteIdNodes = root.getElementsByTagName("SuiteId");
                         String suiteIdXml = suiteIdNodes.getLength() > 0 ? suiteIdNodes.item(0).getTextContent() : null;