|
|
@@ -1,16 +1,14 @@
|
|
|
package com.fs.course.controller;
|
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
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.domain.R;
|
|
|
-import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.domain.model.LoginUser;
|
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
|
import com.fs.common.core.redis.RedisCache;
|
|
|
@@ -21,7 +19,9 @@ import com.fs.course.config.CourseConfig;
|
|
|
import com.fs.course.domain.FsCoursePlaySourceConfig;
|
|
|
import com.fs.course.param.FsCoursePlaySourceConfigCreateParam;
|
|
|
import com.fs.course.param.FsCoursePlaySourceConfigEditParam;
|
|
|
+import com.fs.course.param.FsCoursePlaySourceConfigProtocolParam;
|
|
|
import com.fs.course.service.IFsCoursePlaySourceConfigService;
|
|
|
+import com.fs.course.vo.FsCoursePlaySourceConfigProtocolVO;
|
|
|
import com.fs.course.vo.FsCoursePlaySourceConfigVO;
|
|
|
import com.fs.framework.web.service.TokenService;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
@@ -29,6 +29,7 @@ import com.github.pagehelper.PageHelper;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
@@ -175,4 +176,107 @@ public class FsCoursePlaySourceConfigController extends BaseController {
|
|
|
public void addRedis(String appId,Integer viewPermissions){
|
|
|
redisCache.setCacheObject("viewPermissions:"+appId, viewPermissions);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取隐私协议
|
|
|
+ * **/
|
|
|
+ @PostMapping("/getProtocol")
|
|
|
+ public R getProtocol(@RequestBody FsCoursePlaySourceConfigCreateParam param){
|
|
|
+ FsCoursePlaySourceConfig config = fsCoursePlaySourceConfigService.getById(param.getId());
|
|
|
+ if (config == null) {
|
|
|
+ return R.error("配置信息不存在");
|
|
|
+ }
|
|
|
+ FsCoursePlaySourceConfigProtocolVO protocolVO = new FsCoursePlaySourceConfigProtocolVO();
|
|
|
+ BeanUtils.copyProperties(config, protocolVO);
|
|
|
+ return R.ok(protocolVO);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新协议配置
|
|
|
+ */
|
|
|
+ @PostMapping("/updateProtocol")
|
|
|
+ public R updateProtocol(@Valid @RequestBody FsCoursePlaySourceConfigProtocolParam param) {
|
|
|
+ if (param.getId() == null || param.getId() == 0) {
|
|
|
+ return R.error("配置ID不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ //检查配置是否存在
|
|
|
+ FsCoursePlaySourceConfig config = fsCoursePlaySourceConfigService.getById(param.getId());
|
|
|
+ if (config == null) {
|
|
|
+ return R.error("配置信息不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断协议填写程度
|
|
|
+ int protocolType = calculateProtocolType(param);
|
|
|
+
|
|
|
+ //更新数据
|
|
|
+ FsCoursePlaySourceConfig updateConfig = new FsCoursePlaySourceConfig();
|
|
|
+ updateConfig.setId(param.getId());
|
|
|
+
|
|
|
+ // 设置协议字段
|
|
|
+ updateConfig.setDoctorRegister(param.getDoctorRegister());
|
|
|
+ updateConfig.setDoctorFiling(param.getDoctorFiling());
|
|
|
+ updateConfig.setPharmacistRegister(param.getPharmacistRegister());
|
|
|
+ updateConfig.setPharmacistFiling(param.getPharmacistFiling());
|
|
|
+ updateConfig.setUserRegister(param.getUserRegister());
|
|
|
+ updateConfig.setUserPrivacy(param.getUserPrivacy());
|
|
|
+ updateConfig.setUserHealth(param.getUserHealth());
|
|
|
+ updateConfig.setVipService(param.getVipService());
|
|
|
+ updateConfig.setVipAutomaticService(param.getVipAutomaticService());
|
|
|
+ updateConfig.setUserRemoveService(param.getUserRemoveService());
|
|
|
+ updateConfig.setStoreRules(param.getStoreRules());
|
|
|
+ updateConfig.setResidencyAgreement(param.getResidencyAgreement());
|
|
|
+ updateConfig.setSettingsProtocolType(protocolType);
|
|
|
+ boolean success = fsCoursePlaySourceConfigService.updateById(updateConfig);
|
|
|
+ if (success) {
|
|
|
+ //更新缓存
|
|
|
+ addProtocolRedis(config.getAppid(), JSON.toJSONString(updateConfig));
|
|
|
+ }
|
|
|
+ return success ? R.ok("更新成功") : R.error("更新失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ //加入协议缓存
|
|
|
+ public void addProtocolRedis(String appId,String value){
|
|
|
+ redisCache.setCacheObject("ProtocolConfig:"+appId, value);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算协议填写程度
|
|
|
+ * 0-未设置 1-部分设置 2-已设置
|
|
|
+ */
|
|
|
+ private int calculateProtocolType(FsCoursePlaySourceConfigProtocolParam param) {
|
|
|
+ // 所有需要检查的协议字段
|
|
|
+ String[] protocolFields = {
|
|
|
+ param.getDoctorRegister(),
|
|
|
+ param.getDoctorFiling(),
|
|
|
+ param.getPharmacistRegister(),
|
|
|
+ param.getPharmacistFiling(),
|
|
|
+ param.getUserRegister(),
|
|
|
+ param.getUserPrivacy(),
|
|
|
+ param.getUserHealth(),
|
|
|
+ param.getVipService(),
|
|
|
+ param.getVipAutomaticService(),
|
|
|
+ param.getUserRemoveService(),
|
|
|
+ param.getStoreRules(),
|
|
|
+ param.getResidencyAgreement()
|
|
|
+ };
|
|
|
+
|
|
|
+ int filledCount = 0;
|
|
|
+ int totalFields = protocolFields.length;
|
|
|
+
|
|
|
+ for (String field : protocolFields) {
|
|
|
+ if (StringUtils.hasText(field) && !field.equals("<p><br></p>")) {
|
|
|
+ filledCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (filledCount == 0) {
|
|
|
+ return 0; // 未设置
|
|
|
+ } else if (filledCount < totalFields) {
|
|
|
+ return 1; // 部分设置
|
|
|
+ } else {
|
|
|
+ return 2; // 已设置
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|