Compare commits

..

16 Commits

Author SHA1 Message Date
a70fe6c9ef feat:增加汽车事件模块 2026-07-20 23:17:40 +08:00
69df40a47d feat:更新物品返回数据类型 2026-05-21 22:04:30 +08:00
fe89d3cc85 feat:更新旅游景点排序规则 2026-04-06 22:14:59 +08:00
20aa820794 feat:增加证书排序 2026-04-02 23:09:48 +08:00
17b20a3d4b feat:增加奖状证书模块 2026-04-01 23:24:30 +08:00
638a1a9186 feat:删除日志 2026-03-15 23:12:54 +08:00
1a4b1a8639 feat:更新计算睡眠时长 2026-03-15 23:12:26 +08:00
1b56f33a02 feat:增加搜索美食接口 2026-02-12 17:26:37 +08:00
fb4ec4a50f fix:修复名称拼写错误 2026-02-04 22:22:31 +08:00
20da1e064b feat:更新上传文件接口 2026-02-03 23:17:00 +08:00
3e83adf4f8 feat:增加AList上传文件功能 2026-02-02 22:55:20 +08:00
fcaef1409d feat:增加健康模块睡眠时间存储 2025-11-17 19:58:07 +08:00
ea8d6cfa12 feat:增加账单搜索接口 2025-11-10 19:51:28 +08:00
4cbf49d2a3 feat:去除部分健康记录接口 2025-11-04 22:34:57 +08:00
f9d01b7b36 feat:增加运动健康接口 2025-11-04 20:05:01 +08:00
c8d2bd1df0 feat:增加月经日期统计 2025-10-30 15:00:00 +08:00
110 changed files with 1646 additions and 197 deletions

View File

@@ -38,6 +38,13 @@
<groupId>cn.hutool</groupId>
<artifactId>hutool-crypto</artifactId>
</dependency>
<!-- Jave 2 视频处理库 -->
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-all-deps</artifactId>
<version>3.5.0</version>
</dependency>
</dependencies>
<build>

View File

@@ -0,0 +1,15 @@
package com.cxx.home.config;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@ConfigurationProperties(prefix = "alist")
@Getter
@Setter
public class AListProperties {
private String username;
private String password;
}

View File

@@ -0,0 +1,25 @@
package com.cxx.home.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.web.client.RestClient;
@Configuration
public class RestClientConfig {
final String baseUrl = "http://192.168.1.7:5244/";
@Bean
public RestClient aListClient() {
return RestClient.builder()
// 基础RURL
.baseUrl(baseUrl)
// 默认请求头 请求体为JSON格式
.defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
// 默认请求头 响应体为JSON格式
.defaultHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)
.build();
}
}

View File

@@ -3,7 +3,7 @@ package com.cxx.home.controller;
import com.cxx.common.ReadView;
import com.cxx.common.WriteView;
import com.cxx.common.dto.StatsChartDto;
import com.cxx.home.dto.anniversary.AnniversaryDto;
import com.cxx.home.dto.AnniversaryDto;
import com.cxx.home.service.AnniversaryService;
import com.fasterxml.jackson.annotation.JsonView;
import io.swagger.v3.oas.annotations.Operation;

View File

@@ -2,7 +2,7 @@ package com.cxx.home.controller;
import com.cxx.common.ReadView;
import com.cxx.common.WriteView;
import com.cxx.home.dto.asset.AssetDto;
import com.cxx.home.dto.AssetDto;
import com.cxx.home.service.AssetService;
import com.fasterxml.jackson.annotation.JsonView;
import io.swagger.v3.oas.annotations.Operation;

View File

@@ -0,0 +1,20 @@
package com.cxx.home.controller;
import cn.dev33.satoken.stp.StpUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/auth")
@Tag(name = "认证")
public class AuthController {
@Operation(summary = "查询在线人数")
@GetMapping("/online")
public List<String> queryOnline() {
return StpUtil.searchSessionId("", 0, -1, true);
}
}

View File

@@ -0,0 +1,55 @@
package com.cxx.home.controller;
import com.cxx.common.ReadView;
import com.cxx.common.WriteView;
import com.cxx.home.dto.AwardDto;
import com.cxx.home.service.AwardService;
import com.cxx.home.vo.AwardQueryVo;
import com.fasterxml.jackson.annotation.JsonView;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/award")
@Tag(name = "证书奖状")
public class AwardController {
@Resource
private AwardService awardService;
@Operation(summary = "新增证书奖状")
@PostMapping("")
public Boolean addAward(@RequestBody @JsonView(WriteView.class) @Validated AwardDto dto) {
return awardService.addAward(dto);
}
@Operation(summary = "更新证书奖状")
@PutMapping("/{id}")
public Boolean updateAward(@PathVariable("id") long id,
@RequestBody @JsonView(WriteView.class) @Validated AwardDto dto) {
return awardService.updateAward(id, dto);
}
@Operation(summary = "删除证书奖状")
@DeleteMapping("/{id}")
public Boolean deleteAward(@PathVariable("id") long id) {
return awardService.deleteAward(id);
}
@Operation(summary = "查询所有证书奖状")
@GetMapping("")
public @JsonView(ReadView.class) List<AwardDto> queryAwardList(AwardQueryVo vo) {
return awardService.queryAwardList(vo);
}
@Operation(summary = "查询证书奖状")
@GetMapping("/{id}")
public @JsonView(ReadView.class) AwardDto queryAward(@PathVariable("id") long id) {
return awardService.queryAward(id);
}
}

View File

