|
@@ -1,6 +1,7 @@
|
|
|
package com.fs.course.controller;
|
|
package com.fs.course.controller;
|
|
|
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -19,11 +20,15 @@ import com.fs.common.utils.ServletUtils;
|
|
|
import com.fs.common.utils.bean.BeanUtils;
|
|
import com.fs.common.utils.bean.BeanUtils;
|
|
|
import com.fs.course.config.CourseConfig;
|
|
import com.fs.course.config.CourseConfig;
|
|
|
import com.fs.course.domain.FsCoursePlaySourceConfig;
|
|
import com.fs.course.domain.FsCoursePlaySourceConfig;
|
|
|
|
|
+import com.fs.course.enums.MiniProgramAgreementEnum;
|
|
|
import com.fs.course.param.FsCoursePlaySourceConfigCreateParam;
|
|
import com.fs.course.param.FsCoursePlaySourceConfigCreateParam;
|
|
|
import com.fs.course.param.FsCoursePlaySourceConfigEditParam;
|
|
import com.fs.course.param.FsCoursePlaySourceConfigEditParam;
|
|
|
|
|
+import com.fs.course.param.MiniProgramAgreementParam;
|
|
|
import com.fs.course.service.IFsCoursePlaySourceConfigService;
|
|
import com.fs.course.service.IFsCoursePlaySourceConfigService;
|
|
|
import com.fs.course.vo.FsCoursePlaySourceConfigVO;
|
|
import com.fs.course.vo.FsCoursePlaySourceConfigVO;
|
|
|
import com.fs.framework.web.service.TokenService;
|
|
import com.fs.framework.web.service.TokenService;
|
|
|
|
|
+import com.fs.his.domain.MiniProgramAgreement;
|
|
|
|
|
+import com.fs.his.service.MiniProgramAgreementService;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
@@ -42,6 +47,7 @@ public class FsCoursePlaySourceConfigController extends BaseController {
|
|
|
private final IFsCoursePlaySourceConfigService fsCoursePlaySourceConfigService;
|
|
private final IFsCoursePlaySourceConfigService fsCoursePlaySourceConfigService;
|
|
|
private final TokenService tokenService;
|
|
private final TokenService tokenService;
|
|
|
private final ISysConfigService configService;
|
|
private final ISysConfigService configService;
|
|
|
|
|
+ private final MiniProgramAgreementService miniProgramAgreementService;
|
|
|
|
|
|
|
|
// @PreAuthorize("@ss.hasPermi('course:playSourceConfig:list')")
|
|
// @PreAuthorize("@ss.hasPermi('course:playSourceConfig:list')")
|
|
|
@GetMapping("/list")
|
|
@GetMapping("/list")
|
|
@@ -183,4 +189,58 @@ public class FsCoursePlaySourceConfigController extends BaseController {
|
|
|
}
|
|
}
|
|
|
return R.ok().put("data", fsCoursePlaySourceConfigService.list(queryWrapper));
|
|
return R.ok().put("data", fsCoursePlaySourceConfigService.list(queryWrapper));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('course:playSourceConfig:agreement')")
|
|
|
|
|
+ @Log(title = "小程序协议配置", businessType = BusinessType.UPDATE)
|
|
|
|
|
+ @PostMapping("/updateAgreementConfig")
|
|
|
|
|
+ public AjaxResult updateAgreementConfig(@RequestBody MiniProgramAgreementParam agreement) {
|
|
|
|
|
+ Map<String, String> map = (Map<String, String>) JSON.parse(agreement.getAgreementData());
|
|
|
|
|
+
|
|
|
|
|
+ List<MiniProgramAgreement> list = new ArrayList<>();
|
|
|
|
|
+ for (MiniProgramAgreementEnum agreementEnum : MiniProgramAgreementEnum.values()) {
|
|
|
|
|
+ String content = map.get(agreementEnum.getCode());
|
|
|
|
|
+ if (content != null) {
|
|
|
|
|
+ MiniProgramAgreement update = new MiniProgramAgreement();
|
|
|
|
|
+ update.setAppId(agreement.getAppId());
|
|
|
|
|
+ update.setAgreementType(agreementEnum.getCode());
|
|
|
|
|
+ update.setAgreementContent(content);
|
|
|
|
|
+
|
|
|
|
|
+ list.add(update);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!list.isEmpty()) {
|
|
|
|
|
+ miniProgramAgreementService.batchUpsertAgreements(list);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return AjaxResult.success();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('course:playSourceConfig:agreement')")
|
|
|
|
|
+ @GetMapping("/queryAgreementConfig")
|
|
|
|
|
+ public AjaxResult queryAgreementConfig(@RequestParam(required = true) String appid) {
|
|
|
|
|
+ // 查询协议数据
|
|
|
|
|
+ QueryWrapper<MiniProgramAgreement> queryWrapper = new QueryWrapper<MiniProgramAgreement>()
|
|
|
|
|
+ .eq("app_id", appid);
|
|
|
|
|
+ List<MiniProgramAgreement> agreements = miniProgramAgreementService.list(queryWrapper);
|
|
|
|
|
+
|
|
|
|
|
+ // 按agreementType分组
|
|
|
|
|
+ Map<String, String> agreementMap = new HashMap<>();
|
|
|
|
|
+ for (MiniProgramAgreement agreement : agreements) {
|
|
|
|
|
+ agreementMap.put(agreement.getAgreementType(), agreement.getAgreementContent());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 转换为JSON串返回
|
|
|
|
|
+ String agreementData = JSON.toJSONString(agreementMap);
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
|
|
+ result.put("agreementData", agreementData);
|
|
|
|
|
+ result.put("appId", appid);
|
|
|
|
|
+
|
|
|
|
|
+ return AjaxResult.success(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|