commit 10ff5d21f403d028e3a94ed5ad4c7bd660c57fef Author: zhang chengzhi <3144712872@qq.com> Date: Sat Aug 10 19:44:14 2024 +0800 资源推送微服务 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3e403e3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,35 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store diff --git a/cloud-resource-common/pom.xml b/cloud-resource-common/pom.xml new file mode 100644 index 0000000..8ed7ea0 --- /dev/null +++ b/cloud-resource-common/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + + com.muyu + cloud-resource + 1.0.0 + + + cloud-resource-common + + + 17 + 17 + UTF-8 + + + + + com.muyu + cloud-common-core + + + + + + + diff --git a/cloud-resource-common/src/main/java/com/muyu/cloud/resource/domain/ResourceInfo.java b/cloud-resource-common/src/main/java/com/muyu/cloud/resource/domain/ResourceInfo.java new file mode 100644 index 0000000..8c92961 --- /dev/null +++ b/cloud-resource-common/src/main/java/com/muyu/cloud/resource/domain/ResourceInfo.java @@ -0,0 +1,66 @@ +package com.muyu.cloud.resource.domain; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.muyu.common.core.annotation.Excel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author:zhangchengzhi + * @Package:com.muyu.domain + * @Project:cloud-resource + * @name:ResourceInfo + * @Date:2024/8/10 10:20 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ResourceInfo { + +@Excel(name = "") +private String id; +private String recommendId; +private String title; +private String titleFormat; +private String otherTitle; +private String seriesNumber; +private String seriesTitle; +private String pissn; +private String eissn; +private String pisbn; +private String eisbn; +private String orderNumber; +private String subject; +private String publisher; +private String country; +private String pubYear; +private String foundedYear; +private String language; +private String pubFeq; +private String Intro; +private String classiNumber; +private String url; +private String carrier; +private String type; +private String pubPattern; +private String pubStatus; +private String price; +private String currency; +private String OA; +private String sysTime; +private String sysUserId; +private String organId; +private String orderStatus; +private String distributionStatus; +private String reviewStatus; +private String updReviewStatus; +private String totalScore; +private String factor; +private String note; +private String inlet; +private String oldId; +private String systemId; +private String resVol; +} diff --git a/cloud-resource-common/src/main/java/com/muyu/cloud/resource/domain/SysParam.java b/cloud-resource-common/src/main/java/com/muyu/cloud/resource/domain/SysParam.java new file mode 100644 index 0000000..ca25752 --- /dev/null +++ b/cloud-resource-common/src/main/java/com/muyu/cloud/resource/domain/SysParam.java @@ -0,0 +1,35 @@ +package com.muyu.cloud.resource.domain; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author:zhangchengzhi + * @Package:com.muyu.cloud.resource.domain + * @Project:cloud-resource + * @name:SysParam + * @Date:2024/8/10 10:30 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class SysParam { + +private String id; +private String code; +private String isDel; +private String level; +private String name; +private String startNum; +private String endNum; +private String pid; +private String score; +private String weight; +private String defaultStatus; +private String system; +private String orderBy; +private String type; +private String text; + +} diff --git a/cloud-resource-server/pom.xml b/cloud-resource-server/pom.xml new file mode 100644 index 0000000..63d2990 --- /dev/null +++ b/cloud-resource-server/pom.xml @@ -0,0 +1,135 @@ + + + 4.0.0 + + com.muyu + cloud-resource + 1.0.0 + + + cloud-resource-server + + + 17 + 17 + UTF-8 + + + + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + + org.springframework.boot + spring-boot-starter-actuator + + + + + com.mysql + mysql-connector-j + + + + + com.muyu + cloud-common-datasource + + + + + com.muyu + cloud-common-datascope + + + + + com.muyu + cloud-common-log + + + + + com.muyu + cloud-common-api-doc + + + + + com.muyu + cloud-common-xxl + + + + + com.muyu + cloud-common-rabbit + + + + com.muyu + cloud-pay-common + + + + com.muyu + cloud-common-nacos-remote + + + + com.muyu + cloud-resource-common + 1.0.0 + + + + + + + cloud-pay + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + + + + + diff --git a/cloud-resource-server/src/main/java/com/muyu/resource/MuYuResourceApplication.java b/cloud-resource-server/src/main/java/com/muyu/resource/MuYuResourceApplication.java new file mode 100644 index 0000000..eccb3d2 --- /dev/null +++ b/cloud-resource-server/src/main/java/com/muyu/resource/MuYuResourceApplication.java @@ -0,0 +1,24 @@ +package com.muyu.resource; + +import com.muyu.common.security.annotation.EnableCustomConfig; +import com.muyu.common.security.annotation.EnableMyFeignClients; +import lombok.extern.log4j.Log4j2; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @Author:zhangchengzhi + * @Package:com.muyu.cloud.pay + * @Project:cloud-pay + * @name:MuYuPayApplication + * @Date:2024/7/29 17:08 + */ +@Log4j2 +@EnableCustomConfig +@EnableMyFeignClients +@SpringBootApplication +public class MuYuResourceApplication { + public static void main (String[] args) { + SpringApplication.run(MuYuResourceApplication.class, args); + } +} diff --git a/cloud-resource-server/src/main/java/com/muyu/resource/controller/ResourceController.java b/cloud-resource-server/src/main/java/com/muyu/resource/controller/ResourceController.java new file mode 100644 index 0000000..2d699d9 --- /dev/null +++ b/cloud-resource-server/src/main/java/com/muyu/resource/controller/ResourceController.java @@ -0,0 +1,67 @@ +package com.muyu.resource.controller; + +import com.muyu.cloud.resource.domain.ResourceInfo; +import com.muyu.common.core.domain.Result; +import com.muyu.common.core.utils.poi.ExcelUtil; +import com.muyu.common.log.annotation.Log; +import com.muyu.common.log.enums.BusinessType; +import com.muyu.common.security.annotation.RequiresPermissions; +import com.muyu.common.security.utils.SecurityUtils; +import com.muyu.common.system.domain.SysUser; +import com.muyu.resource.service.ResourceService; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.util.List; + +import static com.muyu.common.core.domain.Result.success; + +/** + * @Author:zhangchengzhi + * @Package:com.muyu.cloud.resource.controller + * @Project:cloud-resource + * @name:ResourceController + * @Date:2024/8/10 10:35 + */ +@RestController +@RequestMapping("/ResourceInfo") +public class ResourceController { + + @Autowired + private ResourceService resourceService; + + + + @Log(title = "用户管理", businessType = BusinessType.IMPORT) + @RequiresPermissions("Resource:ResourceInfo:import") + @PostMapping("/importData") + public Result importData (MultipartFile file, boolean updateSupport) throws Exception { + ExcelUtil util = new ExcelUtil(ResourceInfo.class); + List resourceList = util.importExcel(file.getInputStream()); +// String operName = SecurityUtils.getUsername(); +// String message = resourceService.importResource(resourceList, updateSupport, operName); + return Result.success(resourceList); + + } + @PostMapping("/importTemplate") + public void importTemplate (HttpServletResponse response) throws IOException { + ExcelUtil util = new ExcelUtil(SysUser.class); + util.importTemplateExcel(response, "用户数据"); + } + + + @PostMapping("/upload") + public void upload(HttpServletResponse response){ + + + + } + + + +} diff --git a/cloud-resource-server/src/main/java/com/muyu/resource/mapper/ResourceMapper.java b/cloud-resource-server/src/main/java/com/muyu/resource/mapper/ResourceMapper.java new file mode 100644 index 0000000..9fb1eef --- /dev/null +++ b/cloud-resource-server/src/main/java/com/muyu/resource/mapper/ResourceMapper.java @@ -0,0 +1,25 @@ +package com.muyu.resource.mapper; + +import com.muyu.cloud.resource.domain.ResourceInfo; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * @Author:zhangchengzhi + * @Package:com.muyu.cloud.resource.mapper + * @Project:cloud-resource + * @name:ResourceMapper + * @Date:2024/8/10 11:42 + */ +@Mapper +public interface ResourceMapper { + + /** + * 查询所有数据 + * @return + */ + +List selectResourceAll(); + +} diff --git a/cloud-resource-server/src/main/java/com/muyu/resource/redis/DataSynchronization.java b/cloud-resource-server/src/main/java/com/muyu/resource/redis/DataSynchronization.java new file mode 100644 index 0000000..8071268 --- /dev/null +++ b/cloud-resource-server/src/main/java/com/muyu/resource/redis/DataSynchronization.java @@ -0,0 +1,42 @@ +package com.muyu.resource.redis; + +import com.muyu.resource.mapper.ResourceMapper; +import com.muyu.common.redis.service.RedisService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; +import org.springframework.stereotype.Component; + +/** + * @Author:zhangchengzhi + * @Package:com.muyu.cloud.resource.redis + * @Project:cloud-resource + * @name: + * @Date:2024/8/10 11:25 + */ +@Component +public class DataSynchronization implements ApplicationRunner { + + @Autowired + private RedisService redisService; + + @Autowired + private ResourceMapper resourceMapper; + + /** + * 数据库同步到redis + * @param args + * @throws Exception + */ + @Override + public void run(ApplicationArguments args) throws Exception { + + + + + + + + + } +} diff --git a/cloud-resource-server/src/main/java/com/muyu/resource/service/Impl/ResourceServiceImpl.java b/cloud-resource-server/src/main/java/com/muyu/resource/service/Impl/ResourceServiceImpl.java new file mode 100644 index 0000000..759edc3 --- /dev/null +++ b/cloud-resource-server/src/main/java/com/muyu/resource/service/Impl/ResourceServiceImpl.java @@ -0,0 +1,40 @@ +package com.muyu.resource.service.Impl; + +import com.muyu.cloud.resource.domain.ResourceInfo; +import com.muyu.common.core.exception.ServiceException; +import com.muyu.common.core.utils.StringUtils; +import com.muyu.common.core.utils.bean.BeanValidators; +import com.muyu.common.security.utils.SecurityUtils; +import com.muyu.common.system.domain.SysUser; +import com.muyu.resource.mapper.ResourceMapper; +import com.muyu.resource.service.ResourceService; +import jakarta.validation.Validator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @Author:zhangchengzhi + * @Package:com.muyu.resource.service.Impl + * @Project:cloud-resource + * @name:ResourceServiceImpl + * @Date:2024/8/10 19:15 + */ +@Service +public class ResourceServiceImpl implements ResourceService { + + @Autowired + private ResourceMapper resourceMapper; + + private static final Logger log = LoggerFactory.getLogger(ResourceServiceImpl.class); + + @Autowired + protected Validator validator; + + + + +} diff --git a/cloud-resource-server/src/main/java/com/muyu/resource/service/ResourceService.java b/cloud-resource-server/src/main/java/com/muyu/resource/service/ResourceService.java new file mode 100644 index 0000000..2353c2c --- /dev/null +++ b/cloud-resource-server/src/main/java/com/muyu/resource/service/ResourceService.java @@ -0,0 +1,18 @@ +package com.muyu.resource.service; + +import com.muyu.cloud.resource.domain.ResourceInfo; +import com.muyu.common.system.domain.SysUser; + +import java.util.List; + +/** + * @Author:zhangchengzhi + * @Package:com.muyu.resource.service + * @Project:cloud-resource + * @name:ResourceService + * @Date:2024/8/10 19:14 + */ +public interface ResourceService { + + +} diff --git a/cloud-resource-server/src/main/resources/banner.txt b/cloud-resource-server/src/main/resources/banner.txt new file mode 100644 index 0000000..0dd5eee --- /dev/null +++ b/cloud-resource-server/src/main/resources/banner.txt @@ -0,0 +1,2 @@ +Spring Boot Version: ${spring-boot.version} +Spring Application Name: ${spring.application.name} diff --git a/cloud-resource-server/src/main/resources/bootstrap.yml b/cloud-resource-server/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..5fe13e3 --- /dev/null +++ b/cloud-resource-server/src/main/resources/bootstrap.yml @@ -0,0 +1,56 @@ +# Tomcat +server: + port: 9701 + +# nacos线上地址 +nacos: + addr: 106.54.199.209:8848 + user-name: nacos + password: nacos + namespace: high-six + +# Spring +spring: + main: + allow-bean-definition-overriding: true + application: + # 应用名称 + name: cloud-resource + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: ${nacos.addr} + # nacos用户名 + username: ${nacos.user-name} + # nacos密码 + password: ${nacos.password} + # 命名空间 + namespace: ${nacos.namespace} + config: + # 服务注册地址 + server-addr: ${nacos.addr} + # nacos用户名 + username: ${nacos.user-name} + # nacos密码 + password: ${nacos.password} + # 命名空间 + namespace: ${nacos.namespace} + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + # 系统共享配置 + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + # 系统环境Config共享配置 + - application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + # xxl-job 配置文件 + - application-xxl-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + # rabbit 配置文件 + - application-rabbit-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} +logging: + level: + com.muyu.system.mapper: DEBUG diff --git a/cloud-resource-server/src/main/resources/logback/dev.xml b/cloud-resource-server/src/main/resources/logback/dev.xml new file mode 100644 index 0000000..a0e16b0 --- /dev/null +++ b/cloud-resource-server/src/main/resources/logback/dev.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + ${log.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + ERROR + + ACCEPT + + DENY + + + + + + + + + + + + + + + + + + diff --git a/cloud-resource-server/src/main/resources/logback/prod.xml b/cloud-resource-server/src/main/resources/logback/prod.xml new file mode 100644 index 0000000..afd0098 --- /dev/null +++ b/cloud-resource-server/src/main/resources/logback/prod.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + ${log.sky.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + + + ERROR + + ACCEPT + + DENY + + + + + + + + ${log.sky.pattern} + + + + + + + + + + + + + + + + + + + + diff --git a/cloud-resource-server/src/main/resources/logback/test.xml b/cloud-resource-server/src/main/resources/logback/test.xml new file mode 100644 index 0000000..be7c5f6 --- /dev/null +++ b/cloud-resource-server/src/main/resources/logback/test.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + ${log.sky.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + + + ERROR + + ACCEPT + + DENY + + + + + + + + ${log.sky.pattern} + + + + + + + + + + + + + + + + + + + + diff --git a/cloud-resource-server/src/main/resources/mapper/resource/ResourceMapper.xml b/cloud-resource-server/src/main/resources/mapper/resource/ResourceMapper.xml new file mode 100644 index 0000000..5d8abf6 --- /dev/null +++ b/cloud-resource-server/src/main/resources/mapper/resource/ResourceMapper.xml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..17dafa2 --- /dev/null +++ b/pom.xml @@ -0,0 +1,38 @@ + + + 4.0.0 + + + com.muyu + cloud-server-parent + 3.6.4 + + + cloud-resource + 1.0.0 + pom + + cloud-resource-common + cloud-resource-server + + + + 17 + 17 + UTF-8 + + + + + + + + + + + + + +