pull/1121/head
liujiang 2025-10-31 21:24:48 +08:00
commit 88ef878053
9 changed files with 171 additions and 1 deletions

View File

@ -16,6 +16,7 @@ import com.ruoyi.framework.ocr.BusinessLicense;
import com.ruoyi.framework.ocr.IdCard;
import com.ruoyi.framework.ocr.OcrClientWrapper;
import com.ruoyi.framework.oss.OSSClientWrapper;
import com.ruoyi.system.service.ISysHtmlService;
import com.ruoyi.web.controller.common.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -24,6 +25,7 @@ import org.apache.commons.codec.binary.Base64;
import org.codehaus.jettison.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -60,6 +62,8 @@ public class CommonController {
private RedisCache redisCache;
@Autowired
private OcrClientWrapper ocrClient;
@Autowired
private ISysHtmlService htmlService;
@ApiOperation("获取OSS临时访问凭证")
@GetMapping("/oss/getCredentials")
@ -219,6 +223,20 @@ public class CommonController {
return R.ok(BeanUtil.toBean(dto, BusinessLicenseVO.class));
}
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
@ApiOperation("保存html需登录管理员用户")
@PostMapping("/html/save")
public R saveHtmlContent(@Validated @RequestBody HtmlVO vo){
htmlService.saveHtml(vo.getTitle(),vo.getContent());
return R.ok();
}
@ApiOperation("获取html内容")
@GetMapping("/html/content/{title}")
public String getHtmlContent(@PathVariable("title") String title) {
return htmlService.getHtmlContent(title);
}
/**
*
*

View File

@ -0,0 +1,26 @@
package com.ruoyi.web.controller.common.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* @author liangyq
* @date 2025-06-29
*/
@ApiModel
@Data
public class HtmlVO {
@NotEmpty
@ApiModelProperty("title")
private String title;
@NotNull
@ApiModelProperty("content")
private String content;
}

View File

@ -122,6 +122,8 @@ public class SecurityConfig
.antMatchers("/rest/v1/alipay-callback/**").permitAll()
//OSS回调
.antMatchers("/rest/v1/oss-callback/upload").permitAll()
//html
.antMatchers("/rest/v1/common/html/content/**").permitAll()
//物流回调
.antMatchers("/rest/v1/express-callback/**").permitAll()
// 系统广告及首页

View File

@ -989,7 +989,7 @@ public class XktTask {
public void autoCompleteStoreOrder() {
log.info("-------------自动完成订单开始-------------");
Integer batchCount = 20;
Date beforeDate = DateUtil.offset(new Date(), DateField.DAY_OF_YEAR, -14);
Date beforeDate = DateUtil.offset(new Date(), DateField.DAY_OF_YEAR, -15);
List<Long> storeOrderIds = storeOrderService.listNeedAutoCompleteOrder(beforeDate, batchCount);
for (Long storeOrderId : storeOrderIds) {
log.info("开始处理: {}", storeOrderId);

View File

@ -0,0 +1,20 @@
package com.ruoyi.system.domain;
import com.ruoyi.common.core.domain.SimpleEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
/**
* @author liangyq
* @date 2025-10-31
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class SysHtml extends SimpleEntity {
private String title;
private String content;
}

View File

@ -0,0 +1,13 @@
package com.ruoyi.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.system.domain.SysHtml;
import org.springframework.stereotype.Repository;
/**
* @author liangyq
* @date 2025-10-31
*/
@Repository
public interface SysHtmlMapper extends BaseMapper<SysHtml> {
}

View File

@ -0,0 +1,12 @@
package com.ruoyi.system.service;
/**
* @author liangyq
* @date 2025-10-31
*/
public interface ISysHtmlService {
void saveHtml(String title, String content);
String getHtmlContent(String title);
}

View File

@ -0,0 +1,65 @@
package com.ruoyi.system.service.impl;
import cn.hutool.cache.CacheUtil;
import cn.hutool.cache.impl.WeakCache;
import cn.hutool.core.lang.Assert;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.system.domain.SysHtml;
import com.ruoyi.system.mapper.SysHtmlMapper;
import com.ruoyi.system.service.ISysHtmlService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.Map;
/**
* @author liangyq
* @date 2025-10-31
*/
@Service
public class SysHtmlServiceImpl implements ISysHtmlService {
// private WeakCache<String, String> htmlCache = CacheUtil.newWeakCache(-1L);
private Map<String, String> htmlCache = new HashMap<>();
@Autowired
private SysHtmlMapper htmlMapper;
@Transactional(rollbackFor = Exception.class)
@Override
public void saveHtml(String title, String content) {
Assert.notEmpty(title);
SysHtml html = htmlMapper.selectOne(Wrappers.lambdaQuery(SysHtml.class).eq(SysHtml::getTitle, title));
if (html == null) {
//新增
html = new SysHtml();
html.setTitle(title);
html.setContent(content);
html.setDelFlag(Constants.UNDELETED);
htmlMapper.insert(html);
} else {
//修改
html.setContent(content);
html.setDelFlag(Constants.UNDELETED);
htmlMapper.updateById(html);
}
htmlCache.put(title, content);
}
@Override
public String getHtmlContent(String title) {
Assert.notEmpty(title);
String content = htmlCache.get(title);
if (content == null) {
SysHtml html = htmlMapper.selectOne(Wrappers.lambdaQuery(SysHtml.class).eq(SysHtml::getTitle, title));
if (html != null) {
content = html.getContent();
htmlCache.put(title, content);
}
}
return content;
}
}

View File

@ -4262,6 +4262,20 @@ CREATE TABLE `user_subscriptions`
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户关注u档口' ROW_FORMAT = DYNAMIC;
DROP TABLE IF EXISTS `sys_html`;
CREATE TABLE `sys_html` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
`title` varchar(256) NOT NULL COMMENT '标题',
`content` mediumblob DEFAULT NULL COMMENT '内容',
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '删除标志0代表存在 2代表删除',
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '创建者',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '更新者',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_title` (`title`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='网页内容';
-- 快递费用初始化(测试,上线前根据实际费用调整)
INSERT INTO express_fee_config ( express_id, region_code, first_item_amount, next_item_amount )
SELECT 1, region_code, 5, 5 FROM express_region WHERE region_level = 1;