|
|
@@ -0,0 +1,113 @@
|
|
|
+package com.fs.course.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.fs.common.annotation.Log;
|
|
|
+import com.fs.common.core.controller.BaseController;
|
|
|
+import com.fs.common.core.domain.AjaxResult;
|
|
|
+import com.fs.common.core.page.TableDataInfo;
|
|
|
+import com.fs.common.enums.BusinessType;
|
|
|
+import com.fs.common.utils.bean.BeanUtils;
|
|
|
+import com.fs.feishu.domain.FsFeishuConfig;
|
|
|
+import com.fs.feishu.param.FsFeishuConfigCreateParam;
|
|
|
+import com.fs.feishu.param.FsFeishuConfigEditParam;
|
|
|
+import com.fs.feishu.service.IFsFeishuConfigService;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.util.*;
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 飞书应用配置
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/course/feishuConfig")
|
|
|
+@AllArgsConstructor
|
|
|
+public class FsFeishuConfigController extends BaseController {
|
|
|
+
|
|
|
+ private final IFsFeishuConfigService fsFeishuConfigService;
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('course:feishuConfig:list')")
|
|
|
+ @GetMapping("/list")
|
|
|
+ public TableDataInfo list(@RequestParam(required = false) String name,
|
|
|
+ @RequestParam(required = false) String appId,
|
|
|
+ @RequestParam(required = false) Integer status,
|
|
|
+ @RequestParam(required = false, defaultValue = "1") Integer pageNum,
|
|
|
+ @RequestParam(required = false, defaultValue = "10") Integer pageSize) {
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("name", name);
|
|
|
+ params.put("appId", appId);
|
|
|
+ params.put("status", status);
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
+ List<FsFeishuConfig> list = fsFeishuConfigService.selectListByMap(params);
|
|
|
+ return getDataTable(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('course:feishuConfig:query')")
|
|
|
+ @GetMapping("/{id}")
|
|
|
+ public AjaxResult getInfo(@PathVariable Long id) {
|
|
|
+ return AjaxResult.success(fsFeishuConfigService.getById(id));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('course:feishuConfig:add')")
|
|
|
+ @Log(title = "飞书配置", businessType = BusinessType.INSERT)
|
|
|
+ @PostMapping
|
|
|
+ public AjaxResult add(@Valid @RequestBody FsFeishuConfigCreateParam param) {
|
|
|
+ FsFeishuConfig exist = fsFeishuConfigService.getOne(
|
|
|
+ Wrappers.<FsFeishuConfig>lambdaQuery()
|
|
|
+ .eq(FsFeishuConfig::getAppId, param.getAppId())
|
|
|
+ .eq(FsFeishuConfig::getIsDel, 0)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (exist != null) {
|
|
|
+ return AjaxResult.error("appId已存在");
|
|
|
+ }
|
|
|
+ FsFeishuConfig config = new FsFeishuConfig();
|
|
|
+ BeanUtils.copyProperties(param, config);
|
|
|
+ config.setIsDel(0);
|
|
|
+ config.setCreateTime(new Date());
|
|
|
+ config.setUpdateTime(new Date());
|
|
|
+ fsFeishuConfigService.save(config);
|
|
|
+ fsFeishuConfigService.refreshNormalConfigCache();
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('course:feishuConfig:edit')")
|
|
|
+ @Log(title = "飞书配置", businessType = BusinessType.UPDATE)
|
|
|
+ @PutMapping
|
|
|
+ public AjaxResult edit(@Valid @RequestBody FsFeishuConfigEditParam param) {
|
|
|
+ FsFeishuConfig config = fsFeishuConfigService.getById(param.getId());
|
|
|
+ if (config == null || Objects.equals(config.getIsDel(), 1)) {
|
|
|
+ return AjaxResult.error("飞书配置不存在");
|
|
|
+ }
|
|
|
+ FsFeishuConfig exist = fsFeishuConfigService.getOne(
|
|
|
+ Wrappers.<FsFeishuConfig>lambdaQuery()
|
|
|
+ .eq(FsFeishuConfig::getAppId, param.getAppId())
|
|
|
+ .eq(FsFeishuConfig::getIsDel, 0)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (exist != null && !exist.getId().equals(config.getId())) {
|
|
|
+ return AjaxResult.error("appId已存在");
|
|
|
+ }
|
|
|
+ BeanUtils.copyProperties(param, config);
|
|
|
+ config.setUpdateTime(new Date());
|
|
|
+ fsFeishuConfigService.updateById(config);
|
|
|
+ fsFeishuConfigService.refreshNormalConfigCache();
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('course:feishuConfig:remove')")
|
|
|
+ @Log(title = "飞书配置", businessType = BusinessType.DELETE)
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
+ public AjaxResult remove(@PathVariable Long[] ids) {
|
|
|
+ Wrapper<FsFeishuConfig> updateWrapper = Wrappers.<FsFeishuConfig>lambdaUpdate()
|
|
|
+ .set(FsFeishuConfig::getIsDel, 1)
|
|
|
+ .set(FsFeishuConfig::getUpdateTime, new Date())
|
|
|
+ .in(FsFeishuConfig::getId, Arrays.asList(ids));
|
|
|
+ fsFeishuConfigService.update(updateWrapper);
|
|
|
+ fsFeishuConfigService.refreshNormalConfigCache();
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+}
|