diff --git a/common/src/main/java/cn/hezhaohui/pojo/dto/MovieDTO.java b/common/src/main/java/cn/hezhaohui/pojo/dto/MovieDTO.java new file mode 100644 index 0000000..5bfe15d --- /dev/null +++ b/common/src/main/java/cn/hezhaohui/pojo/dto/MovieDTO.java @@ -0,0 +1,16 @@ +package cn.hezhaohui.pojo.dto; + + +import lombok.Data; + +import java.util.Date; + +@Data +public class MovieDTO { + + private Integer id; + + private String name; + + private Date day; +} \ No newline at end of file diff --git a/common/src/main/java/cn/hezhaohui/entity/Weather.java b/common/src/main/java/cn/hezhaohui/pojo/entity/Weather.java similarity index 89% rename from common/src/main/java/cn/hezhaohui/entity/Weather.java rename to common/src/main/java/cn/hezhaohui/pojo/entity/Weather.java index 65411a5..9f4f177 100644 --- a/common/src/main/java/cn/hezhaohui/entity/Weather.java +++ b/common/src/main/java/cn/hezhaohui/pojo/entity/Weather.java @@ -1,4 +1,4 @@ -package cn.hezhaohui.entity; +package cn.hezhaohui.pojo.entity; import lombok.Builder; import lombok.Data; diff --git a/common/src/main/java/cn/hezhaohui/pojo/vo/MovieVO.java b/common/src/main/java/cn/hezhaohui/pojo/vo/MovieVO.java new file mode 100644 index 0000000..6c0ce57 --- /dev/null +++ b/common/src/main/java/cn/hezhaohui/pojo/vo/MovieVO.java @@ -0,0 +1,11 @@ +package cn.hezhaohui.pojo.vo; + +import lombok.Data; + +@Data +public class MovieVO { + + private String name; + + private String date; +} diff --git a/lark/src/main/java/cn/hezhaohui/lark/client/MovieClient.java b/lark/src/main/java/cn/hezhaohui/lark/client/MovieClient.java new file mode 100644 index 0000000..46fe0e5 --- /dev/null +++ b/lark/src/main/java/cn/hezhaohui/lark/client/MovieClient.java @@ -0,0 +1,10 @@ +package cn.hezhaohui.lark.client; + +import cn.hezhaohui.pojo.dto.MovieDTO; + +import java.util.List; + +public interface MovieClient { + + List listMovies(); +} diff --git a/lark/src/main/java/cn/hezhaohui/lark/client/WeatherClient.java b/lark/src/main/java/cn/hezhaohui/lark/client/WeatherClient.java index 2decff4..5d37441 100644 --- a/lark/src/main/java/cn/hezhaohui/lark/client/WeatherClient.java +++ b/lark/src/main/java/cn/hezhaohui/lark/client/WeatherClient.java @@ -1,7 +1,7 @@ package cn.hezhaohui.lark.client; -import cn.hezhaohui.entity.Weather; +import cn.hezhaohui.pojo.entity.Weather; public interface WeatherClient { diff --git a/lark/src/main/java/cn/hezhaohui/lark/client/impl/MovieClientImpl.java b/lark/src/main/java/cn/hezhaohui/lark/client/impl/MovieClientImpl.java new file mode 100644 index 0000000..d3b4e36 --- /dev/null +++ b/lark/src/main/java/cn/hezhaohui/lark/client/impl/MovieClientImpl.java @@ -0,0 +1,18 @@ +package cn.hezhaohui.lark.client.impl; + +import cn.hezhaohui.pojo.dto.MovieDTO; +import cn.hezhaohui.lark.client.MovieClient; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONUtil; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Component +public class MovieClientImpl implements MovieClient { + @Override + public List listMovies() { + String ans = HttpUtil.get("http://localhost:8081/movie"); + return JSONUtil.parseArray(ans).toList(MovieDTO.class); + } +} diff --git a/lark/src/main/java/cn/hezhaohui/lark/client/impl/WeatherClientImpl.java b/lark/src/main/java/cn/hezhaohui/lark/client/impl/WeatherClientImpl.java index fc0664b..2a1d730 100644 --- a/lark/src/main/java/cn/hezhaohui/lark/client/impl/WeatherClientImpl.java +++ b/lark/src/main/java/cn/hezhaohui/lark/client/impl/WeatherClientImpl.java @@ -1,7 +1,7 @@ package cn.hezhaohui.lark.client.impl; -import cn.hezhaohui.entity.Weather; +import cn.hezhaohui.pojo.entity.Weather; import cn.hezhaohui.lark.client.WeatherClient; import cn.hutool.http.HttpUtil; import cn.hutool.json.JSONUtil; diff --git a/lark/src/main/java/cn/hezhaohui/lark/handler/EventListener.java b/lark/src/main/java/cn/hezhaohui/lark/handler/EventListener.java index ab5dd13..392fa56 100644 --- a/lark/src/main/java/cn/hezhaohui/lark/handler/EventListener.java +++ b/lark/src/main/java/cn/hezhaohui/lark/handler/EventListener.java @@ -2,7 +2,7 @@ package cn.hezhaohui.lark.handler; import cn.hezhaohui.common.AppConstant; import cn.hezhaohui.common.CardEnum; -import cn.hezhaohui.entity.Weather; +import cn.hezhaohui.pojo.entity.Weather; import cn.hezhaohui.lark.client.WeatherClient; import cn.hezhaohui.lark.util.BeanUtil; import cn.hezhaohui.lark.util.LarkUtil; diff --git a/lark/src/main/java/cn/hezhaohui/lark/service/MovieService.java b/lark/src/main/java/cn/hezhaohui/lark/service/MovieService.java new file mode 100644 index 0000000..a78b2ba --- /dev/null +++ b/lark/src/main/java/cn/hezhaohui/lark/service/MovieService.java @@ -0,0 +1,30 @@ +package cn.hezhaohui.lark.service; + +import cn.hezhaohui.lark.client.MovieClient; +import cn.hezhaohui.pojo.dto.MovieDTO; +import cn.hezhaohui.pojo.vo.MovieVO; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; + +@Service +public class MovieService { + + @Resource + private MovieClient movieClient; + + public List listMovies() { + List movieDTOS = movieClient.listMovies(); + List movieVOS = new ArrayList<>(); + for (MovieDTO movieDTO : movieDTOS) { + MovieVO movieVO = new MovieVO(); + movieVO.setName(movieDTO.getName()); + movieVO.setDate(new SimpleDateFormat("yyyy-MM-dd").format(movieDTO.getDay())); + movieVOS.add(movieVO); + } + return movieVOS; + } +} diff --git a/lark/src/test/java/cn/hezhaohui/lark/client/impl/MovieClientImplTest.java b/lark/src/test/java/cn/hezhaohui/lark/client/impl/MovieClientImplTest.java new file mode 100644 index 0000000..1f1d33b --- /dev/null +++ b/lark/src/test/java/cn/hezhaohui/lark/client/impl/MovieClientImplTest.java @@ -0,0 +1,24 @@ +package cn.hezhaohui.lark.client.impl; + +import cn.hezhaohui.pojo.dto.MovieDTO; +import cn.hezhaohui.lark.client.MovieClient; +import jakarta.annotation.Resource; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +import java.util.List; + +@SpringBootTest +class MovieClientImplTest { + + @Resource + private MovieClient movieClient; + + @Test + void listMovies() { + List movieDTOS = movieClient.listMovies(); + for(MovieDTO movieDTO : movieDTOS) { + System.out.println(movieDTO); + } + } +} \ No newline at end of file diff --git a/lark/src/test/java/cn/hezhaohui/lark/client/impl/WeatherClientImplTest.java b/lark/src/test/java/cn/hezhaohui/lark/client/impl/WeatherClientImplTest.java index dc7dd4d..5dbf01f 100644 --- a/lark/src/test/java/cn/hezhaohui/lark/client/impl/WeatherClientImplTest.java +++ b/lark/src/test/java/cn/hezhaohui/lark/client/impl/WeatherClientImplTest.java @@ -1,6 +1,6 @@ package cn.hezhaohui.lark.client.impl; -import cn.hezhaohui.entity.Weather; +import cn.hezhaohui.pojo.entity.Weather; import cn.hezhaohui.lark.client.WeatherClient; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; diff --git a/lark/src/test/java/cn/hezhaohui/lark/service/MovieServiceTest.java b/lark/src/test/java/cn/hezhaohui/lark/service/MovieServiceTest.java new file mode 100644 index 0000000..4672960 --- /dev/null +++ b/lark/src/test/java/cn/hezhaohui/lark/service/MovieServiceTest.java @@ -0,0 +1,25 @@ +package cn.hezhaohui.lark.service; + +import cn.hezhaohui.pojo.vo.MovieVO; +import jakarta.annotation.Resource; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +import java.util.List; + +import static org.junit.jupiter.api.Assertions.*; + +@SpringBootTest +class MovieServiceTest { + + @Resource + private MovieService movieService; + + @Test + void listMovies() { + List movies = movieService.listMovies(); + for (MovieVO movie : movies) { + System.out.println(movie); + } + } +} \ No newline at end of file diff --git a/lark/src/test/java/cn/hezhaohui/lark/util/LarkUtilTest.java b/lark/src/test/java/cn/hezhaohui/lark/util/LarkUtilTest.java index 2a26088..823ec29 100644 --- a/lark/src/test/java/cn/hezhaohui/lark/util/LarkUtilTest.java +++ b/lark/src/test/java/cn/hezhaohui/lark/util/LarkUtilTest.java @@ -2,7 +2,7 @@ package cn.hezhaohui.lark.util; import cn.hezhaohui.lark.client.WeatherClient; import cn.hezhaohui.common.CardEnum; -import cn.hezhaohui.entity.Weather; +import cn.hezhaohui.pojo.entity.Weather; import jakarta.annotation.Resource; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; diff --git a/movie/init.sql b/movie/init.sql new file mode 100644 index 0000000..0fb6d4b --- /dev/null +++ b/movie/init.sql @@ -0,0 +1,9 @@ +CREATE DATABASE IF NOT EXISTS panel; + +USE panel; + +CREATE TABLE IF NOT EXISTS movie ( + id INT AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(255) NOT NULL, + day DATE NOT NULL +); \ No newline at end of file diff --git a/movie/pom.xml b/movie/pom.xml new file mode 100644 index 0000000..200ca6b --- /dev/null +++ b/movie/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + + cn.hezhaohui + lark-panel + 1.0.0 + + + movie + + + + org.springframework.boot + spring-boot-starter-web + + + com.baomidou + mybatis-plus-spring-boot3-starter + + + com.mysql + mysql-connector-j + + + cn.hezhaohui + common + 1.0.0 + + + org.projectlombok + lombok + + + org.springframework.boot + spring-boot-starter-test + + + + + 21 + 21 + UTF-8 + + + \ No newline at end of file diff --git a/movie/src/main/java/cn/hezhaohui/movie/MovieApplication.java b/movie/src/main/java/cn/hezhaohui/movie/MovieApplication.java new file mode 100644 index 0000000..f151b92 --- /dev/null +++ b/movie/src/main/java/cn/hezhaohui/movie/MovieApplication.java @@ -0,0 +1,14 @@ +package cn.hezhaohui.movie; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +@MapperScan("cn.hezhaohui.movie.mapper") +public class MovieApplication { + public static void main(String[] args) { + SpringApplication.run(MovieApplication.class, args); + } + +} diff --git a/movie/src/main/java/cn/hezhaohui/movie/controller/MovieController.java b/movie/src/main/java/cn/hezhaohui/movie/controller/MovieController.java new file mode 100644 index 0000000..54d5e89 --- /dev/null +++ b/movie/src/main/java/cn/hezhaohui/movie/controller/MovieController.java @@ -0,0 +1,25 @@ +package cn.hezhaohui.movie.controller; + +import cn.hezhaohui.movie.entity.Movie; +import cn.hezhaohui.movie.service.MovieService; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import jakarta.annotation.Resource; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +@RequestMapping("movie") +public class MovieController { + + @Resource + private MovieService movieService; + + @GetMapping + public List getMovieList(){ + return movieService.list(new QueryWrapper().orderByDesc("id")); + } + +} diff --git a/movie/src/main/java/cn/hezhaohui/movie/entity/Movie.java b/movie/src/main/java/cn/hezhaohui/movie/entity/Movie.java new file mode 100644 index 0000000..66d2883 --- /dev/null +++ b/movie/src/main/java/cn/hezhaohui/movie/entity/Movie.java @@ -0,0 +1,71 @@ +package cn.hezhaohui.movie.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.util.Date; +import lombok.Data; + +/** + * + * @TableName movie + */ +@TableName(value ="movie") +@Data +public class Movie { + /** + * + */ + @TableId(type = IdType.AUTO) + private Integer id; + + /** + * + */ + private String name; + + /** + * + */ + private Date day; + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + Movie other = (Movie) that; + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName())) + && (this.getDay() == null ? other.getDay() == null : this.getDay().equals(other.getDay())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getName() == null) ? 0 : getName().hashCode()); + result = prime * result + ((getDay() == null) ? 0 : getDay().hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", name=").append(name); + sb.append(", day=").append(day); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/movie/src/main/java/cn/hezhaohui/movie/mapper/MovieMapper.java b/movie/src/main/java/cn/hezhaohui/movie/mapper/MovieMapper.java new file mode 100644 index 0000000..530c84e --- /dev/null +++ b/movie/src/main/java/cn/hezhaohui/movie/mapper/MovieMapper.java @@ -0,0 +1,18 @@ +package cn.hezhaohui.movie.mapper; + +import cn.hezhaohui.movie.entity.Movie; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author 23117 +* @description 针对表【movie】的数据库操作Mapper +* @createDate 2025-10-30 19:52:48 +* @Entity cn.hezhaohui.movie.entity.Movie +*/ +public interface MovieMapper extends BaseMapper { + +} + + + + diff --git a/movie/src/main/java/cn/hezhaohui/movie/service/MovieService.java b/movie/src/main/java/cn/hezhaohui/movie/service/MovieService.java new file mode 100644 index 0000000..7720810 --- /dev/null +++ b/movie/src/main/java/cn/hezhaohui/movie/service/MovieService.java @@ -0,0 +1,13 @@ +package cn.hezhaohui.movie.service; + +import cn.hezhaohui.movie.entity.Movie; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author 23117 +* @description 针对表【movie】的数据库操作Service +* @createDate 2025-10-30 19:52:48 +*/ +public interface MovieService extends IService { + +} diff --git a/movie/src/main/java/cn/hezhaohui/movie/service/impl/MovieServiceImpl.java b/movie/src/main/java/cn/hezhaohui/movie/service/impl/MovieServiceImpl.java new file mode 100644 index 0000000..0248f79 --- /dev/null +++ b/movie/src/main/java/cn/hezhaohui/movie/service/impl/MovieServiceImpl.java @@ -0,0 +1,22 @@ +package cn.hezhaohui.movie.service.impl; + +import cn.hezhaohui.movie.entity.Movie; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import cn.hezhaohui.movie.service.MovieService; +import cn.hezhaohui.movie.mapper.MovieMapper; +import org.springframework.stereotype.Service; + +/** +* @author 23117 +* @description 针对表【movie】的数据库操作Service实现 +* @createDate 2025-10-30 19:52:48 +*/ +@Service +public class MovieServiceImpl extends ServiceImpl + implements MovieService{ + +} + + + + diff --git a/movie/src/main/resources/application.yml b/movie/src/main/resources/application.yml new file mode 100644 index 0000000..c63e069 --- /dev/null +++ b/movie/src/main/resources/application.yml @@ -0,0 +1,8 @@ +spring: + datasource: + username: root + password: dn293830 + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://47.121.181.112:3306/panel +server: + port: 8081 \ No newline at end of file diff --git a/movie/src/main/resources/cn/hezhaohui/movie/mapper/MovieMapper.xml b/movie/src/main/resources/cn/hezhaohui/movie/mapper/MovieMapper.xml new file mode 100644 index 0000000..747ea1e --- /dev/null +++ b/movie/src/main/resources/cn/hezhaohui/movie/mapper/MovieMapper.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + id,name,day + + diff --git a/movie/src/test/java/cn/hezhaohui/movie/service/impl/MovieServiceImplTest.java b/movie/src/test/java/cn/hezhaohui/movie/service/impl/MovieServiceImplTest.java new file mode 100644 index 0000000..74ec33b --- /dev/null +++ b/movie/src/test/java/cn/hezhaohui/movie/service/impl/MovieServiceImplTest.java @@ -0,0 +1,25 @@ +package cn.hezhaohui.movie.service.impl; + + +import cn.hezhaohui.movie.entity.Movie; +import cn.hezhaohui.movie.service.MovieService; +import jakarta.annotation.Resource; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +import java.util.List; + +@SpringBootTest +class MovieServiceImplTest { + + + @Resource + private MovieService movieService; + + @Test + void getMovies() { + List list = movieService.list(); + System.out.println(list); + } + +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index ddae592..e21a59f 100644 --- a/pom.xml +++ b/pom.xml @@ -16,6 +16,7 @@ lark weather common + movie @@ -38,6 +39,16 @@ hutool-all 5.8.9 + + com.baomidou + mybatis-plus-spring-boot3-starter + 3.5.14 + + + com.mysql + mysql-connector-j + 8.3.0 + diff --git a/weather/src/main/java/cn/hezhaohui/weather/controller/WeatherController.java b/weather/src/main/java/cn/hezhaohui/weather/controller/WeatherController.java index 2a07192..aa3bca1 100644 --- a/weather/src/main/java/cn/hezhaohui/weather/controller/WeatherController.java +++ b/weather/src/main/java/cn/hezhaohui/weather/controller/WeatherController.java @@ -1,6 +1,6 @@ package cn.hezhaohui.weather.controller; -import cn.hezhaohui.entity.Weather; +import cn.hezhaohui.pojo.entity.Weather; import cn.hezhaohui.weather.util.WeatherUtil; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/weather/src/main/java/cn/hezhaohui/weather/util/WeatherUtil.java b/weather/src/main/java/cn/hezhaohui/weather/util/WeatherUtil.java index 9344276..f46c083 100644 --- a/weather/src/main/java/cn/hezhaohui/weather/util/WeatherUtil.java +++ b/weather/src/main/java/cn/hezhaohui/weather/util/WeatherUtil.java @@ -1,7 +1,7 @@ package cn.hezhaohui.weather.util; import cn.hezhaohui.common.AIConstant; -import cn.hezhaohui.entity.Weather; +import cn.hezhaohui.pojo.entity.Weather; import cn.hezhaohui.weather.service.ChatService; import cn.hutool.http.HttpUtil; import cn.hutool.json.JSONObject; diff --git a/weather/src/test/java/cn/hezhaohui/weather/util/WeatherUtilTest.java b/weather/src/test/java/cn/hezhaohui/weather/util/WeatherUtilTest.java index d47a81a..11314af 100644 --- a/weather/src/test/java/cn/hezhaohui/weather/util/WeatherUtilTest.java +++ b/weather/src/test/java/cn/hezhaohui/weather/util/WeatherUtilTest.java @@ -1,6 +1,6 @@ package cn.hezhaohui.weather.util; -import cn.hezhaohui.entity.Weather; +import cn.hezhaohui.pojo.entity.Weather; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest;