임산물현황 추가 팝업까지 + 값체크.

This commit is contained in:
주우성
2025-06-15 12:55:33 +09:00
parent 9723b58aa9
commit ecf5b83bba
39 changed files with 1257 additions and 85 deletions

View File

@@ -16,7 +16,6 @@ class GetMonthlyInputStatusDao implements GetMonthlyInputStatusPortOut {
private final GetMonthlyInputStatusMapper mapper;
@Override
@Transactional
public Optional<GetMonthlyInputStatus> operate(GetMonthlyInputStatusCmd command) {
GetMonthlyInputStatus secArticle = mapper.getMonthlyInputStatus(command);
@@ -24,4 +23,7 @@ class GetMonthlyInputStatusDao implements GetMonthlyInputStatusPortOut {
return Optional.of(secArticle);
}
}

View File

@@ -9,4 +9,5 @@ public interface GetMonthlyInputStatusMapper {
GetMonthlyInputStatus getMonthlyInputStatus(GetMonthlyInputStatusCmd command);
}

View File

@@ -8,4 +8,5 @@ import java.util.Optional;
public interface GetMonthlyInputStatusPortIn {
Optional<GetMonthlyInputStatus> operate(GetMonthlyInputStatusCmd command);
}

View File

@@ -8,4 +8,5 @@ import java.util.Optional;
public interface GetMonthlyInputStatusPortOut {
Optional<GetMonthlyInputStatus> operate(GetMonthlyInputStatusCmd command);
}

View File

@@ -24,4 +24,12 @@ public class GetMonthlyInputStatus {
private String createdBy;
private LocalDateTime updatedAt;
private String updatedBy;
public String getKoreanMonth() {
if (month != null && month.contains("-")) {
String[] parts = month.split("-");
return parts[0] + "년 " + Integer.parseInt(parts[1]) + "월";
}
return "";
}
}

View File

@@ -11,4 +11,5 @@ import lombok.Setter;
@EqualsAndHashCode
public class GetMonthlyInputStatusCmd {
private Long id;
private Long householdSeq;
}

View File

@@ -0,0 +1,28 @@
package app.module.core.usecase.monthly.getPrevMonthlyInputStatus.adapters.persistence;
import app.module.core.usecase.monthly.getPrevMonthlyInputStatus.ports.GetPrevMonthlyInputStatusPortOut;
import app.module.core.usecase.monthly.getPrevMonthlyInputStatus.ports.application.domain.GetPrevMonthlyInputStatus;
import app.module.core.usecase.monthly.getPrevMonthlyInputStatus.ports.application.domain.GetPrevMonthlyInputStatusCmd;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
import java.util.Optional;
@Repository
@RequiredArgsConstructor
class GetPrevMonthlyInputStatusDao implements GetPrevMonthlyInputStatusPortOut {
private final GetPrevMonthlyInputStatusMapper mapper;
@Override
public Optional<GetPrevMonthlyInputStatus> operate(GetPrevMonthlyInputStatusCmd command) {
GetPrevMonthlyInputStatus secArticle = mapper.getPrevMonthlyInputStatus(command);
return Optional.ofNullable(secArticle);
}
}

View File

@@ -0,0 +1,13 @@
package app.module.core.usecase.monthly.getPrevMonthlyInputStatus.adapters.persistence;
import app.module.core.usecase.monthly.getPrevMonthlyInputStatus.ports.application.domain.GetPrevMonthlyInputStatus;
import app.module.core.usecase.monthly.getPrevMonthlyInputStatus.ports.application.domain.GetPrevMonthlyInputStatusCmd;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface GetPrevMonthlyInputStatusMapper {
GetPrevMonthlyInputStatus getPrevMonthlyInputStatus(GetPrevMonthlyInputStatusCmd command);
}

View File

@@ -0,0 +1,12 @@
package app.module.core.usecase.monthly.getPrevMonthlyInputStatus.ports;
import app.module.core.usecase.monthly.getPrevMonthlyInputStatus.ports.application.domain.GetPrevMonthlyInputStatus;
import app.module.core.usecase.monthly.getPrevMonthlyInputStatus.ports.application.domain.GetPrevMonthlyInputStatusCmd;
import java.util.Optional;
public interface GetPrevMonthlyInputStatusPortIn {
Optional<GetPrevMonthlyInputStatus> operate(GetPrevMonthlyInputStatusCmd command);
}

View File

@@ -0,0 +1,12 @@
package app.module.core.usecase.monthly.getPrevMonthlyInputStatus.ports;
import app.module.core.usecase.monthly.getPrevMonthlyInputStatus.ports.application.domain.GetPrevMonthlyInputStatus;
import app.module.core.usecase.monthly.getPrevMonthlyInputStatus.ports.application.domain.GetPrevMonthlyInputStatusCmd;
import java.util.Optional;
public interface GetPrevMonthlyInputStatusPortOut {
Optional<GetPrevMonthlyInputStatus> operate(GetPrevMonthlyInputStatusCmd command);
}

View File

@@ -0,0 +1,22 @@
package app.module.core.usecase.monthly.getPrevMonthlyInputStatus.ports.application;
import app.module.core.usecase.monthly.getPrevMonthlyInputStatus.ports.GetPrevMonthlyInputStatusPortIn;
import app.module.core.usecase.monthly.getPrevMonthlyInputStatus.ports.GetPrevMonthlyInputStatusPortOut;
import app.module.core.usecase.monthly.getPrevMonthlyInputStatus.ports.application.domain.GetPrevMonthlyInputStatus;
import app.module.core.usecase.monthly.getPrevMonthlyInputStatus.ports.application.domain.GetPrevMonthlyInputStatusCmd;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.Optional;
@Service
@RequiredArgsConstructor
class GetPrevMonthlyInputStatusService implements GetPrevMonthlyInputStatusPortIn {
private final GetPrevMonthlyInputStatusPortOut portOut;
@Override
public Optional<GetPrevMonthlyInputStatus> operate(GetPrevMonthlyInputStatusCmd command) {
return portOut.operate(command);
}
}

View File

@@ -0,0 +1,26 @@
package app.module.core.usecase.monthly.getPrevMonthlyInputStatus.ports.application.domain;
import app.module.core.config.application.enums.MonthStatus;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.time.LocalDateTime;
@Getter
@Setter
@NoArgsConstructor
@EqualsAndHashCode
public class GetPrevMonthlyInputStatus {
private Long id;
private Long householdSeq;
private String month;
private MonthStatus forestProductStatus;
private MonthStatus bankAutoTransferStatus;
private LocalDateTime createdAt;
private String createdBy;
private LocalDateTime updatedAt;
private String updatedBy;
}

View File

@@ -0,0 +1,15 @@
package app.module.core.usecase.monthly.getPrevMonthlyInputStatus.ports.application.domain;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetPrevMonthlyInputStatusCmd {
private Long id;
private Long householdSeq;
}

View File

@@ -24,7 +24,6 @@ class GetForestProductsDao implements GetForestProductsPortOut {
private final GetForestProductsMapper mapper;
@Override
@Transactional
public Page<GetForestProducts> operate(Pageable pageable, GetForestProductsCmd command) {
// 게시물 목록 얻기
List<GetForestProductsDto> contents =
@@ -63,63 +62,4 @@ class GetForestProductsDao implements GetForestProductsPortOut {
contents.isEmpty() ? 0 : contents.get(0).getTotal());
}
@Override
@Transactional
public List<GetForestProducts> operateList(GetForestProductsCmd command) {
/*// 검색조건 초기화
Specification<Article> spec = (root, query, criteriaBuilder) -> null;
// 검색어 - like 검색
if (!StringUtils.isEmpty(command.getSearchField())) {
spec =
spec.and(
(root, query, builder) ->
builder.like(
root.get(command.getSearchField()),
"%" + command.getSearchValue() + "%"));
}
// 공개여부 검색
if (!StringUtils.isEmpty(command.getSearchOpen())) {
spec =
spec.and(
((root, query, criteriaBuilder) ->
criteriaBuilder.equal(
root.get("visible"), Boolean.valueOf(command.getSearchOpen()))));
}
List<Article> result = getArticlesRepo.findAll(spec);
return result.stream()
.map(
article ->
new GetArticles(
article.getId(),
article.getUpdatedBy(),
article.getUpdatedAt(),
article.getTitle(),
article.getContent(),
article.getVisible(),
article.getStartDate(),
article.getEndDate(),
article.getOrderNo(),
article.getUploadFiles().stream()
// 목록에 보여줄 대표이미지만 담는다
.filter(
uploadFile -> uploadFile.getType()
.equals(FileUploadType.EXAMPLE_REP))
.map(
uploadFile ->
new GetArticleFiles(
uploadFile.getId(),
uploadFile.getType(),
uploadFile.getPath(),
uploadFile.getName(),
uploadFile.getOriginName(),
uploadFile.getFileLength()))
.findFirst()
.orElse(null)))
.collect(Collectors.toList());*/
return null;
}
}

View File

@@ -13,4 +13,5 @@ public interface GetForestProductsMapper {
List<GetForestProductsDto> getForestProducts(
@Param("pageable") Pageable pageable, @Param("cmd") GetForestProductsCmd cmd);
}

View File

@@ -11,5 +11,4 @@ public interface GetForestProductsPortIn {
Page<GetForestProducts> operate(Pageable pageable, GetForestProductsCmd command);
List<GetForestProducts> operateList(GetForestProductsCmd command);
}

View File

@@ -11,5 +11,4 @@ public interface GetForestProductsPortOut {
Page<GetForestProducts> operate(Pageable pageable, GetForestProductsCmd command);
List<GetForestProducts> operateList(GetForestProductsCmd command);
}

View File

@@ -22,8 +22,4 @@ class GetForestProductsService implements GetForestProductsPortIn {
return portOut.operate(pageable, command);
}
@Override
public List<GetForestProducts> operateList(GetForestProductsCmd command) {
return portOut.operateList(command);
}
}

