Browse Source

增加政策法规

master
赵鹏 1 month ago
parent
commit
ab2b968bad
  1. 19
      yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/http/HttpUtils.java
  2. 2
      yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
  3. 140
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/policy/PolicyController.java
  4. 57
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/policy/PolicyHtmlController.java
  5. 25
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/policy/vo/PolicyPageReqVO.java
  6. 29
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/policy/vo/PolicyRespDetailVO.java
  7. 27
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/policy/vo/PolicyRespVO.java
  8. 20
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/policy/vo/PolicySaveReqVO.java
  9. 39
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/policy/PolicyDO.java
  10. 27
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/policy/PolicyMapper.java
  11. 6
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/maxkb/MaxkbApiService.java
  12. 52
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/maxkb/MaxkbApiServiceImpl.java
  13. 56
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/policy/PolicyService.java
  14. 75
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/policy/PolicyServiceImpl.java
  15. 12
      yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/policy/PolicyMapper.xml
  16. 6
      yudao-server/src/main/resources/application-dev.yaml
  17. 6
      yudao-server/src/main/resources/application-local.yaml
  18. 4
      yudao-server/src/main/resources/application.yaml

19
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/http/HttpUtils.java

@ -143,6 +143,25 @@ public class HttpUtils {
}
}
/**
* HTTP post 请求基于 {@link cn.hutool.http.HttpUtil} 实现
*
* 为什么要封装该方法因为 HttpUtil 默认封装的方法没有允许传递 headers 参数
*
* @param url URL
* @param headers 请求头
* @param requestBody 请求体
* @return 请求结果
*/
public static String delete(String url, Map<String, String> headers, String requestBody) {
try (HttpResponse response = HttpRequest.delete(url)
.addHeaders(headers)
.body(requestBody)
.execute()) {
return response.body();
}
}
/**
* HTTP get 请求基于 {@link cn.hutool.http.HttpUtil} 实现
*

2
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java

@ -205,5 +205,5 @@ public interface ErrorCodeConstants {
ErrorCode SIGN_IN_LOG_ERROR6 = new ErrorCode(1-003-005-003, "超过2人才能打开");
ErrorCode POLICY_NOT_EXISTS = new ErrorCode(1-003-006-001, "政策法规不存在");
}

140
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/policy/PolicyController.java

@ -0,0 +1,140 @@
package cn.iocoder.yudao.module.system.controller.admin.policy;
import cn.iocoder.yudao.module.system.controller.admin.maxkb.vo.MaxkbdocumentVo;
import cn.iocoder.yudao.module.system.service.maxkb.MaxkbApiService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.system.controller.admin.policy.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.policy.PolicyDO;
import cn.iocoder.yudao.module.system.service.policy.PolicyService;
import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
@Tag(name = "管理后台 - 政策法规")
@RestController
@RequestMapping("/system/policy")
@Validated
public class PolicyController {
@Resource
private PolicyService policyService;
@Resource
private MaxkbApiService maxkbApiService;
@Value("${yudao.web.url}")
private String webUrl;
@Value("${yudao.maxkb.policy.url}")
private String policyUrl;
@Value("${yudao.maxkb.policy.id}")
private String policyMaxId;
@PostMapping("/create")
@Operation(summary = "创建政策法规")
@PreAuthorize("@ss.hasPermission('system:policy:create')")
public CommonResult<Integer> createPolicy(@Valid @RequestBody PolicySaveReqVO createReqVO) {
Integer policy = policyService.createPolicy(createReqVO);
MaxkbdocumentVo maxkbdocumentVo =new MaxkbdocumentVo();
maxkbdocumentVo.setId(policyMaxId);
maxkbdocumentVo.setSource_url_list(new String[]{getViewUrl(policy)});
maxkbApiService.pushWebUrl(maxkbdocumentVo);
return success(policy);
}
private String getViewUrl(Integer id){
return webUrl+policyUrl+"?id="+id;
}
@PutMapping("/update")
@Operation(summary = "更新政策法规")
@PreAuthorize("@ss.hasPermission('system:policy:update')")
public CommonResult<Boolean> updatePolicy(@Valid @RequestBody PolicySaveReqVO updateReqVO) {
policyService.updatePolicy(updateReqVO);
String viewUrl = getViewUrl(updateReqVO.getId());
maxkbApiService.deleteByName(viewUrl,policyMaxId);
MaxkbdocumentVo maxkbdocumentVo =new MaxkbdocumentVo();
maxkbdocumentVo.setId(policyMaxId);
maxkbdocumentVo.setSource_url_list(new String[]{getViewUrl(updateReqVO.getId())});
maxkbApiService.pushWebUrl(maxkbdocumentVo);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除政策法规")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('system:policy:delete')")
public CommonResult<Boolean> deletePolicy(@RequestParam("id") Integer id) {
policyService.deletePolicy(id);
String viewUrl = getViewUrl(id);
maxkbApiService.deleteByName(viewUrl,policyMaxId);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得政策法规")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PermitAll
public CommonResult<PolicyRespDetailVO> getPolicy(@RequestParam("id") Integer id) {
PolicyDO policy = policyService.getPolicy(id);
return success(BeanUtils.toBean(policy, PolicyRespDetailVO.class));
}
@GetMapping("/getContent")
@Operation(summary = "获得政策法规")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PermitAll
public String getContentPolicy(@RequestParam("id") Integer id) {
PolicyDO policy = policyService.getPolicy(id);
String context = policy.getContext();
return "<html><body>"+context+"</body></html>";
}
@GetMapping("/page")
@Operation(summary = "获得政策法规分页")
@PreAuthorize("@ss.hasPermission('system:policy:query')")
public CommonResult<PageResult<PolicyRespVO>> getPolicyPage(@Valid PolicyPageReqVO pageReqVO) {
PageResult<PolicyDO> pageResult = policyService.getPolicyPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, PolicyRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出政策法规 Excel")
@PreAuthorize("@ss.hasPermission('system:policy:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportPolicyExcel(@Valid PolicyPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<PolicyDO> list = policyService.getPolicyPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "政策法规.xls", "数据", PolicyRespVO.class,
BeanUtils.toBean(list, PolicyRespVO.class));
}
}

57
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/policy/PolicyHtmlController.java

@ -0,0 +1,57 @@
package cn.iocoder.yudao.module.system.controller.admin.policy;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.system.controller.admin.maxkb.vo.MaxkbdocumentVo;
import cn.iocoder.yudao.module.system.controller.admin.policy.vo.PolicyPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.policy.vo.PolicyRespDetailVO;
import cn.iocoder.yudao.module.system.controller.admin.policy.vo.PolicyRespVO;
import cn.iocoder.yudao.module.system.controller.admin.policy.vo.PolicySaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.policy.PolicyDO;
import cn.iocoder.yudao.module.system.service.maxkb.MaxkbApiService;
import cn.iocoder.yudao.module.system.service.policy.PolicyService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 政策法规")
@RequestMapping("/system/policyHtml")
@RestController
public class PolicyHtmlController {
@Resource
private PolicyService policyService;
@GetMapping("/getContent")
@Operation(summary = "获得政策法规")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PermitAll
@ResponseBody
public String getContentPolicy(@RequestParam("id") Integer id) {
PolicyDO policy = policyService.getPolicy(id);
String context = policy.getContext();
return "<html><body>"+context+"</body></html>";
}
}

25
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/policy/vo/PolicyPageReqVO.java

@ -0,0 +1,25 @@
package cn.iocoder.yudao.module.system.controller.admin.policy.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 政策法规分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PolicyPageReqVO extends PageParam {
@Schema(description = "名称", example = "王五")
private String name;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

29
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/policy/vo/PolicyRespDetailVO.java

@ -0,0 +1,29 @@
package cn.iocoder.yudao.module.system.controller.admin.policy.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 政策法规 Response VO")
@Data
@ExcelIgnoreUnannotated
public class PolicyRespDetailVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "29928")
@ExcelProperty("id")
private Integer id;
@Schema(description = "名称", example = "王五")
@ExcelProperty("名称")
private String name;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
private String context;
}

27
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/policy/vo/PolicyRespVO.java

@ -0,0 +1,27 @@
package cn.iocoder.yudao.module.system.controller.admin.policy.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 政策法规 Response VO")
@Data
@ExcelIgnoreUnannotated
public class PolicyRespVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "29928")
@ExcelProperty("id")
private Integer id;
@Schema(description = "名称", example = "王五")
@ExcelProperty("名称")
private String name;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

20
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/policy/vo/PolicySaveReqVO.java

@ -0,0 +1,20 @@
package cn.iocoder.yudao.module.system.controller.admin.policy.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
@Schema(description = "管理后台 - 政策法规新增/修改 Request VO")
@Data
public class PolicySaveReqVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "29928")
private Integer id;
@Schema(description = "名称", example = "王五")
private String name;
@Schema(description = "内容")
private String context;
}

39
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/policy/PolicyDO.java

@ -0,0 +1,39 @@
package cn.iocoder.yudao.module.system.dal.dataobject.policy;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 政策法规 DO
*
* @author 芋道源码
*/
@TableName("hb_policy")
@KeySequence("hb_policy_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PolicyDO extends BaseDO {
/**
* id
*/
@TableId
private Integer id;
/**
* 名称
*/
private String name;
/**
* 内容
*/
private String context;
}

