Browse Source

多项目共用小程序看课配置

Long 1 week ago
parent
commit
5140d8afe0

+ 44 - 0
fs-service-system/src/main/java/com/fs/store/domain/FsProjectAddressConfig.java

@@ -0,0 +1,44 @@
+package com.fs.store.domain;
+
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Data
+public class FsProjectAddressConfig {
+
+    /**
+     * 主键ID
+     */
+    private Long id;
+
+    /**
+     * 项目名称
+     */
+    private String name;
+
+    /**
+     * 唯一编码
+     */
+    private String code;
+
+    /**
+     * api接口地址
+     */
+    private String addressUrl;
+
+    /**
+     * 存储桶地址
+     */
+    private String bucketPath;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 修改时间
+     */
+    private LocalDateTime updateTime;
+}

+ 14 - 0
fs-service-system/src/main/java/com/fs/store/mapper/FsProjectAddressConfigMapper.java

@@ -0,0 +1,14 @@
+package com.fs.store.mapper;
+
+import com.fs.store.domain.FsProjectAddressConfig;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+public interface FsProjectAddressConfigMapper {
+
+    /**
+     * 根据code查询url
+     */
+    @Select("select * from fs_project_address_config where code = #{code}")
+    FsProjectAddressConfig selectDomainByCode(@Param("code") String code);
+}

+ 11 - 0
fs-service-system/src/main/java/com/fs/store/service/IFsProjectAddressConfigService.java

@@ -0,0 +1,11 @@
+package com.fs.store.service;
+
+import com.fs.store.domain.FsProjectAddressConfig;
+
+public interface IFsProjectAddressConfigService {
+
+    /**
+     * 根据code查询url
+     */
+    FsProjectAddressConfig selectDomainByCode(String code);
+}

+ 23 - 0
fs-service-system/src/main/java/com/fs/store/service/impl/FsProjectAddressConfigServiceImpl.java

@@ -0,0 +1,23 @@
+package com.fs.store.service.impl;
+
+import com.fs.store.domain.FsProjectAddressConfig;
+import com.fs.store.mapper.FsProjectAddressConfigMapper;
+import com.fs.store.service.IFsProjectAddressConfigService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+@Service
+public class FsProjectAddressConfigServiceImpl implements IFsProjectAddressConfigService {
+
+    @Resource
+    private FsProjectAddressConfigMapper fsProjectAddressConfigMapper;
+
+    /**
+     * 根据code查询url
+     */
+    @Override
+    public FsProjectAddressConfig selectDomainByCode(String code) {
+        return fsProjectAddressConfigMapper.selectDomainByCode(code);
+    }
+}

+ 13 - 0
fs-service-system/src/main/resources/db/20250826-项目配置表.sql

@@ -0,0 +1,13 @@
+-- 项目地址配置表
+drop table if exists `fs_project_address_config`;
+create table `fs_project_address_config` (
+    `id`            bigint not null auto_increment       comment '主键ID',
+    `name`          varchar(255) not null                comment '项目名称',
+    `code`          varchar(50)  not null                comment '唯一标识',
+    `address_url`   varchar(255)  not null               comment '接口地址',
+    `bucket_path`   varchar(255)  not null               comment '存储桶地址',
+    `create_time`   datetime                             comment '创建时间',
+    `update_time`   datetime                             comment '修改时间',
+    primary key (`id`) using btree,
+    unique key uk_code (`code`)
+) engine = Innodb comment '项目地址配置表';

+ 8 - 0
fs-service-system/src/main/resources/mapper/store/FsProjectAddressConfigMapper.xml

@@ -0,0 +1,8 @@
+<?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="com.fs.store.mapper.FsProjectAddressConfigMapper">
+
+
+</mapper>

+ 17 - 0
fs-user-app/src/main/java/com/fs/app/controller/CommonController.java

@@ -122,6 +122,9 @@ public class CommonController extends AppBaseController {
 	IFsStoreOrderService orderService;
 	@Autowired
 	IFsStorePaymentService paymentService;
+	@Autowired
+	private IFsProjectAddressConfigService projectAddressConfigService;
+
 //	@ApiOperation("批量推送订单")
 //	@GetMapping("pushOms")
 //	public R pushOms(String startTime) throws Exception
@@ -655,6 +658,20 @@ public class CommonController extends AppBaseController {
 		return R.ok();
 	}
 
+	@ApiOperation("获取项目对应api请求域名地址")
+	@GetMapping("/getDomain")
+	public R getDomain(@RequestParam String projectCode) {
+		FsProjectAddressConfig config = projectAddressConfigService.selectDomainByCode(projectCode);
+		String addressUrl = "";
+		String imgPath = "";
+
+		if (Objects.nonNull(config)) {
+			addressUrl = config.getAddressUrl();
+			imgPath = config.getBucketPath();
+		}
+
+		return R.ok().put("addressUrl", addressUrl).put("imgpath", imgPath);
+	}