View File

@@ -0,0 +1,62 @@
package app.module.core.usecase.product.getMonthlyForestProducts.adapters.persistence;
import app.module.core.usecase.product.getMonthlyForestProducts.adapters.persistence.model.GetMonthlyForestProductsDto;
import app.module.core.usecase.product.getMonthlyForestProducts.ports.GetMonthlyForestProductsPortOut;
import app.module.core.usecase.product.getMonthlyForestProducts.ports.application.domain.GetMonthlyForestProducts;
import app.module.core.usecase.product.getMonthlyForestProducts.ports.application.domain.GetMonthlyForestProductsCmd;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.ListUtils;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.stream.Collectors;
@Repository
@RequiredArgsConstructor
class GetMonthlyForestProductsDao implements GetMonthlyForestProductsPortOut {
private final GetMonthlyForestProductsMapper mapper;
@Override
public Page<GetMonthlyForestProducts> operate(Pageable pageable, GetMonthlyForestProductsCmd command) {
// 게시물 목록 얻기
List<GetMonthlyForestProductsDto> contents =
ListUtils.emptyIfNull(mapper.getMonthlyForestProducts(pageable, command));
return new PageImpl<>(
contents.stream()
.map(
article ->
new GetMonthlyForestProducts(
article.getId(),
article.getHouseholdSeq(),
article.getStreetNum(),
article.getLandType(),
article.getTown(),
article.getAvailableArea(),
article.getCropName(),
article.getCropCode(),
article.getLandArea(),
article.getMonth(),
article.getMainYield(),
article.getMainYieldUnitCode(),
article.getMainSaleAmount(),
article.getMainSaleUnitCode(),
article.getSubYield(),
article.getSubYieldUnitCode(),
article.getSubSaleAmount(),
article.getSubSaleUnitCode(),
article.getMonthlyInputStatusId(),
article.getCreatedAt(),
article.getCreatedBy(),
article.getUpdatedAt(),
article.getUpdatedBy()))
.collect(Collectors.toList()),
pageable,
contents.isEmpty() ? 0 : contents.get(0).getTotal());
}
}