27
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/policy/PolicyMapper.java

@ -0,0 +1,27 @@
package cn.iocoder.yudao.module.system.dal.mysql.policy;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.dal.dataobject.policy.PolicyDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.system.controller.admin.policy.vo.*;
/**
* 政策法规 Mapper
*
* @author 芋道源码
*/
@Mapper
public interface PolicyMapper extends BaseMapperX<PolicyDO> {
default PageResult<PolicyDO> selectPage(PolicyPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<PolicyDO>()
.likeIfPresent(PolicyDO::getName, reqVO.getName())
.betweenIfPresent(PolicyDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(PolicyDO::getId));
}
}

6
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/maxkb/MaxkbApiService.java

@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.system.service.maxkb;
import cn.hutool.json.JSONArray;
import cn.iocoder.yudao.module.system.controller.admin.maxkb.vo.MaxkbdocumentVo;
import com.google.gson.JsonObject;
import java.util.List;
@ -10,4 +12,8 @@ public interface MaxkbApiService {
public void pushWebUrl(MaxkbdocumentVo maxkbdocumentVo) ;
public JSONArray getDocumentList(String name, String id);
public void deleteByName(String name, String id);
}

52
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/maxkb/MaxkbApiServiceImpl.java

@ -7,6 +7,7 @@ import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.common.util.http.HttpUtils;
import cn.iocoder.yudao.module.infra.api.config.ConfigApi;
import cn.iocoder.yudao.module.system.controller.admin.maxkb.vo.MaxkbdocumentVo;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
@ -16,6 +17,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@Service
@Slf4j
@ -50,11 +52,61 @@ public class MaxkbApiServiceImpl implements MaxkbApiService {
@Override
public void pushWebUrl(MaxkbdocumentVo maxkbdocumentVo) {
log.info("web知识库请求信息:"+configApi.getConfigValueByKey(MAXKB_ACCOUNT_URL) + "/api/dataset/"+maxkbdocumentVo.getId()+"/document/web");
if(StrUtil.isEmpty(maxkbdocumentVo.getSelector())){
maxkbdocumentVo.setSelector("");
}
log.info("web知识库请求参数:"+JSONUtil.toJsonStr(maxkbdocumentVo));
log.info("webtoken:"+JSONUtil.toJsonStr(getMaxkbHeager()));
String s = HttpUtils.post(configApi.getConfigValueByKey(MAXKB_ACCOUNT_URL) + "/api/dataset/"+maxkbdocumentVo.getId()+"/document/web",getMaxkbHeager(), JSONUtil.toJsonStr(maxkbdocumentVo));
log.info("web知识库返回信息"+s);
}
@Override
public JSONArray getDocumentList(String name, String id) {
String s = HttpUtils.get(configApi.getConfigValueByKey(MAXKB_ACCOUNT_URL) + "/api/dataset/" + id + "/document/1/10000?name="+name, getMaxkbHeager());
log.info("web知识库返回信息"+s);
JSONObject jsonObject = JSONUtil.parseObj(s);
if("200".equals(jsonObject.getStr("code"))) {
JSONObject data = jsonObject.getJSONObject("data");
log.info("web知识库返回信息data"+JSONUtil.toJsonStr(data));
if (data != null) {
if(!JSONUtil.isNull(data)){
if(data.containsKey("records")){
log.info("web知识库返回信息records"+data.containsKey("records"));
}
JSONArray records = data.getJSONArray("records");
return records;
}
}
}
throw new RuntimeException(jsonObject.getStr("message"));
}
@Override
public void deleteByName(String name, String id) {
JSONArray documentList = getDocumentList(name, id);
if(documentList!= null && !documentList.isEmpty()){
//取出所有id
List<String> ids = documentList.stream().map(o -> ((JSONObject) o).getStr("id")).collect(Collectors.toList());
JSONObject jsonObject = new JSONObject();
jsonObject.set("id_list",ids);
String s = HttpUtils.delete(configApi.getConfigValueByKey(MAXKB_ACCOUNT_URL) + "/api/dataset/"+id+"/document/web",getMaxkbHeager(), JSONUtil.toJsonStr(jsonObject));
log.info("web知识库返回信息"+s);
}
}
private Map<String,String>getMaxkbHeager(){
String token = stringRedisTemplate.opsForValue().get(MAXKB_ACCOUNT_TOKEN);
if(StrUtil.isEmpty(token)){

56
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/policy/PolicyService.java

@ -0,0 +1,56 @@
package cn.iocoder.yudao.module.system.service.policy;
import java.util.*;
import cn.iocoder.yudao.module.system.controller.admin.policy.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.policy.PolicyDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import javax.validation.Valid;
/**
* 政策法规 Service 接口
*
* @author 芋道源码
*/
public interface PolicyService {
/**
* 创建政策法规
*
* @param createReqVO 创建信息
* @return 编号
*/
Integer createPolicy(@Valid PolicySaveReqVO createReqVO);
/**
* 更新政策法规
*
* @param updateReqVO 更新信息
*/
void updatePolicy(@Valid PolicySaveReqVO updateReqVO);
/**
* 删除政策法规
*
* @param id 编号
*/
void deletePolicy(Integer id);
/**
* 获得政策法规
*
* @param id 编号
* @return 政策法规
*/
PolicyDO getPolicy(Integer id);
/**
* 获得政策法规分页
*
* @param pageReqVO 分页查询
* @return 政策法规分页
*/
PageResult<PolicyDO> getPolicyPage(PolicyPageReqVO pageReqVO);
}

75
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/policy/PolicyServiceImpl.java

@ -0,0 +1,75 @@
package cn.iocoder.yudao.module.system.service.policy;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import cn.iocoder.yudao.module.system.controller.admin.policy.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.policy.PolicyDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.system.dal.mysql.policy.PolicyMapper;
import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
/**
* 政策法规 Service 实现类
*
* @author 芋道源码
*/
@Service
@Validated
public class PolicyServiceImpl implements PolicyService {
@Resource
private PolicyMapper policyMapper;
@Override
public Integer createPolicy(PolicySaveReqVO createReqVO) {
// 插入
PolicyDO policy = BeanUtils.toBean(createReqVO, PolicyDO.class);
policyMapper.insert(policy);
// 返回
return policy.getId();
}
@Override
public void updatePolicy(PolicySaveReqVO updateReqVO) {
// 校验存在
validatePolicyExists(updateReqVO.getId());
// 更新
PolicyDO updateObj = BeanUtils.toBean(updateReqVO, PolicyDO.class);
policyMapper.updateById(updateObj);
}
@Override
public void deletePolicy(Integer id) {
// 校验存在
validatePolicyExists(id);
// 删除
policyMapper.deleteById(id);
}
private void validatePolicyExists(Integer id) {
if (policyMapper.selectById(id) == null) {
throw exception(POLICY_NOT_EXISTS);
}
}
@Override
public PolicyDO getPolicy(Integer id) {
return policyMapper.selectById(id);
}
@Override
public PageResult<PolicyDO> getPolicyPage(PolicyPageReqVO pageReqVO) {
return policyMapper.selectPage(pageReqVO);
}
}

12
yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/policy/PolicyMapper.xml

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.system.dal.mysql.policy.PolicyMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

6
yudao-server/src/main/resources/application-dev.yaml

@ -164,6 +164,12 @@ wx: # 参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-sta
# 芋道配置项,设置当前项目所有自定义的配置
yudao:
web:
url: http://localhost:9980/
maxkb:
policy:
url: policyDetail
id: bff33a78-e5bd-11ef-825e-0242ac110003
pay:
order-notify-url: http://yunai.natapp1.cc/admin-api/pay/notify/order # 支付渠道的【支付】回调地址
refund-notify-url: http://yunai.natapp1.cc/admin-api/pay/notify/refund # 支付渠道的【退款】回调地址

6
yudao-server/src/main/resources/application-local.yaml

@ -212,6 +212,12 @@ wx:
# 芋道配置项,设置当前项目所有自定义的配置
yudao:
web:
url: http://localhost:9980/
maxkb:
policy:
url: policyDetail
id: bff33a78-e5bd-11ef-825e-0242ac110003
captcha:
enable: false # 本地环境,暂时关闭图片验证码,方便登录等接口的测试;
security:

4
yudao-server/src/main/resources/application.yaml

@ -221,6 +221,9 @@ yudao:
security:
permit-all_urls:
- /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,不需要登录
- /admin-api/system/policy/get # 微信公众号开放平台,微信回调接口,不需要登录
- /admin-api/system/policy/getContent # 微信公众号开放平台,微信回调接口,不需要登录
- /admin-api/system/policyHtml/getContent # 微信公众号开放平台,微信回调接口,不需要登录
websocket:
enable: true # websocket的开关
path: /infra/ws # 路径
@ -260,6 +263,7 @@ yudao:
- /jmreport/* # 积木报表,无法携带租户编号
- /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,无法携带租户编号
- /admin-api/system/wechat/**
- /policyDetail
ignore-tables:
- system_tenant
- system_tenant_package

Loading…
Cancel
Save