diff --git a/pom.xml b/pom.xml index 1921581..49f4d9a 100644 --- a/pom.xml +++ b/pom.xml @@ -31,6 +31,18 @@ spring-boot-starter-web + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + 2.2.6.RELEASE + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + 2.2.6.RELEASE + + mysql mysql-connector-java @@ -95,12 +107,6 @@ httpclient - - com.xuxueli - xxl-job-core - 2.4.1 - - org.springframework.boot spring-boot-starter-test diff --git a/src/main/java/top/baogutang/music/config/XxlJobConfig.java b/src/main/java/top/baogutang/music/config/XxlJobConfig.java index 2378155..224ca33 100644 --- a/src/main/java/top/baogutang/music/config/XxlJobConfig.java +++ b/src/main/java/top/baogutang/music/config/XxlJobConfig.java @@ -1,42 +1,42 @@ -package top.baogutang.music.config; - -import com.xxl.job.core.executor.impl.XxlJobSpringExecutor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * @description: - * @author: nikooh - * @date: 2024/06/14 : 15:29 - */ -@Slf4j -@Configuration -//@ConditionalOnProperty(value = "spring.profiles.active", havingValue = "prod") -public class XxlJobConfig { - - @Value("${xxl.job.admin.addresses}") - private String adminAddresses; - - @Value("${xxl.job.executor.appName}") - private String appName; - - @Value("${xxl.job.executor.accessKey}") - private String accessKey; - - - @Bean - public XxlJobSpringExecutor xxlJobExecutor() { - log.info(">>>>>>>>>>> xxl-job config init start <<<<<<<<<<"); - XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor(); - xxlJobSpringExecutor.setAdminAddresses(adminAddresses); - xxlJobSpringExecutor.setAppname(appName); - xxlJobSpringExecutor.setAccessToken(accessKey); - log.info(">>>>>>>>>>> xxl-job config init success <<<<<<<<<<"); - return xxlJobSpringExecutor; - } - - -} +//package top.baogutang.music.config; +// +//import com.xxl.job.core.executor.impl.XxlJobSpringExecutor; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.beans.factory.annotation.Value; +//import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +//import org.springframework.context.annotation.Bean; +//import org.springframework.context.annotation.Configuration; +// +///** +// * @description: +// * @author: nikooh +// * @date: 2024/06/14 : 15:29 +// */ +//@Slf4j +//@Configuration +////@ConditionalOnProperty(value = "spring.profiles.active", havingValue = "prod") +//public class XxlJobConfig { +// +// @Value("${xxl.job.admin.addresses}") +// private String adminAddresses; +// +// @Value("${xxl.job.executor.appName}") +// private String appName; +// +// @Value("${xxl.job.executor.accessKey}") +// private String accessKey; +// +// +// @Bean +// public XxlJobSpringExecutor xxlJobExecutor() { +// log.info(">>>>>>>>>>> xxl-job config init start <<<<<<<<<<"); +// XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor(); +// xxlJobSpringExecutor.setAdminAddresses(adminAddresses); +// xxlJobSpringExecutor.setAppname(appName); +// xxlJobSpringExecutor.setAccessToken(accessKey); +// log.info(">>>>>>>>>>> xxl-job config init success <<<<<<<<<<"); +// return xxlJobSpringExecutor; +// } +// +// +//} diff --git a/src/main/java/top/baogutang/music/controller/MusicTriggerController.java b/src/main/java/top/baogutang/music/controller/MusicTriggerController.java new file mode 100644 index 0000000..a16da5f --- /dev/null +++ b/src/main/java/top/baogutang/music/controller/MusicTriggerController.java @@ -0,0 +1,32 @@ +package top.baogutang.music.controller; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import top.baogutang.music.domain.Results; +import top.baogutang.music.schedule.QQDailyMusicHandler; + +import javax.annotation.Resource; + +/** + * + * @description: + * + * @author: N1KO + * @date: 2024/12/23 : 15:26 + */ +@Slf4j +@RestController +@RequestMapping("/api/v1/music/trigger") +public class MusicTriggerController { + + @Resource + private QQDailyMusicHandler qqDailyMusicHandler; + + @GetMapping("/daily") + public Results triggerDaily() { + qqDailyMusicHandler.fetchDailyAndSave(); + return Results.ok(); + } +} diff --git a/src/main/java/top/baogutang/music/properties/QQMusicProperties.java b/src/main/java/top/baogutang/music/properties/QQMusicProperties.java index ca29b5f..3324610 100644 --- a/src/main/java/top/baogutang/music/properties/QQMusicProperties.java +++ b/src/main/java/top/baogutang/music/properties/QQMusicProperties.java @@ -2,6 +2,7 @@ package top.baogutang.music.properties; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.stereotype.Component; /** @@ -14,6 +15,7 @@ import org.springframework.stereotype.Component; @Data @Component @ConfigurationProperties(prefix = "baogutang.qq-music") +@RefreshScope public class QQMusicProperties { private String queryBaseUrl; diff --git a/src/main/java/top/baogutang/music/schedule/QQDailyMusicHandler.java b/src/main/java/top/baogutang/music/schedule/QQDailyMusicHandler.java index c4571d6..793fdea 100644 --- a/src/main/java/top/baogutang/music/schedule/QQDailyMusicHandler.java +++ b/src/main/java/top/baogutang/music/schedule/QQDailyMusicHandler.java @@ -7,6 +7,7 @@ import org.apache.commons.lang3.StringUtils; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; +import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; @@ -40,6 +41,7 @@ import java.util.zip.InflaterInputStream; */ @Slf4j @Component +@RefreshScope public class QQDailyMusicHandler extends DailyMusicHandler { @Resource diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml deleted file mode 100644 index f99ee11..0000000 --- a/src/main/resources/application.yml +++ /dev/null @@ -1,85 +0,0 @@ - -server: - port: 8105 - -spring: - profiles: - active: ${SPRING_ACTIVE_PROFILE:local} - application: - name: baogutang-music - datasource: - driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://117.72.78.133:3306/baogutang-music?characterEncoding=UTF-8 - username: baogutang-music - password: xCcFfY3zXh8sC28e - hikari: - max-lifetime: 60000 - redis: - host: 117.72.78.133 - port: 6379 - password: admin@pwdpwd - servlet: - multipart: - max-file-size: 2048MB - max-request-size: 32MB - resources: - static-locations: classpath:/templates/ - -thread: - pool: - core: 10 - max: 10 - alive: 10 - capacity: 200 - - - -knife4j: - enable: true - - -baogutang: - music: - zip: -# base-path: /downloads/music/zips - base-path: /Users/nikooh/Desktop/downloads/music/zips - net-ease-music: - query-base-url: http://117.72.78.133:5173/search?keywords=%s&limit=%d&offset=%d&type=%d - playlist-base-url: http://117.72.78.133:5173/playlist/track/all?id=%d - album-base-url: http://117.72.78.133:5173/album?id=%d - artist-base-url: http://117.72.78.133:5173/artists?id=%d - download-base-url: https://api.sooooooooooooooooootheby.top/Netease_url/Song_V1?level=jymaster&type=json&ids=%d - download-path: /downloads/music -# download-path: /Users/nikooh/Desktop/downloads/music - qq-music: - query-base-url: http://117.72.78.133:5175/search?key=%s&pageNo=%d&pageSize=%d&t=%d - playlist-base-url: http://117.72.78.133:5175/songlist?id=%s - album-base-url: http://117.72.78.133:5175/album/songs?albummid=%s - download-base-url1: http://117.72.78.133:5176/song?url=https://y.qq.com/n/ryqq/songDetail/%s - download-base-url2: http://117.72.78.133:5176/song?url=https://u.y.qq.com/n/ryqq/songDetail/%s - daily-music-base-url: https://c.y.qq.com/node/musicmac/v6/index.html - cookie: "RK=rUvZdxsXGU; ptcz=da14a0149395412d1ccada68745ff33321cfa01aad39b07aa3fcecae55395d97; pac_uid=0_eTHZsZHX7ba4M; _qimei_uuid42=18b140b1a2a100af5a8d7679cb48e01d678edc347b; _qimei_fingerprint=caa870019e5e1e0d9dc30786b07078ba; _qimei_h38=e25542625a8d7679cb48e01d03000006d18b14; _qimei_q36=; pgv_pvid=7363669324; fqm_pvqid=7c5bc23f-c99a-4341-ba32-643f6cfc30f2; ts_refer=www.google.com.hk/; ts_uid=3998702427; fqm_sessionid=ab065cb0-5652-4f77-a339-baf6a8afdb5f; pgv_info=ssid=s5380242360; login_type=1; ts_last=y.qq.com/n/ryqq/search; wxopenid=; uin=940879015; euin=NKvzNeSqoe6k; music_ignore_pskey=202306271436Hn@vBj; psrf_qqunionid=538FF9C402100468B3B9CB56FB49CA8B; wxunionid=; tmeLoginType=2; qqmusic_key=Q_H_L_63k3NJFbLtBHdyzgGBtfNP6_ZAiH0BPaf9vLQMUFOLe-WVnuOWGp-JUh7sgP-oSjrmFnzawQiTS69LcLVMFvs9w; psrf_qqopenid=EBFCD19499A42B5DFF06DE7BB15B3D98; psrf_qqrefresh_token=E2D138702A05B6A1D0582E516C18B595; qm_keyst=Q_H_L_63k3NJFbLtBHdyzgGBtfNP6_ZAiH0BPaf9vLQMUFOLe-WVnuOWGp-JUh7sgP-oSjrmFnzawQiTS69LcLVMFvs9w; psrf_musickey_createtime=1734917905; psrf_qqaccess_token=372F8B12E8910A482D80FDB5E3190D75; wxrefresh_token=; psrf_access_token_expiresAt=1735522705" - daily-music-search-url: http://c.y.qq.com/qzone/fcg-bin/fcg_ucc_getcdinfo_byids_cp.fcg?type=1&utf8=1&loginUin=0&disstid=%s - download-path: /downloads/music -# download-path: /Users/nikooh/Desktop/downloads/music - - kugou-music: - query-base-url: http://117.72.78.133:5177/search?keywords=%s&page=%d&pagesize=%d&type=%s - playlist-base-url: http://117.72.78.133:5177/playlist/track/all?id=%s&pagesize=200 - album-base-url: http://117.72.78.133:5177/album/songs?id=%s&pagesize=50 - artist-base-url: http://117.72.78.133:5177/artist/audios?id=%s&sort=hot&pagesize=%d - download-base-url: http://117.72.78.133:5177/song/url?hash=%s&quality=viper_clear - download-path: /downloads/music -# download-path: /Users/nikooh/Desktop/downloads/music - - -xxl: - job: - admin: - addresses: http://117.72.78.133:8900/xxl-job-admin - executor: - appName: ${spring.application.name} - accessKey: WJtjy1217 - - - diff --git a/src/main/resources/bootstrap-prod.yml b/src/main/resources/bootstrap-prod.yml new file mode 100644 index 0000000..4530c12 --- /dev/null +++ b/src/main/resources/bootstrap-prod.yml @@ -0,0 +1,19 @@ +spring: + application: + name: baogutang-music + cloud: + nacos: + discovery: + server-addr: 117.72.78.133:8848 + config: + server-addr: 117.72.78.133:8848 + namespace: 40b10af8-f553-41ae-8ff1-8cedf2272da0 + file-extension: yml + refresh-enabled: true + group: DEFAULT_GROUP + username: nacos + password: 199312 +# shared-configs: +# - data-id: goods-blindbox.yml +# refresh: true + diff --git a/src/main/resources/bootstrap.yml b/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..ef534cd --- /dev/null +++ b/src/main/resources/bootstrap.yml @@ -0,0 +1,5 @@ +spring: + profiles: + active: prod + main: + allow-bean-definition-overriding: true