View File

@@ -0,0 +1,17 @@
package app.module.core.usecase.product.getMonthlyForestProducts.adapters.persistence;
import app.module.core.usecase.product.getMonthlyForestProducts.adapters.persistence.model.GetMonthlyForestProductsDto;
import app.module.core.usecase.product.getMonthlyForestProducts.ports.application.domain.GetMonthlyForestProductsCmd;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Pageable;
import java.util.List;
@Mapper
public interface GetMonthlyForestProductsMapper {
List<GetMonthlyForestProductsDto> getMonthlyForestProducts(
@Param("pageable") Pageable pageable, @Param("cmd") GetMonthlyForestProductsCmd cmd);
}

View File

@@ -0,0 +1,47 @@
package app.module.core.usecase.product.getMonthlyForestProducts.adapters.persistence.model;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Getter
@Setter
@AllArgsConstructor
public class GetMonthlyForestProductsDto {
private Long id;
private Long householdSeq;
private String streetNum;
private String landType;
private String town;
private Integer availableArea;
private String cropName;
private String cropCode;
private Integer landArea;
private String month;
private BigDecimal mainYield;
private String mainYieldUnitCode;
private BigDecimal mainSaleAmount;
private String mainSaleUnitCode;
private BigDecimal subYield;
private String subYieldUnitCode;
private BigDecimal subSaleAmount;
private String subSaleUnitCode;
private Long monthlyInputStatusId;
private LocalDateTime createdAt;
private String createdBy;
private LocalDateTime updatedAt;
private String updatedBy;
private Long total;
}