@@ -9,6 +9,7 @@ import com.cxx.home.dto.bill.BillRecordDto;
import com.cxx.home.dto.bill.BillSummaryDto;
import com.cxx.home.service.BillRecordService;
import com.cxx.home.vo.BillQueryVo;
import com.cxx.home.vo.BillSearchVo;
import com.fasterxml.jackson.annotation.JsonView;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -55,6 +56,12 @@ public class BillController {
return billRecordService.queryBillSummary(billQueryVo);
}
@Operation(summary = "搜索账单概要")
@GetMapping("/search")
public @JsonView(ReadView.class) List<BillSummaryDto> searchBillSummary(BillSearchVo billSearchVo) {
return billRecordService.searchBillSummary(billSearchVo);
}
@Operation(summary = "查询账单统计")
@GetMapping("/stats/{type}")
public List<StatsChartDto> queryBillStats(@PathVariable("type") String type, BillQueryVo billQueryVo) {

View File

@@ -0,0 +1,49 @@
package com.cxx.home.controller;
import com.cxx.common.ReadView;
import com.cxx.common.WriteView;
import com.cxx.home.dto.CarEventDto;
import com.cxx.home.service.CarEventService;
import com.cxx.home.vo.CarQueryVo;
import com.fasterxml.jackson.annotation.JsonView;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/car")
@Tag(name = "汽车事件")
public class CarEventController {
@Resource
private CarEventService carEventService;
@Operation(summary = "新增汽车事件")
@PostMapping("")
public Boolean addCarEvent(@RequestBody @JsonView(WriteView.class) @Validated CarEventDto dto) {
return carEventService.addCarEvent(dto);
}
@Operation(summary = "更新汽车事件")
@PutMapping("/{id}")
public Boolean updateCarEvent(@PathVariable("id") long id,
@RequestBody @JsonView(WriteView.class) @Validated CarEventDto dto) {
return carEventService.updateCarEvent(id, dto);
}
@Operation(summary = "删除汽车事件")
@DeleteMapping("/{id}")
public Boolean deleteCarEvent(@PathVariable("id") long id) {
return carEventService.deleteCarEvent(id);
}
@Operation(summary = "查询所有汽车事件")
@GetMapping("")
public @JsonView(ReadView.class) List<CarEventDto> queryCarEventList(CarQueryVo query) {
return carEventService.queryCarEventList(query);
}
}

View File

@@ -4,6 +4,7 @@ import com.cxx.home.dto.file.ChunkInfoDto;
import com.cxx.home.dto.file.ChunkResultDto;
import com.cxx.home.dto.file.FileInfoDto;
import com.cxx.home.dto.file.FileRecordDto;
import com.cxx.home.service.AListService;
import com.cxx.home.service.FileService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -20,6 +21,9 @@ public class FileController {
@Resource
private FileService fileService;
@Resource
private AListService aListService;
@Operation(summary = "上传文件")
@PostMapping(value = "", headers = "content-type=multipart/form-data")
public FileRecordDto uploadFile(@RequestPart("file") MultipartFile file,
@@ -28,6 +32,13 @@ public class FileController {
return fileService.uploadFile(file, path, md5);
}
@Operation(summary = "上传aList文件")
@PostMapping(value = "/alist", consumes = "multipart/form-data")
public String uploadAListFile(@RequestParam("file") MultipartFile file,
@RequestParam("filePath") String filePath) {
return aListService.uploadFile(file, filePath);
}
@Operation(summary = "上传文件块")
@PostMapping("/chunk")
public Boolean uploadChunk(ChunkInfoDto chunkInfo,

View File

@@ -52,6 +52,12 @@ public class FoodController {
return foodService.queryFoodSummary(currentPage, pageSize, foodQueryVo);
}
@Operation(summary = "搜索美食")
@GetMapping("/recipe/search")
public FoodSummaryDto searchFood(@RequestParam("name") String name) {
return foodService.searchFood(name);
}
@Operation(summary = "查询美食")
@GetMapping("/recipe/{id}")
public @JsonView(ReadView.class) FoodRecipeDto queryFoodRecipe(@PathVariable("id") long id) {
@@ -60,8 +66,8 @@ public class FoodController {
@Operation(summary = "查询所有美食名称")
@GetMapping("/recipe/name")
public List<String> queryFoodName() {
return foodService.queryFoodName();
public List<String> queryFoodNameList() {
return foodService.queryFoodNameList();
}
@Operation(summary = "新增美食成果")

View File

@@ -0,0 +1,36 @@
package com.cxx.home.controller;
import com.cxx.common.ReadView;
import com.cxx.common.WriteView;
import com.cxx.home.dto.HealthRecordDto;
import com.cxx.home.service.HealthService;
import com.cxx.home.vo.HealthQueryVo;
import com.fasterxml.jackson.annotation.JsonView;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/health")
@Tag(name = "锻炼记录")
public class HealthController {
@Resource
private HealthService healthService;
@Operation(summary = "更新健康记录")
@PutMapping("/{id}")
public Boolean updateExercise(@PathVariable("id") long id,
@RequestBody @JsonView(WriteView.class) HealthRecordDto dto) {
return healthService.update(id, dto);
}
@Operation(summary = "查询健康记录")
@GetMapping("")
public @JsonView(ReadView.class) List<HealthRecordDto> queryExercise(HealthQueryVo queryVo) {
return healthService.query(queryVo);
}
}

View File

@@ -3,7 +3,7 @@ package com.cxx.home.controller;
import com.cxx.common.ReadView;
import com.cxx.common.WriteView;
import com.cxx.home.dto.journal.JournalDto;
import com.cxx.home.dto.JournalDto;
import com.cxx.home.service.JournalService;
import com.cxx.home.vo.JournalQueryVo;
import com.fasterxml.jackson.annotation.JsonView;

View File

@@ -2,7 +2,7 @@ package com.cxx.home.controller;
import com.cxx.common.ReadView;
import com.cxx.common.WriteView;
import com.cxx.home.dto.kpi.KpiDto;
import com.cxx.home.dto.KpiDto;
import com.cxx.home.service.KpiService;
import com.cxx.home.vo.KpiQueryVo;
import com.fasterxml.jackson.annotation.JsonView;

View File

@@ -2,7 +2,7 @@ package com.cxx.home.controller;
import com.cxx.common.ReadView;
import com.cxx.common.WriteView;
import com.cxx.home.dto.ledger.LedgerDto;
import com.cxx.home.dto.LedgerDto;
import com.cxx.home.service.LedgerService;
import com.fasterxml.jackson.annotation.JsonView;
import io.swagger.v3.oas.annotations.Operation;

View File

@@ -2,7 +2,7 @@ package com.cxx.home.controller;
import com.cxx.common.ReadView;
import com.cxx.common.WriteView;
import com.cxx.home.dto.password.PasswordDto;
import com.cxx.home.dto.PasswordDto;
import com.cxx.home.service.PasswordService;
import com.cxx.home.vo.PasswordQueryVo;
import com.fasterxml.jackson.annotation.JsonView;

View File

@@ -2,6 +2,7 @@ package com.cxx.home.controller;
import com.cxx.common.ReadView;
import com.cxx.common.WriteView;
import com.cxx.home.dto.period.MenstrualPeriodDto;
import com.cxx.home.dto.period.PeriodDayDto;
import com.cxx.home.dto.period.PeriodSettingDto;
import com.cxx.home.service.PeriodService;
@@ -39,6 +40,12 @@ public class PeriodController {
return periodService.getMenstruateFirstDate(month);
}
@Operation(summary = "获取月经周期天数")
@GetMapping("/menstruate/days")
public List<MenstrualPeriodDto> getMenstrualPeriod() {
return periodService.getMenstrualPeriod();
}
@Operation(summary = "查询月经设置")
@GetMapping("/setting")
public @JsonView(ReadView.class) PeriodSettingDto queryPeriodSetting() {

View File

@@ -1,9 +1,8 @@
package com.cxx.home.controller;
import com.cxx.common.ReadView;
import com.cxx.common.WriteView;
import com.cxx.home.dto.product.ProductDto;
import com.cxx.home.dto.ProductDto;
import com.cxx.home.service.ProductService;
import com.cxx.home.vo.ProductQueryVo;
import com.fasterxml.jackson.annotation.JsonView;

View File

@@ -0,0 +1,18 @@
package com.cxx.home.converter;
import com.cxx.home.dto.AwardDto;
import com.cxx.home.entity.Award;
import org.mapstruct.Mapper;
import java.util.List;
@Mapper(componentModel = "spring")
public interface AwardConverter {
Award toEntity(AwardDto dto);
List<Award> toEntities(List<AwardDto> dto);
AwardDto toDto(Award entities);
List<AwardDto> toDtos(List<Award> entities);
}

View File

@@ -0,0 +1,18 @@
package com.cxx.home.converter;
import com.cxx.home.dto.CarEventDto;
import com.cxx.home.entity.CarEvent;
import org.mapstruct.Mapper;
import java.util.List;
@Mapper(componentModel = "spring")
public interface CarEventConverter {
CarEvent toEntity(CarEventDto dto);
List<CarEvent> toEntities(List<CarEventDto> dto);
CarEventDto toDto(CarEvent entities);
List<CarEventDto> toDtos(List<CarEvent> entities);
}

View File

@@ -0,0 +1,18 @@
package com.cxx.home.converter;
import com.cxx.home.dto.HealthRecordDto;
import com.cxx.home.entity.HealthRecord;
import org.mapstruct.Mapper;
import java.util.List;
@Mapper(componentModel = "spring")
public interface HealthConverter {
HealthRecord toEntity(HealthRecordDto dto);
List<HealthRecord> toEntities(List<HealthRecordDto> dto);
HealthRecordDto toDto(HealthRecord entities);
List<HealthRecordDto> toDtos(List<HealthRecord> entities);
}

View File

@@ -0,0 +1,18 @@
package com.cxx.home.converter;
import com.cxx.home.dto.JournalDto;
import com.cxx.home.entity.Journal;
import org.mapstruct.Mapper;
import java.util.List;
@Mapper(componentModel = "spring")
public interface JournalConverter {
Journal toEntity(JournalDto dto);
List<Journal> toEntities(List<JournalDto> dto);
JournalDto toDto(Journal entities);
List<JournalDto> toDtos(List<Journal> entities);
}

View File

@@ -0,0 +1,18 @@
package com.cxx.home.converter;
import com.cxx.home.dto.KpiDto;
import com.cxx.home.entity.Kpi;
import org.mapstruct.Mapper;
import java.util.List;
@Mapper(componentModel = "spring")
public interface KpiConverter {
Kpi toEntity(KpiDto dto);
List<Kpi> toEntities(List<KpiDto> dto);
KpiDto toDto(Kpi entities);
List<KpiDto> toDtos(List<Kpi> entities);
}

View File

@@ -0,0 +1,18 @@
package com.cxx.home.converter;
import com.cxx.home.dto.ProductDto;
import com.cxx.home.entity.Product;
import org.mapstruct.Mapper;
import java.util.List;
@Mapper(componentModel = "spring")
public interface ProductConverter {
Product toEntity(ProductDto dto);
List<Product> toEntities(List<ProductDto> dto);
ProductDto toDto(Product entities);
List<ProductDto> toDtos(List<Product> entities);
}

View File

@@ -1,7 +1,7 @@
package com.cxx.home.dao;
import com.cxx.common.dto.StatsChartDto;
import com.cxx.home.dto.anniversary.AnniversaryDto;
import com.cxx.home.dto.AnniversaryDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

View File

@@ -1,6 +1,6 @@
package com.cxx.home.dao;
import com.cxx.home.dto.asset.AssetDto;
import com.cxx.home.dto.AssetDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

View File

@@ -0,0 +1,16 @@
package com.cxx.home.dao;
import com.cxx.home.dto.AwardDto;
import com.cxx.home.vo.AwardQueryVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface AwardDao {
List<AwardDto> queryAwardList(@Param("query") AwardQueryVo query);
void insertAwardImage(@Param("awardId") Long awardId,
@Param("list") List<String> imageFiles);
}

View File

@@ -6,6 +6,7 @@ import com.cxx.home.dto.bill.BillItemDto;
import com.cxx.home.dto.bill.BillRecordDto;
import com.cxx.home.dto.bill.BillSummaryDto;
import com.cxx.home.vo.BillQueryVo;
import com.cxx.home.vo.BillSearchVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -17,6 +18,8 @@ public interface BillDao {
List<BillSummaryDto> queryBillSummary(@Param("query") BillQueryVo query);
List<BillSummaryDto> searchBillSummary(@Param("query") BillSearchVo search);
void insertBillImage(@Param("billId") Long billId,
@Param("list") List<String> imageFiles);

View File

@@ -0,0 +1,13 @@
package com.cxx.home.dao;
import com.cxx.home.dto.CarEventDto;
import com.cxx.home.vo.CarQueryVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface CarEventDao {
List<CarEventDto> queryCarEventList(@Param("query") CarQueryVo queryVo);
}

View File

@@ -15,6 +15,8 @@ public interface FoodDao {
IPage<FoodSummaryDto> queryFoodSummary(IPage<FoodSummaryDto> page,
@Param("query") FoodQueryVo foodQueryVo);
FoodSummaryDto searchFoodSummary(@Param("name") String name);
List<FoodRecordDto> queryFoodRecordById(@Param("id") Long id);
List<FoodRecordDto> queryFoodRecord(@Param("startDate") String startDate,

View File

@@ -1,6 +1,6 @@
package com.cxx.home.dao;
import com.cxx.home.dto.journal.JournalDto;
import com.cxx.home.dto.JournalDto;
import com.cxx.home.vo.JournalQueryVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

View File

@@ -1,13 +0,0 @@
package com.cxx.home.dao;
import com.cxx.home.dto.kpi.KpiDto;
import com.cxx.home.vo.KpiQueryVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface KpiDao {
List<KpiDto> queryKpi(@Param("query") KpiQueryVo queryVo);
}

View File

@@ -1,6 +1,6 @@
package com.cxx.home.dao;
import com.cxx.home.dto.ledger.LedgerDto;
import com.cxx.home.dto.LedgerDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

View File

@@ -1,6 +1,6 @@
package com.cxx.home.dao;
import com.cxx.home.dto.password.PasswordDto;
import com.cxx.home.dto.PasswordDto;
import com.cxx.home.vo.PasswordQueryVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -9,7 +9,7 @@ import java.util.List;
@Mapper
public interface PasswordDao {
List<PasswordDto> query(@Param("query") PasswordQueryVo query);
List<PasswordDto> queryPasswordList(@Param("query") PasswordQueryVo query);
List<String> queryCategory();
}

View File

@@ -1,6 +1,6 @@
package com.cxx.home.dao;
import com.cxx.home.dto.product.ProductDto;
import com.cxx.home.dto.ProductDto;
import com.cxx.home.vo.ProductQueryVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -9,9 +9,5 @@ import java.util.List;
@Mapper
public interface ProductDao {
ProductDto queryProduct(@Param("id") Long id);
List<ProductDto> queryProductList(@Param("query") ProductQueryVo queryVo);
List<String> queryProductCategory();
}

View File

@@ -1,4 +1,4 @@
package com.cxx.home.dto.anniversary;
package com.cxx.home.dto;
import com.cxx.common.PlainView;
import com.cxx.common.ReadView;

View File

@@ -1,4 +1,4 @@
package com.cxx.home.dto.asset;
package com.cxx.home.dto;
import com.cxx.common.PlainView;
import com.cxx.common.ReadView;

View File

@@ -0,0 +1,43 @@
package com.cxx.home.dto;
import com.cxx.common.PlainView;
import com.cxx.common.ReadView;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonView;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
import java.util.List;
@Getter
@Setter
@JsonView(PlainView.class)
public class AwardDto {
@Schema(description = "id")
@JsonView(ReadView.class)
private Long id;
@Schema(description = "名称")
private String name;
@Schema(description = "类型")
private String type;
@Schema(description = "日期")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date date;
@Schema(description = "地点")
private String location;
@Schema(description = "所属人")
private String owner;
@Schema(description = "备注")
private String remark;
@Schema(description = "图片路径")
private List<String> imageList;
}

View File

@@ -0,0 +1,53 @@
package com.cxx.home.dto;
import com.cxx.common.PlainView;
import com.cxx.common.ReadView;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonView;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.PositiveOrZero;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDate;
@Getter
@Setter
@JsonView(PlainView.class)
public class CarEventDto {
@Schema(description = "id")
@JsonView(ReadView.class)
private Long id;
@Schema(description = "名称")
@NotBlank(message = "汽车名称不能为空")
private String name;
@Schema(description = "类型")
private String type;
@Schema(description = "日期")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private LocalDate date;
@Schema(description = "当前里程")
@PositiveOrZero(message = "里程必须大于等于0")
private Integer mileage;
@Schema(description = "cost")
@PositiveOrZero(message = "花费必须大于等于0")
private Integer cost;
@Schema(description = "地点")
private String location;
@Schema(description = "描述")
private String description;
@Schema(description = "图片路径")
private String imageUrl;
@Schema(description = "备注")
private String remark;
}

View File

@@ -0,0 +1,45 @@
package com.cxx.home.dto;
import com.cxx.common.PlainView;
import com.cxx.common.ReadView;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonView;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDate;
import java.time.LocalTime;
@Getter
@Setter
@JsonView(PlainView.class)
public class HealthRecordDto {
@Schema(description = "id")
@JsonView(ReadView.class)
private Long id;
@Schema(description = "运行项目")
private String sportProject;
@Schema(description = "运动时长")
private Integer sportDuration;
@Schema(description = "体重")
private Double weight;
@Schema(description = "睡眠开始时间")
@JsonFormat(pattern = "HH:mm", timezone = "GMT+8")
private LocalTime sleepStartTime;
@Schema(description = "睡眠结束时间")
@JsonFormat(pattern = "HH:mm", timezone = "GMT+8")
private LocalTime sleepEndTime;
@Schema(description = "睡眠时长")
private Double sleepDuration;
@Schema(description = "记录日期")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private LocalDate date;
}

View File

@@ -1,4 +1,4 @@
package com.cxx.home.dto.journal;
package com.cxx.home.dto;
import com.cxx.common.PlainView;
import com.cxx.common.ReadView;

View File

@@ -1,4 +1,4 @@
package com.cxx.home.dto.kpi;
package com.cxx.home.dto;
import com.cxx.common.PlainView;
import com.cxx.common.ReadView;

View File

@@ -1,4 +1,4 @@
package com.cxx.home.dto.ledger;
package com.cxx.home.dto;
import com.cxx.common.PlainView;
import com.cxx.common.ReadView;

View File

@@ -1,4 +1,4 @@
package com.cxx.home.dto.password;
package com.cxx.home.dto;
import com.cxx.common.PlainView;
import com.cxx.common.ReadView;

View File

@@ -1,4 +1,4 @@
package com.cxx.home.dto.product;
package com.cxx.home.dto;
import com.cxx.common.PlainView;
import com.cxx.common.ReadView;
@@ -32,18 +32,10 @@ public class ProductDto {
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date expiryDate;
@Schema(description = "总天数")
@JsonView(ReadView.class)
private Integer totalDay;
@Schema(description = "价格")
@PositiveOrZero(message = "商品价格必须大于等于0")
private Double price;
@Schema(description = "日均价格")
@JsonView(ReadView.class)
private Double averagePrice;
@Schema(description = "类别")
private String category;

View File

@@ -0,0 +1,11 @@
package com.cxx.home.dto.alist;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class AListLogin {
private String username;
private String password;
}

View File

@@ -0,0 +1,13 @@
package com.cxx.home.dto.period;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.time.LocalDate;
@Data
@AllArgsConstructor
public class MenstrualPeriodDto {
private LocalDate startDate;
private LocalDate endDate;
}

View File

@@ -8,7 +8,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
import java.time.LocalDate;
@Getter
@Setter
@@ -20,7 +20,7 @@ public class PeriodDayDto {
@Schema(description = "日期")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date date;
private LocalDate date;
@Schema(description = "是否吃药")
private Boolean isDrug;

View File

@@ -0,0 +1,32 @@
package com.cxx.home.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cxx.framework.data.AbstractEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("award")
public class Award extends AbstractEntity {
@TableField("name")
private String name;
@TableField("type")
private String type;
@TableField("date")
private Date date;
@TableField("location")
private String location;
@TableField("owner")
private String owner;
@TableField("remark")
private String remark;
}

View File

@@ -0,0 +1,15 @@
package com.cxx.home.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName("award_image")
public class AwardImage {
@TableField("award_id")
private Long awardId;
@TableField("image_url")
private String imageUrl;
}

View File

@@ -0,0 +1,41 @@
package com.cxx.home.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cxx.framework.data.AbstractEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDate;
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("car_event")
public class CarEvent extends AbstractEntity {
@TableField(value = "name")
private String name;
@TableField("type")
private String type;
@TableField("date")
private LocalDate date;
@TableField("mileage")
private Integer mileage;
@TableField("cost")
private Integer cost;
@TableField("location")
private String location;
@TableField("description")
private String description;
@TableField("image_url")
private String imageUrl;
@TableField("remark")
private String remark;
}

View File

@@ -0,0 +1,37 @@
package com.cxx.home.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cxx.framework.data.AbstractEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("health_record")
public class HealthRecord extends AbstractEntity {
@TableField("sport_project")
private String sportProject;
@TableField("sport_duration")
private Integer sportDuration;
@TableField("weight")
private Double weight;
@TableField("sleep_start_time")
private LocalTime sleepStartTime;
@TableField("sleep_end_time")
private LocalTime sleepEndTime;
@TableField("sleep_duration")
private Double sleepDuration;
@TableField("date")
private LocalDate date;
}

View File

@@ -34,8 +34,8 @@ public class Ledger extends AbstractEntity {
@TableField("provider")
private String provider;
@TableField("imager_url")
private String imagerUrl;
@TableField("image_url")
private String imageUrl;
@TableField("remark")
private String remark;

View File

@@ -6,14 +6,14 @@ import com.cxx.framework.data.AbstractEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import java.time.LocalDate;
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("period_day")
public class PeriodDay extends AbstractEntity {
@TableField("date")
private Date date;
private LocalDate date;
@TableField("is_drug")
private Integer isDrug;

View File

@@ -0,0 +1,9 @@
package com.cxx.home.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cxx.home.entity.AwardImage;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface AwardImageMapper extends BaseMapper<AwardImage> {
}

View File

@@ -0,0 +1,9 @@
package com.cxx.home.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cxx.home.entity.Award;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface AwardMapper extends BaseMapper<Award> {
}

View File

@@ -0,0 +1,9 @@
package com.cxx.home.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cxx.home.entity.CarEvent;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CarEventMapper extends BaseMapper<CarEvent> {
}

View File

@@ -0,0 +1,9 @@
package com.cxx.home.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cxx.home.entity.HealthRecord;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface HealthRecordMapper extends BaseMapper<HealthRecord> {
}

View File

@@ -0,0 +1,7 @@
package com.cxx.home.service;
import org.springframework.web.multipart.MultipartFile;
public interface AListService {
String uploadFile(MultipartFile file, String filePath);
}

View File

@@ -1,7 +1,7 @@
package com.cxx.home.service;
import com.cxx.common.dto.StatsChartDto;
import com.cxx.home.dto.anniversary.AnniversaryDto;
import com.cxx.home.dto.AnniversaryDto;
import java.util.List;

View File

@@ -1,6 +1,6 @@
package com.cxx.home.service;
import com.cxx.home.dto.asset.AssetDto;
import com.cxx.home.dto.AssetDto;
import java.util.List;

View File

@@ -0,0 +1,18 @@
package com.cxx.home.service;
import com.cxx.home.dto.AwardDto;
import com.cxx.home.vo.AwardQueryVo;
import java.util.List;
public interface AwardService {
Boolean addAward(AwardDto dto);
Boolean updateAward(Long id, AwardDto dto);
Boolean deleteAward(Long id);
AwardDto queryAward(Long id);
List<AwardDto> queryAwardList(AwardQueryVo vo);
}

View File

@@ -6,6 +6,7 @@ import com.cxx.home.dto.bill.BillItemDto;
import com.cxx.home.dto.bill.BillRecordDto;
import com.cxx.home.dto.bill.BillSummaryDto;
import com.cxx.home.vo.BillQueryVo;
import com.cxx.home.vo.BillSearchVo;
import java.util.List;
@@ -18,6 +19,8 @@ public interface BillRecordService {
List<BillSummaryDto> queryBillSummary(BillQueryVo billQueryVo);
List<BillSummaryDto> searchBillSummary(BillSearchVo searchVo);
List<StatsChartDto> queryBillStats(String type, BillQueryVo billQueryVo);
List<BillItemDto> queryBillPay();

View File

@@ -0,0 +1,17 @@
package com.cxx.home.service;
import com.cxx.home.dto.CarEventDto;
import com.cxx.home.vo.CarQueryVo;
import java.util.List;
public interface CarEventService {
Boolean addCarEvent(CarEventDto dto);
Boolean updateCarEvent(Long id, CarEventDto dto);
Boolean deleteCarEvent(Long id);
List<CarEventDto> queryCarEventList(CarQueryVo query);
}

View File

@@ -27,9 +27,11 @@ public interface FoodService {
IPage<FoodSummaryDto> queryFoodSummary(Integer currentPage, Integer pageSize, FoodQueryVo foodQueryVo);
FoodSummaryDto searchFood(String name);
List<FoodRecordDto> queryFoodRecord(String startDate, String endDate);
List<String> queryFoodName();
List<String> queryFoodNameList();
List<String> queryFoodCategory();

View File

@@ -0,0 +1,13 @@
package com.cxx.home.service;
import com.cxx.home.dto.HealthRecordDto;
import com.cxx.home.vo.HealthQueryVo;
import java.util.List;
public interface HealthService {
List<HealthRecordDto> query(HealthQueryVo queryVo);
Boolean update(Long id, HealthRecordDto dto);
}

View File

@@ -1,6 +1,6 @@
package com.cxx.home.service;
import com.cxx.home.dto.journal.JournalDto;
import com.cxx.home.dto.JournalDto;
import com.cxx.home.vo.JournalQueryVo;
import java.util.List;

View File

@@ -1,6 +1,6 @@
package com.cxx.home.service;
import com.cxx.home.dto.kpi.KpiDto;
import com.cxx.home.dto.KpiDto;
import com.cxx.home.vo.KpiQueryVo;
import java.util.List;

View File

@@ -1,6 +1,6 @@
package com.cxx.home.service;
import com.cxx.home.dto.ledger.LedgerDto;
import com.cxx.home.dto.LedgerDto;
import java.util.List;

View File

@@ -1,6 +1,6 @@
package com.cxx.home.service;
import com.cxx.home.dto.password.PasswordDto;
import com.cxx.home.dto.PasswordDto;
import com.cxx.home.vo.PasswordQueryVo;
import java.util.List;

View File

@@ -1,5 +1,6 @@
package com.cxx.home.service;
import com.cxx.home.dto.period.MenstrualPeriodDto;
import com.cxx.home.dto.period.PeriodDayDto;
import com.cxx.home.dto.period.PeriodSettingDto;
@@ -15,4 +16,6 @@ public interface PeriodService {
Boolean updatePeriodSetting(Long id, PeriodSettingDto periodSettingDto);
PeriodSettingDto queryPeriodSetting();
List<MenstrualPeriodDto> getMenstrualPeriod();
}

View File

@@ -1,15 +1,15 @@
package com.cxx.home.service;
import com.cxx.home.dto.product.ProductDto;
import com.cxx.home.dto.ProductDto;
import com.cxx.home.vo.ProductQueryVo;
import java.util.List;
public interface ProductService {
Boolean addProduct(ProductDto productDto);
Boolean addProduct(ProductDto dto);
Boolean updateProduct(Long id, ProductDto productDto);
Boolean updateProduct(Long id, ProductDto dto);
Boolean deleteProduct(Long id);

View File

@@ -0,0 +1,101 @@
package com.cxx.home.service.impl;
import com.cxx.framework.web.CustomException;
import com.cxx.home.config.AListProperties;
import com.cxx.home.dto.alist.AListLogin;
import com.cxx.home.service.AListService;
import com.cxx.home.util.VideoCompressor;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestClient;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
@Service
@Slf4j
public class AListServiceImpl implements AListService {
@Resource
private RestClient aListClient;
@Resource
private AListProperties aListProperties;
private String getAccessToken() {
AListLogin aListLogin = new AListLogin();
aListLogin.setUsername(aListProperties.getUsername());
aListLogin.setPassword(aListProperties.getPassword());
Map<String, Object> response = aListClient.post()
.uri("api/auth/login")
.body(aListLogin)
.retrieve()
.body(Map.class);
if (response == null) {
throw new CustomException("AList登录失败 请联系管理员");
}
HashMap<String, Object> data = (HashMap<String, Object>) response.get("data");
return (String) data.get("token");
}
@Override
public String uploadFile(MultipartFile file, String filePath) {
try {
String token = getAccessToken();
MultiValueMap<String, Object> body = new LinkedMultiValueMap<>();
File tempFile = convertMultipartFileToFile(file);
log.info("临时文件地址:{}", tempFile.toPath());
log.info("开始压缩文件:{}", tempFile.getName());
File compressFile = VideoCompressor.compressTo720p(tempFile);
log.info("完成压缩文件:{}", tempFile.getName());
log.info("压缩文件地址:{}", tempFile.toPath());
body.add("file", new FileSystemResource(compressFile));
aListClient.put()
.uri("api/fs/form")
.header(HttpHeaders.AUTHORIZATION, token)
.header("File-Path", filePath)
.contentType(MediaType.MULTIPART_FORM_DATA)
.body(body)
.retrieve()
.body(Map.class);
Files.deleteIfExists(compressFile.toPath());
Files.deleteIfExists(tempFile.toPath());
return filePath;
} catch (Exception e) {
log.error("文件上传失败{}", e.getMessage());
throw new RuntimeException("文件上传失败", e);
}
}
private File convertMultipartFileToFile(MultipartFile file) throws IOException {
String suffix = (file.getOriginalFilename() != null && file.getOriginalFilename().contains("."))
? file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."))
: ".tmp";
Path tempFile = Files.createTempFile(System.currentTimeMillis() + "", suffix);
file.transferTo(tempFile);
return tempFile.toFile();
}
}

View File

@@ -3,7 +3,7 @@ package com.cxx.home.service.impl;
import com.cxx.common.dto.StatsChartDto;
import com.cxx.framework.web.CustomException;
import com.cxx.home.dao.AnniversaryDao;
import com.cxx.home.dto.anniversary.AnniversaryDto;
import com.cxx.home.dto.AnniversaryDto;
import com.cxx.home.entity.Anniversary;
import com.cxx.home.mapper.AnniversaryMapper;
import com.cxx.home.service.AnniversaryService;
@@ -21,7 +21,6 @@ public class AnniversaryServiceImpl implements AnniversaryService {
@Resource
private AnniversaryMapper anniversaryMapper;
@Override
public Boolean addAnniversary(AnniversaryDto anniversaryDto) {
Anniversary anniversary = new Anniversary();

View File

@@ -2,7 +2,7 @@ package com.cxx.home.service.impl;
import com.cxx.framework.web.CustomException;
import com.cxx.home.dao.AssetDao;
import com.cxx.home.dto.asset.AssetDto;
import com.cxx.home.dto.AssetDto;
import com.cxx.home.entity.Asset;
import com.cxx.home.mapper.AssetMapper;
import com.cxx.home.service.AssetService;

View File

@@ -0,0 +1,93 @@
package com.cxx.home.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.cxx.framework.web.CustomException;
import com.cxx.home.converter.AwardConverter;
import com.cxx.home.dao.AwardDao;
import com.cxx.home.dto.AwardDto;
import com.cxx.home.entity.Award;
import com.cxx.home.entity.AwardImage;
import com.cxx.home.mapper.AwardImageMapper;
import com.cxx.home.mapper.AwardMapper;
import com.cxx.home.service.AwardService;
import com.cxx.home.vo.AwardQueryVo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class AwardServiceImpl implements AwardService {
@Resource
private AwardDao awardDao;
@Resource
private AwardMapper awardMapper;
@Resource
private AwardImageMapper awardImageMapper;
@Resource
private AwardConverter awardConverter;
@Override
@Transactional
public Boolean addAward(AwardDto dto) {
Award award = awardConverter.toEntity(dto);
awardMapper.insert(award);
insertAwardImage(award.getId(), dto.getImageList());
return Boolean.TRUE;
}
@Override
@Transactional
public Boolean updateAward(Long id, AwardDto dto) {
if (awardMapper.selectById(id) == null) {
throw new CustomException("该证书不存在");
}
Award award = awardConverter.toEntity(dto);
award.setId(id);
awardMapper.updateById(award);
deleteAwardImage(id);
insertAwardImage(id, dto.getImageList());
return Boolean.TRUE;
}
@Override
@Transactional
public Boolean deleteAward(Long id) {
return awardMapper.deleteById(id) == 1;
}
@Override
public AwardDto queryAward(Long id) {
if (awardMapper.selectById(id) == null) {
throw new CustomException("该证书不存在");
}
return awardConverter.toDto(awardMapper.selectById(id));
}
@Override
public List<AwardDto> queryAwardList(AwardQueryVo vo) {
return awardDao.queryAwardList(vo);
}
private void insertAwardImage(Long awardId, List<String> imageList) {
if (!imageList.isEmpty()) {
awardDao.insertAwardImage(awardId, imageList);
}
}
private void deleteAwardImage(Long id) {
awardImageMapper.delete(Wrappers.lambdaQuery(AwardImage.class).eq(AwardImage::getAwardId, id));
}
}

View File

@@ -13,10 +13,13 @@ import com.cxx.framework.web.CustomException;
import com.cxx.home.dao.BillDao;
import com.cxx.home.service.BillRecordService;
import com.cxx.home.vo.BillQueryVo;
import com.cxx.home.vo.BillSearchVo;
import jakarta.annotation.Resource;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
@@ -131,6 +134,16 @@ public class BillRecordServiceImpl implements BillRecordService {
return billDao.queryBillSummary(billQuery);
}
@Override
public List<BillSummaryDto> searchBillSummary(BillSearchVo billSearch) {
if (billSearch.getContent().isEmpty()
&& billSearch.getCategory().isEmpty()
&& billSearch.getLocation().isEmpty()) {
return Collections.emptyList();
}
return billDao.searchBillSummary(billSearch);
}
@Override
public List<StatsChartDto> queryBillStats(String type, BillQueryVo billQuery) {
return billDao.queryBillStats(type, billQuery);

View File

@@ -0,0 +1,56 @@
package com.cxx.home.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.cxx.home.converter.CarEventConverter;
import com.cxx.home.dao.CarEventDao;
import com.cxx.home.dto.CarEventDto;
import com.cxx.home.entity.CarEvent;
import com.cxx.home.mapper.CarEventMapper;
import com.cxx.home.service.CarEventService;
import com.cxx.home.vo.CarQueryVo;
import jakarta.annotation.Resource;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class CarEventServiceImpl implements CarEventService {
@Resource
private CarEventMapper carEventMapper;
@Resource
private CarEventConverter carEventConverter;
@Resource
private CarEventDao carEventDao;
@Override
@Transactional
public Boolean addCarEvent(CarEventDto dto) {
CarEvent carEvent = new CarEvent();
BeanUtils.copyProperties(dto, carEvent);
return carEventMapper.insert(carEvent) == 1;
}
@Override
@Transactional
public Boolean updateCarEvent(Long id, CarEventDto dto) {
CarEvent carEvent = new CarEvent();
BeanUtils.copyProperties(dto, carEvent);
carEvent.setId(id);
return carEventMapper.updateById(carEvent) == 1;
}
@Override
@Transactional
public Boolean deleteCarEvent(Long id) {
return carEventMapper.deleteById(id) == 1;
}
@Override
public List<CarEventDto> queryCarEventList(CarQueryVo query) {
return carEventDao.queryCarEventList(query);
}
}

View File

@@ -90,12 +90,21 @@ public class FoodServiceImpl implements FoodService {
public Boolean addFoodRecord(FoodRecordDto foodRecordDto) {
LambdaQueryWrapper<FoodRecipe> queryWrapper = new LambdaQueryWrapper<>();
FoodRecipe foodRecipe = foodRecipeMapper.selectOne(queryWrapper.eq(FoodRecipe::getName, foodRecordDto.getName()));
long recipeId;
if (foodRecipe == null) {
throw new CustomException("该菜谱不存在");
FoodRecipe newRecipe = new FoodRecipe();
newRecipe.setName(foodRecordDto.getName());
newRecipe.setCategory("其他");
newRecipe.setRecommendRate(0);
newRecipe.setRemark("");
foodRecipeMapper.insert(newRecipe);
recipeId = newRecipe.getId();
} else {
recipeId = foodRecipe.getId();
}
FoodRecord foodRecord = new FoodRecord();
foodRecord.setFoodId(foodRecipe.getId());
foodRecord.setFoodId(recipeId);
BeanUtils.copyProperties(foodRecordDto, foodRecord);
foodRecordMapper.insert(foodRecord);
@@ -177,14 +186,21 @@ public class FoodServiceImpl implements FoodService {
return foodSummaryPage;
}
@Override
public FoodSummaryDto searchFood(String name) {
FoodSummaryDto foodSummaryDto = foodDao.searchFoodSummary(name);
foodSummaryDto.setRecordList(foodDao.queryFoodRecordById(foodSummaryDto.getId()));
return foodSummaryDto;
}
@Override
public List<FoodRecordDto> queryFoodRecord(String startDate, String endDate) {
return foodDao.queryFoodRecord(startDate, endDate);
}
@Override
public List<String> queryFoodName() {
return foodRecipeMapper.selectList(null)
public List<String> queryFoodNameList() {
return foodRecipeMapper.selectList(Wrappers.emptyWrapper())
.stream().map(FoodRecipe::getName).collect(Collectors.toList());
}

View File

@@ -0,0 +1,54 @@
package com.cxx.home.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cxx.home.converter.HealthConverter;
import com.cxx.home.dto.HealthRecordDto;
import com.cxx.home.entity.HealthRecord;
import com.cxx.home.mapper.HealthRecordMapper;
import com.cxx.home.service.HealthService;
import com.cxx.home.vo.HealthQueryVo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.List;
@Service
public class HealthServiceImpl implements HealthService {
@Resource
private HealthRecordMapper healthRecordMapper;
@Resource
private HealthConverter healthConverter;
@Override
public List<HealthRecordDto> query(HealthQueryVo queryVo) {
LocalDate startDate = LocalDate.parse(queryVo.getStartDate());
LocalDate endDate = LocalDate.parse(queryVo.getEndDate());
LambdaQueryWrapper<HealthRecord> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.ge(HealthRecord::getDate, startDate)
.le(HealthRecord::getDate, endDate)
.orderByDesc(HealthRecord::getDate);
return healthConverter.toDtos(healthRecordMapper.selectList(queryWrapper));
}
@Override
public Boolean update(Long id, HealthRecordDto dto) {
if (id == 0) {
return healthRecordMapper.insert(healthConverter.toEntity(dto)) == 1;
} else {
if ((dto.getSportProject() == null || dto.getSportProject().isEmpty())
&& dto.getSleepStartTime() == null && dto.getSleepEndTime() == null
&& dto.getSportDuration() == 0 && dto.getWeight() == 0) {
return healthRecordMapper.deleteById(id) == 1;
} else {
HealthRecord healthRecord = healthConverter.toEntity(dto);
healthRecord.setId(id);
return healthRecordMapper.updateById(healthRecord) == 1;
}
}
}
}

View File

@@ -1,8 +1,10 @@
package com.cxx.home.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cxx.framework.web.CustomException;
import com.cxx.home.converter.JournalConverter;
import com.cxx.home.dao.JournalDao;
import com.cxx.home.dto.journal.JournalDto;
import com.cxx.home.dto.JournalDto;
import com.cxx.home.entity.Journal;
import com.cxx.home.mapper.JournalMapper;
import com.cxx.home.service.JournalService;
@@ -11,6 +13,7 @@ import jakarta.annotation.Resource;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.List;
@Service
@@ -21,6 +24,9 @@ public class JournalServiceImpl implements JournalService {
@Resource
private JournalMapper journalMapper;
@Resource
private JournalConverter journalConverter;
@Override
public Boolean addJournal(JournalDto journalDto) {
Journal journal = new Journal();
@@ -52,6 +58,14 @@ public class JournalServiceImpl implements JournalService {
@Override
public List<JournalDto> queryJournal(JournalQueryVo queryVo) {
return journalDao.queryJournal(queryVo);
LocalDate startDate = LocalDate.parse(queryVo.getStartDate());
LocalDate endDate = LocalDate.parse(queryVo.getEndDate());
LambdaQueryWrapper<Journal> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.ge(Journal::getDate, startDate)
.le(Journal::getDate, endDate)
.orderByDesc(Journal::getDate);
return journalConverter.toDtos(journalMapper.selectList(queryWrapper));
}
}

View File

@@ -1,8 +1,9 @@
package com.cxx.home.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cxx.framework.web.CustomException;
import com.cxx.home.dao.KpiDao;
import com.cxx.home.dto.kpi.KpiDto;
import com.cxx.home.converter.KpiConverter;
import com.cxx.home.dto.KpiDto;
import com.cxx.home.entity.Kpi;
import com.cxx.home.mapper.KpiMapper;
import com.cxx.home.service.KpiService;
@@ -11,16 +12,16 @@ import jakarta.annotation.Resource;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.List;
@Service
public class KpiServiceImpl implements KpiService {
@Resource
private KpiDao kpiDao;
@Resource
private KpiMapper kpiMapper;
@Resource
private KpiConverter kpiConverter;
@Override
public Boolean addKpi(KpiDto kpiDto) {
@@ -53,6 +54,14 @@ public class KpiServiceImpl implements KpiService {
@Override
public List<KpiDto> queryKpi(KpiQueryVo queryVo) {
return kpiDao.queryKpi(queryVo);
LocalDate startDate = LocalDate.parse(queryVo.getStartDate());
LocalDate endDate = LocalDate.parse(queryVo.getEndDate());
LambdaQueryWrapper<Kpi> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.ge(Kpi::getDate, startDate)
.le(Kpi::getDate, endDate)
.orderByDesc(Kpi::getDate);
return kpiConverter.toDtos(kpiMapper.selectList(queryWrapper));
}
}

View File

@@ -2,7 +2,7 @@ package com.cxx.home.service.impl;
import com.cxx.framework.web.CustomException;
import com.cxx.home.dao.LedgerDao;
import com.cxx.home.dto.ledger.LedgerDto;
import com.cxx.home.dto.LedgerDto;
import com.cxx.home.entity.Ledger;
import com.cxx.home.mapper.LedgerMapper;
import com.cxx.home.service.LedgerService;

View File

@@ -1,12 +1,13 @@
package com.cxx.home.service.impl;
import cn.hutool.crypto.SecureUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cxx.framework.web.CustomException;
import com.cxx.home.dao.PasswordDao;
import com.cxx.home.dto.password.PasswordDto;
import com.cxx.home.dto.PasswordDto;
import com.cxx.home.entity.Password;
import com.cxx.home.mapper.PasswordMapper;
import com.cxx.home.service.PasswordService;
import com.cxx.home.util.CommonUtils;
import com.cxx.home.vo.PasswordQueryVo;
import jakarta.annotation.Resource;
import org.springframework.beans.BeanUtils;
@@ -14,6 +15,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class PasswordServiceImpl implements PasswordService {
@@ -30,7 +32,7 @@ public class PasswordServiceImpl implements PasswordService {
public Boolean add(PasswordDto passwordDto) {
Password password = new Password();
BeanUtils.copyProperties(passwordDto, password);
password.setPassword(encryptPassword(passwordDto.getPassword()));
password.setPassword(CommonUtils.encryptPassword(secretKey, passwordDto.getPassword()));
return passwordMapper.insert(password) == 1;
}
@@ -44,7 +46,7 @@ public class PasswordServiceImpl implements PasswordService {
Password password = new Password();
BeanUtils.copyProperties(passwordDto, password);
password.setId(id);
password.setPassword(encryptPassword(passwordDto.getPassword()));
password.setPassword(CommonUtils.encryptPassword(secretKey, passwordDto.getPassword()));
return passwordMapper.updateById(password) == 1;
}
@@ -59,22 +61,17 @@ public class PasswordServiceImpl implements PasswordService {
@Override
public List<PasswordDto> query(PasswordQueryVo query) {
List<PasswordDto> passwordList = passwordDao.query(query);
List<PasswordDto> passwordList = passwordDao.queryPasswordList(query);
passwordList.forEach(item -> item.setPassword(decryptStr(item.getPassword())));
passwordList.forEach(item -> item.setPassword(CommonUtils.decryptStr(secretKey, item.getPassword())));
return passwordList;
}
@Override
public List<String > queryCategory() {
return passwordDao.queryCategory();
}
public List<String> queryCategory() {
LambdaQueryWrapper<Password> queryWrapper = new LambdaQueryWrapper<>();
List<Object> categories = passwordMapper.selectObjs(queryWrapper.select(Password::getCategory));
private String encryptPassword(String password) {
return SecureUtil.aes(secretKey.getBytes()).encryptBase64(password);
}
private String decryptStr(String password) {
return SecureUtil.aes(secretKey.getBytes()).decryptStr(password);
return categories.stream().map(Object::toString).distinct().collect(Collectors.toList());
}
}

View File

@@ -1,6 +1,8 @@
package com.cxx.home.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cxx.home.dao.PeriodDao;
import com.cxx.home.dto.period.MenstrualPeriodDto;
import com.cxx.home.dto.period.PeriodDayDto;
import com.cxx.home.dto.period.PeriodSettingDto;
import com.cxx.home.entity.PeriodDay;
@@ -13,6 +15,9 @@ import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@Service
@@ -89,16 +94,55 @@ public class PeriodServiceImpl implements PeriodService {
List<PeriodSetting> periodSettingList = periodSettingMapper.selectList(null);
PeriodSettingDto periodSettingDto = new PeriodSettingDto();
if (periodSettingList.size() > 0) {
BeanUtils.copyProperties(periodSettingList.get(0), periodSettingDto);
periodSettingDto.setIsCalculate(periodSettingList.get(0).getIsCalculate() == 1);
} else {
if (periodSettingList.isEmpty()) {
periodSettingDto.setId(0L);
periodSettingDto.setCycleLength(0);
periodSettingDto.setDuration(0);
periodSettingDto.setIsCalculate(false);
} else {
BeanUtils.copyProperties(periodSettingList.get(0), periodSettingDto);
periodSettingDto.setIsCalculate(periodSettingList.get(0).getIsCalculate() == 1);
}
return periodSettingDto;
}
@Override
public List<MenstrualPeriodDto> getMenstrualPeriod() {
LambdaQueryWrapper<PeriodDay> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PeriodDay::getIsMenstruate, 1).select(PeriodDay::getDate).orderByAsc(PeriodDay::getDate);
List<LocalDate> dates = periodDayMapper.selectList(queryWrapper)
.stream().map(PeriodDay::getDate).toList();
if (dates.isEmpty()) {
return Collections.emptyList();
}
List<MenstrualPeriodDto> result = new ArrayList<>();
LocalDate start = dates.get(0);
LocalDate end = dates.get(0);
for (int i = 1; i < dates.size(); i++) {
LocalDate current = dates.get(i);
// 如果当前日期与前一天连续,继续当前周期
if (current.equals(end.plusDays(1))) {
end = current;
} else {
// 日期不连续,保存当前周期,开始新周期
result.add(new MenstrualPeriodDto(start, end));
// 重新开始新的周期
start = current;
end = current;
}
}
// 添加最后一个周期
result.add(new MenstrualPeriodDto(start, end));
Collections.reverse(result);
return result;
}
}

View File

@@ -2,8 +2,9 @@ package com.cxx.home.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cxx.framework.web.CustomException;
import com.cxx.home.converter.ProductConverter;
import com.cxx.home.dao.ProductDao;
import com.cxx.home.dto.product.ProductDto;
import com.cxx.home.dto.ProductDto;
import com.cxx.home.entity.*;
import com.cxx.home.mapper.*;
import com.cxx.home.service.ProductService;
@@ -14,6 +15,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class ProductServiceImpl implements ProductService {
@@ -23,6 +25,9 @@ public class ProductServiceImpl implements ProductService {
@Resource
private ProductMapper productMapper;
@Resource
private ProductConverter productConverter;
@Override
@Transactional
public Boolean addProduct(ProductDto productDto) {
@@ -61,7 +66,7 @@ public class ProductServiceImpl implements ProductService {
throw new CustomException("该商品不存在");
}
return productDao.queryProduct(id);
return productConverter.toDto(productMapper.selectById(id));
}
@Override
@@ -71,6 +76,9 @@ public class ProductServiceImpl implements ProductService {
@Override
public List<String> queryProductCategory() {
return productDao.queryProductCategory();
LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>();
List<Object> categories = productMapper.selectObjs(queryWrapper.select(Product::getCategory));
return categories.stream().map(Object::toString).distinct().collect(Collectors.toList());
}
}

View File

@@ -99,8 +99,8 @@ public class TravelServiceImpl implements TravelService {
BeanUtils.copyProperties(travelRecordDto, travelRecord);
travelRecordMapper.insert(travelRecord);
insertTravelImage(travelRecord.getTravelId(), travelRecordDto.getImageList());
insertTravelVideo(travelRecord.getTravelId(), travelRecordDto.getVideoList());
insertTravelImage(travelRecord.getId(), travelRecordDto.getImageList());
insertTravelVideo(travelRecord.getId(), travelRecordDto.getVideoList());
return Boolean.TRUE;
}

View File

@@ -0,0 +1,13 @@
package com.cxx.home.util;
import cn.hutool.crypto.SecureUtil;
public class CommonUtils {
public static String encryptPassword(String secretKey, String password) {
return SecureUtil.aes(secretKey.getBytes()).encryptBase64(password);
}
public static String decryptStr(String secretKey, String password) {
return SecureUtil.aes(secretKey.getBytes()).decryptStr(password);
}
}

View File

@@ -0,0 +1,153 @@
package com.cxx.home.util;
import lombok.extern.slf4j.Slf4j;
import ws.schild.jave.Encoder;
import ws.schild.jave.MultimediaObject;
import ws.schild.jave.encode.AudioAttributes;
import ws.schild.jave.encode.EncodingAttributes;
import ws.schild.jave.encode.VideoAttributes;
import java.io.File;
/**
* 视频码率压缩工具类
* 只压缩码率,保持原始分辨率和宽高比
*/
@Slf4j
public class VideoCompressor {
// 支持的视频格式
private static final String[] SUPPORTED_FORMATS = {
".mp4", ".avi", ".mov", ".mkv", ".flv",
".wmv", ".webm", ".mpeg", ".mpg", ".3gp"
};
// 码率压缩参数
private static final int TARGET_VIDEO_BITRATE = 1500000; // 1.5 Mbps
private static final int TARGET_AUDIO_BITRATE = 128000; // 128 kbps
private static final String VIDEO_CODEC = "libx264";
private static final String AUDIO_CODEC = "aac";
private static final String OUTPUT_FORMAT = "mp4";
private static final String OUTPUT_SUFFIX = "_compressed.mp4";
// 码率判断阈值
private static final int MAX_BITRATE_THRESHOLD = 2500000; // 2.5 Mbps
private static final int MIN_BITRATE_THRESHOLD = 1000000; // 1 Mbps
/**
* 压缩视频码率,保持原始分辨率和宽高比
*
* @param inputFile 输入视频文件
* @return 压缩后的视频文件,如果不需要压缩则返回原文件
* @throws Exception 压缩过程中可能出现的异常
*/
public static File compressTo720p(File inputFile) throws Exception {
if (!isSupportedVideoFile(inputFile)) {
log.info("文件格式不支持或文件不存在,直接返回源文件");
return inputFile;
}
// 判断是否需要压缩码率
if (!needBitrateCompression(inputFile)) {
return inputFile;
}
File outputFile = createOutputFile(inputFile);
Encoder encoder = new Encoder();
// 配置编码参数
EncodingAttributes encodingAttributes = createBitrateEncodingAttributes();
log.info("开始压缩视频: {} -> {}", inputFile.getName(), outputFile.getName());
encoder.encode(new MultimediaObject(inputFile), outputFile, encodingAttributes);
log.info("视频压缩完成: {}", outputFile.getName());
return outputFile;
}
/**
* 判断视频是否需要压缩码率
*/
public static boolean needBitrateCompression(File videoFile) throws Exception {
MultimediaObject media = new MultimediaObject(videoFile);
// 获取视频基本信息
double fileSizeMB = videoFile.length() / 1048576.0;
double duration = media.getInfo().getDuration() / 1000.0;
int originalBitrate = media.getInfo().getVideo().getBitRate();
// 获取视频分辨率
int width = media.getInfo().getVideo().getSize().getWidth();
int height = media.getInfo().getVideo().getSize().getHeight();
log.info("视频分析: 分辨率 {}x{}, 大小 {}MB, 时长 {}秒, 码率 {}bps", width, height, fileSizeMB, duration, originalBitrate);
// 如果原始码率超过阈值,就需要压缩
boolean needsCompression = originalBitrate > MAX_BITRATE_THRESHOLD;
if (needsCompression) {
log.info("视频码率({}bps)超过阈值,需要压缩", originalBitrate);
} else {
log.info("视频码率({}bps)在合理范围内,无需压缩", originalBitrate);
}
return needsCompression;
}
/**
* 创建码率压缩编码配置
*/
private static EncodingAttributes createBitrateEncodingAttributes() {
// 音频配置
AudioAttributes audio = new AudioAttributes();
audio.setCodec(AUDIO_CODEC);
audio.setBitRate(TARGET_AUDIO_BITRATE);
// 视频配置
VideoAttributes video = new VideoAttributes();
video.setCodec(VIDEO_CODEC);
video.setBitRate(TARGET_VIDEO_BITRATE);
// 编码设置
EncodingAttributes attributes = new EncodingAttributes();
attributes.setOutputFormat(OUTPUT_FORMAT);
attributes.setAudioAttributes(audio);
attributes.setVideoAttributes(video);
return attributes;
}
/**
* 检查文件是否为支持的视频格式
*/
private static boolean isSupportedVideoFile(File file) {
if (file == null || !file.exists()) {
return false;
}
String filename = file.getName().toLowerCase();
for (String format : SUPPORTED_FORMATS) {
if (filename.endsWith(format)) {
return true;
}
}
return false;
}
/**
* 创建输出文件对象
*/
private static File createOutputFile(File inputFile) {
String baseName = getFileBaseName(inputFile.getName());
String outputFilename = baseName + OUTPUT_SUFFIX;
return new File(inputFile.getParent(), outputFilename);
}
/**
* 获取文件名(不含扩展名)
*/
private static String getFileBaseName(String filename) {
int dotIndex = filename.lastIndexOf('.');
return (dotIndex == -1) ? filename : filename.substring(0, dotIndex);
}
}

View File

@@ -0,0 +1,12 @@
package com.cxx.home.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class AwardQueryVo {
@Schema(description = "类型")
private String type;
}

View File

@@ -0,0 +1,18 @@
package com.cxx.home.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class BillSearchVo {
@Schema(description = "名称")
private String content;
@Schema(description = "类别")
private String category;
@Schema(description = "地址")
private String location;
}

View File

@@ -0,0 +1,12 @@
package com.cxx.home.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class CarQueryVo {
@Schema(description = "事件类别")
private String type;
}

View File

@@ -1,4 +1,3 @@
package com.cxx.home.vo;
import io.swagger.v3.oas.annotations.media.Schema;

View File

@@ -0,0 +1,15 @@
package com.cxx.home.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class HealthQueryVo {
@Schema(description = "开始日期")
private String startDate;
@Schema(description = "结束日期")
private String endDate;
}

View File

@@ -1,4 +1,3 @@
package com.cxx.home.vo;
import io.swagger.v3.oas.annotations.media.Schema;

View File

@@ -1,4 +1,3 @@
package com.cxx.home.vo;
import io.swagger.v3.oas.annotations.media.Schema;

View File

@@ -1,4 +1,3 @@
package com.cxx.home.vo;
import io.swagger.v3.oas.annotations.media.Schema;

View File

@@ -7,6 +7,10 @@ spring:
version: @project.version@
profiles:
active: dev
servlet:
multipart:
max-file-size: 500MB
max-request-size: 500MB
mail:
host: smtp.163.com
port: 465
@@ -29,10 +33,14 @@ mybatis-plus:
mapper-locations: classpath*:/mapper/**/*.xml
configuration:
log-impl:
org.apache.ibatis.logging.stdout.StdOutImpl
# org.apache.ibatis.logging.stdout.StdOutImpl
web-starter:
base-package: com.cxx.home
aes:
secret-key: "sG5p7t9wBdKnPqRsUvYx2D5F8H9JmQ=2"
alist:
username: admin
password: 19940822Cxx

View File

@@ -1,7 +1,7 @@
<?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.cxx.home.dao.AnniversaryDao">
<select id="queryAnniversary" resultType="com.cxx.home.dto.anniversary.AnniversaryDto">
<select id="queryAnniversary" resultType="com.cxx.home.dto.AnniversaryDto">
SELECT id AS id,
title AS title,
date AS date,

View File

@@ -1,7 +1,7 @@
<?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.cxx.home.dao.AssetDao">
<select id="queryAsset" resultType="com.cxx.home.dto.asset.AssetDto">
<select id="queryAsset" resultType="com.cxx.home.dto.AssetDto">
SELECT id AS id,
category AS category,
NAME AS NAME,

Some files were not shown because too many files have changed in this diff Show More