임산물 현황 CRUD Core
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<?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.createForestProduct.adapters.persistence.CreateForestProductMapper">
|
||||
|
||||
<insert id="createForestProduct" keyProperty="id">
|
||||
<!-- createForestProduct 게시글 등록 -->
|
||||
<selectKey keyProperty="id" order="BEFORE" resultType="long">
|
||||
SELECT nextval('notice_seq')
|
||||
</selectKey>
|
||||
|
||||
INSERT INTO forest_product (
|
||||
id,
|
||||
household_seq,
|
||||
street_num,
|
||||
land_type,
|
||||
town,
|
||||
available_area,
|
||||
crop_name,
|
||||
crop_code,
|
||||
land_area,
|
||||
month,
|
||||
main_yield,
|
||||
main_yield_unit_code,
|
||||
main_sale_amount,
|
||||
main_sale_unit_code,
|
||||
sub_yield,
|
||||
sub_yield_unit_code,
|
||||
sub_sale_amount,
|
||||
sub_sale_unit_code,
|
||||
created_at,
|
||||
created_by,
|
||||
updated_at,
|
||||
updated_by,
|
||||
is_deleted
|
||||
) VALUES (
|
||||
#{id},
|
||||
#{householdSeq},
|
||||
#{streetNum},
|
||||
#{landType},
|
||||
#{town},
|
||||
#{availableArea},
|
||||
#{cropName},
|
||||
#{cropCode},
|
||||
#{landArea},
|
||||
#{month},
|
||||
#{mainYield},
|
||||
#{mainYieldUnitCode},
|
||||
#{mainSaleAmount},
|
||||
#{mainSaleUnitCode},
|
||||
#{subYield},
|
||||
#{subYieldUnitCode},
|
||||
#{subSaleAmount},
|
||||
#{subSaleUnitCode},
|
||||
#{createdAt},
|
||||
#{createdBy},
|
||||
#{createdAt},
|
||||
#{createdBy},
|
||||
false
|
||||
)
|
||||
</insert>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?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.getForestProduct.adapters.persistence.GetForestProductMapper">
|
||||
<select id="getForestProduct"
|
||||
resultType="app.module.core.usecase.product.getForestProduct.ports.application.domain.GetForestProduct">
|
||||
/* getForestProduct 상세 게시글 조회 */
|
||||
<if test="id != null">
|
||||
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.created_at AS createdAt,
|
||||
a.created_by AS createdBy,
|
||||
a.updated_at AS updatedAt,
|
||||
a.updated_by AS updatedBy
|
||||
FROM forest_product a
|
||||
WHERE a.id = #{id}
|
||||
AND a.is_deleted = false
|
||||
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,72 @@
|
||||
<?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.getForestProducts.adapters.persistence.GetForestProductsMapper">
|
||||
|
||||
<select id="getForestProducts"
|
||||
resultType="app.module.core.usecase.product.getForestProducts.adapters.persistence.model.GetForestProductsDto">
|
||||
/* 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.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.searchField != null and cmd.searchField != ''">
|
||||
<choose>
|
||||
<when test="cmd.searchField eq 'month'">
|
||||
AND a.month ILIKE '%' || #{cmd.searchValue} || '%'
|
||||
</when>
|
||||
<when test="cmd.searchField eq 'household'">
|
||||
AND a.household_seq = #{cmd.searchValue}
|
||||
</when>
|
||||
<when test="cmd.searchField eq 'updatedBy'">
|
||||
AND a.updated_by ILIKE '%' || #{cmd.searchValue} || '%'
|
||||
</when>
|
||||
</choose>
|
||||
</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>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?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.removeForestProducts.adapters.persistence.RemoveForestProductsMapper">
|
||||
<update id="deleteForestProducts">
|
||||
/* deleteForestProducts : 게시물 삭제 */
|
||||
UPDATE forest_product
|
||||
SET <include refid="common.fields.DeleteBaseSet" />
|
||||
WHERE id IN
|
||||
<foreach collection="removeIds" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -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.product.updateForestProduct.adapters.persistence.UpdateForestProductMapper">
|
||||
|
||||
|
||||
|
||||
<update id="updateForestProduct">
|
||||
/* updateNotice 게시글 수정 */
|
||||
UPDATE forest_product
|
||||
SET
|
||||
household_seq = #{householdSeq},
|
||||
street_num = #{streetNum},
|
||||
land_type = #{landType},
|
||||
town = #{town},
|
||||
available_area = #{availableArea},
|
||||
crop_name = #{cropName},
|
||||
crop_code = #{cropCode},
|
||||
land_area = #{landArea},
|
||||
month = #{month},
|
||||
main_yield = #{mainYield},
|
||||
main_yield_unit_code = #{mainYieldUnitCode},
|
||||
main_sale_amount = #{mainSaleAmount},
|
||||
main_sale_unit_code = #{mainSaleUnitCode},
|
||||
sub_yield = #{subYield},
|
||||
sub_yield_unit_code = #{subYieldUnitCode},
|
||||
sub_sale_amount = #{subSaleAmount},
|
||||
sub_sale_unit_code = #{subSaleUnitCode},
|
||||
<include refid="common.fields.UpdateBaseSet"/>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -1207,6 +1207,17 @@ CREATE TABLE forest_product (
|
||||
crop_code varchar(255), -- 작물부호 (매핑코드)
|
||||
land_area integer, -- 면적
|
||||
month varchar(7) NOT NULL, -- 조사시행 월 (yyyy-mm)
|
||||
main_yield NUMERIC(10, 2), -- 수확량
|
||||
main_yield_unit_code varchar(255), -- 수확 단위 (매핑코드)
|
||||
main_sale_amount NUMERIC(10, 2), -- 판매량
|
||||
main_sale_unit_code varchar(255), -- 판매 단위 (매핑코드)
|
||||
|
||||
sub_yield NUMERIC(10, 2), -- 수확량
|
||||
sub_yield_unit_code varchar(255), -- 수확 단위 (매핑코드)
|
||||
sub_sale_amount NUMERIC(10, 2), -- 판매량
|
||||
sub_sale_unit_code varchar(255), -- 판매 단위 (매핑코드)
|
||||
|
||||
|
||||
created_at timestamp(6), -- 생성일
|
||||
created_by varchar(255), -- 생성자
|
||||
updated_at timestamp(6), -- 수정일
|
||||
@@ -1231,6 +1242,17 @@ COMMENT ON COLUMN forest_product.crop_name IS '재배작물명';
|
||||
COMMENT ON COLUMN forest_product.crop_code IS '작물부호 (매핑코드)';
|
||||
COMMENT ON COLUMN forest_product.land_area IS '면적';
|
||||
COMMENT ON COLUMN forest_product.month IS '조사시행 월 (yyyy-mm)';
|
||||
|
||||
COMMENT ON COLUMN forest_product.main_yield IS '주 생산물 수확량';
|
||||
COMMENT ON COLUMN forest_product.main_yield_unit_code IS '주 생산물 수확 단위 (매핑코드)';
|
||||
COMMENT ON COLUMN forest_product.main_sale_amount IS '주 생산물 판매량';
|
||||
COMMENT ON COLUMN forest_product.main_sale_unit_code IS '주 생산물 판매 단위 (매핑코드)';
|
||||
|
||||
COMMENT ON COLUMN forest_product.sub_yield IS '주 생산물 수확량';
|
||||
COMMENT ON COLUMN forest_product.sub_yield_unit_code IS '주 생산물 수확 단위 (매핑코드)';
|
||||
COMMENT ON COLUMN forest_product.sub_sale_amount IS '주 생산물 판매량';
|
||||
COMMENT ON COLUMN forest_product.sub_sale_unit_code IS '주 생산물 판매 단위 (매핑코드)';
|
||||
|
||||
COMMENT ON COLUMN forest_product.created_at IS '생성일';
|
||||
COMMENT ON COLUMN forest_product.created_by IS '생성자';
|
||||
COMMENT ON COLUMN forest_product.updated_at IS '수정일';
|
||||
|
||||
Reference in New Issue
Block a user