View File

@@ -0,0 +1,12 @@
package app.module.core.usecase.product.getMonthlyForestProducts.ports;
import app.module.core.usecase.product.getMonthlyForestProducts.ports.application.domain.GetMonthlyForestProducts;
import app.module.core.usecase.product.getMonthlyForestProducts.ports.application.domain.GetMonthlyForestProductsCmd;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
public interface GetMonthlyForestProductsPortIn {
Page<GetMonthlyForestProducts> operate(Pageable pageable, GetMonthlyForestProductsCmd command);
}

View File

@@ -0,0 +1,12 @@
package app.module.core.usecase.product.getMonthlyForestProducts.ports;
import app.module.core.usecase.product.getMonthlyForestProducts.ports.application.domain.GetMonthlyForestProducts;
import app.module.core.usecase.product.getMonthlyForestProducts.ports.application.domain.GetMonthlyForestProductsCmd;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
public interface GetMonthlyForestProductsPortOut {
Page<GetMonthlyForestProducts> operate(Pageable pageable, GetMonthlyForestProductsCmd command);
}

View File

@@ -0,0 +1,23 @@
package app.module.core.usecase.product.getMonthlyForestProducts.ports.application;
import app.module.core.usecase.product.getMonthlyForestProducts.ports.GetMonthlyForestProductsPortIn;
import app.module.core.usecase.product.getMonthlyForestProducts.ports.GetMonthlyForestProductsPortOut;
import app.module.core.usecase.product.getMonthlyForestProducts.ports.application.domain.GetMonthlyForestProducts;
import app.module.core.usecase.product.getMonthlyForestProducts.ports.application.domain.GetMonthlyForestProductsCmd;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
class GetMonthlyForestProductsService implements GetMonthlyForestProductsPortIn {
private final GetMonthlyForestProductsPortOut portOut;
@Override
public Page<GetMonthlyForestProducts> operate(Pageable pageable, GetMonthlyForestProductsCmd command) {
return portOut.operate(pageable, command);
}
}

View File

@@ -0,0 +1,47 @@
package app.module.core.usecase.product.getMonthlyForestProducts.ports.application.domain;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetMonthlyForestProducts {
private Long id;
private Long householdSeq;
private String streetNum;
private String landType;
private String town;
private Integer availableArea;
private String cropName;
private String cropCode;
private Integer landArea;
private String month;
private BigDecimal mainYield;
private String mainYieldUnitCode;
private BigDecimal mainSaleAmount;
private String mainSaleUnitCode;
private BigDecimal subYield;
private String subYieldUnitCode;
private BigDecimal subSaleAmount;
private String subSaleUnitCode;
private Long monthlyInputStatusId;
private LocalDateTime createdAt;
private String createdBy;
private LocalDateTime updatedAt;
private String updatedBy;
}

View File

@@ -0,0 +1,16 @@
package app.module.core.usecase.product.getMonthlyForestProducts.ports.application.domain;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetMonthlyForestProductsCmd {
private Long monthlyInputStatusId;
private Long householdSeq;
}

View File

@@ -20,6 +20,9 @@
FROM monthly_input_status a
WHERE a.id = #{id}
AND a.is_deleted = false
<if test="householdSeq != null">
AND a.household_seq = #{householdSeq}
</if>
</if>
</select>

View File

@@ -0,0 +1,33 @@
<?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="app.module.core.usecase.monthly.getPrevMonthlyInputStatus.adapters.persistence.GetPrevMonthlyInputStatusMapper">
<select id="getPrevMonthlyInputStatus"
resultType="app.module.core.usecase.monthly.getPrevMonthlyInputStatus.ports.application.domain.GetPrevMonthlyInputStatus">
<if test="id != null">
SELECT
a.id AS id,
a.household_seq AS householdSeq,
a.month AS month,
a.forest_product_status AS forestProductStatus,
a.bank_auto_transfer_status AS bankAutoTransferStatus,
a.created_at AS createdAt,
a.created_by AS createdBy,
a.updated_at AS updatedAt,
a.updated_by AS updatedBy
FROM monthly_input_status a
WHERE a.is_deleted = false
AND a.forest_product_status != 'NONE'
AND a.household_seq = #{householdSeq}
AND a.month = (
SELECT TO_CHAR(TO_DATE(month, 'YYYY-MM') - INTERVAL '1 month', 'YYYY-MM')
FROM monthly_input_status
WHERE is_deleted = false AND id = #{id}
);
</if>
</select>
</mapper>

View File

@@ -70,4 +70,9 @@
</if>
</select>
</mapper>

View File

@@ -0,0 +1,71 @@
<?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="app.module.core.usecase.product.getMonthlyForestProducts.adapters.persistence.GetMonthlyForestProductsMapper">
<select id="getMonthlyForestProducts"
resultType="app.module.core.usecase.product.getMonthlyForestProducts.adapters.persistence.model.GetMonthlyForestProductsDto">
/* getForestProducts : 게시물 리스트 */
SELECT
a.id AS id,
a.household_seq AS householdSeq,
a.street_num AS streetNum,
a.land_type AS landType,
a.town AS town,
a.available_area AS availableArea,
a.crop_name AS cropName,
a.crop_code AS cropCode,
a.land_area AS landArea,
a.month AS month,
a.main_yield AS mainYield,
a.main_yield_unit_code AS mainYieldUnitCode,
a.main_sale_amount AS mainSaleAmount,
a.main_sale_unit_code AS mainSaleUnitCode,
a.sub_yield AS subYield,
a.sub_yield_unit_code AS subYieldUnitCode,
a.sub_sale_amount AS subSaleAmount,
a.sub_sale_unit_code AS subSaleUnitCode,
a.monthly_input_status_id AS monthlyInputStatusId,
a.created_at AS createdAt,
a.created_by AS createdBy,
a.updated_at AS updatedAt,
a.updated_by AS updatedBy,
COUNT(*) OVER () AS total
FROM forest_product a
WHERE a.is_deleted = false
<if test="cmd.monthlyInputStatusId != null">
AND a.monthly_input_status_id = #{cmd.monthlyInputStatusId}
</if>
<if test="cmd.householdSeq != null">
AND a.household_seq = #{cmd.householdSeq}
</if>
<if test="pageable.sort != null and !pageable.sort.isEmpty()">
ORDER BY
<foreach collection="pageable.sort" item="order" separator=",">
<choose>
<when test="order.property eq 'household'">a.household_seq</when>
<when test="order.property eq 'updatedBy'">a.updated_by</when>
<when test="order.property eq 'updatedAt'">a.updated_at</when>
<when test="order.property eq 'createdBy'">a.created_by</when>
<when test="order.property eq 'createdAt'">a.created_at</when>
<otherwise>a.id</otherwise>
</choose>
<choose>
<when test="order.direction.toString() eq 'DESC'">DESC</when>
<otherwise>ASC</otherwise>
</choose>
</foreach>
OFFSET #{pageable.offset} ROWS FETCH NEXT #{pageable.pageSize} ROWS ONLY
</if>
</select>
</mapper>