feat: 移植工程

This commit is contained in:
2025-06-10 09:54:52 +08:00
commit a2de21b092
277 changed files with 11116 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/sweet_hut?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: root
password: 123456

View File

@@ -0,0 +1,6 @@
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://mysql:3306/sweet_hut?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: docker
password: 19940822Cxx

View File

@@ -0,0 +1,6 @@
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/sweet_hut?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: cxx
password: 19940822Cxx@1213

View File

@@ -0,0 +1,36 @@
server:
port: 8081
spring:
application:
name: @project.artifactId@
version: @project.version@
profiles:
active: dev
mail:
host: smtp.163.com
port: 465
username: njcxx0822@163.com
password: CDfsF386Y2FWKHHm
protocol: smtps
properties:
mail:
smtp:
auth: true
starttls:
enable: true
default-encoding: UTF-8
quartz:
job-store-type: jdbc
# mybatis plus mapper路径
mybatis-plus:
# mybatis plus
mapper-locations: classpath*:/mapper/**/*.xml
configuration:
log-impl:
org.apache.ibatis.logging.stdout.StdOutImpl
web-starter:
base-package: com.cxx.home

View File

@@ -0,0 +1,41 @@
<?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 AS id,
title AS title,
date AS date,
CASE WHEN recurring = 1 THEN true ELSE false END AS recurring,
type AS type,
category AS category
FROM anniversary AS a
<where>
<if test="category != null and category != ''">
a.category = #{category}
</if>
AND
(CASE
WHEN type = 'countDown' THEN
(recurring = 1 OR date >= CURDATE())
ELSE
TRUE
END)
</where>
ORDER BY date DESC
</select>
<select id="queryAnniversaryCategory" resultType="com.cxx.common.dto.StatsChartDto">
SELECT a.category AS name,
COUNT(*) AS value
FROM anniversary a
WHERE CASE
WHEN type = 'countDown' THEN
(
recurring = 1
OR date >= CURDATE())
ELSE 1
END
GROUP BY a.category
</select>
</mapper>

View File

@@ -0,0 +1,25 @@
<?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 AS id,
category AS category,
NAME AS NAME,
amount AS amount,
owner AS owner,
remark AS remark
FROM asset AS a
<where>
<if test="category != null and category != ''">
category = #{category}
</if>
</where>
ORDER BY a.category, a.name
</select>
<select id="queryAssetCategory" resultType="string">
SELECT DISTINCT category
FROM asset
WHERE category IS NOT NULL AND category != '';
</select>
</mapper>

View File

@@ -0,0 +1,164 @@
<?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.BillDao">
<resultMap id="billRecordResultMap" type="com.cxx.common.dto.bill.BillRecordDto">
<id property="id" column="id"/>
<result property="bookName" column="bookName"/>
<result property="type" column="type"/>
<result property="category" column="category"/>
<result property="location" column="location"/>
<result property="payAccount" column="payAccount"/>
<result property="amount" column="amount"/>
<result property="content" column="content"/>
<result property="remark" column="remark"/>
<result property="date" column="date"/>
<collection property="imageList" ofType="java.lang.String"
column="id" select="queryBillImage"/>
</resultMap>
<resultMap id="billSummaryResultMap" type="com.cxx.common.dto.bill.BillSummaryDto">
<id property="id" column="id"/>
<result property="bookName" column="bookName"/>
<result property="type" column="type"/>
<result property="category" column="category"/>
<result property="location" column="location"/>
<result property="payAccount" column="payAccount"/>
<result property="amount" column="amount"/>
<result property="content" column="content"/>
<result property="remark" column="remark"/>
<result property="date" column="date"/>
</resultMap>
<select id="queryBillImage" resultType="java.lang.String">
SELECT image_url AS imageUrl
FROM bill_image
WHERE bill_id = #{id}
</select>
<select id="queryBillRecord" resultMap="billRecordResultMap">
SELECT a.id AS id,
c.name AS bookName,
a.type AS type,
d.name AS category,
a.location AS location,
b.name AS payAccount,
a.amount AS amount,
a.content AS content,
a.remark AS remark,
a.date AS date
FROM bill_record a
LEFT JOIN bill_pay b ON a.pay_id = b.id
LEFT JOIN bill_book c ON a.book_id = c.id
LEFT JOIN bill_category d ON a.category_id = d.id
WHERE a.id = #{id}
LIMIT 1
</select>
<select id="queryBillSummary" resultMap="billSummaryResultMap">
SELECT
a.id AS id,
c.name AS bookName,
a.type AS type,
d.name AS category,
a.location AS location,
b.name AS payAccount,
a.amount AS amount,
a.content AS content,
a.remark AS remark,
a.date AS date
FROM bill_record a
LEFT JOIN bill_pay b ON a.pay_id = b.id
LEFT JOIN bill_book c ON a.book_id = c.id
LEFT JOIN bill_category d ON a.category_id = d.id
<where>
<if test="query.bookName != null and query.bookName != ''">
c.name = #{query.bookName}
</if>
<if test="query.type != null and query.type != ''">
AND a.type = #{query.type}
</if>
AND a.date <![CDATA[ >=]]> STR_TO_DATE(#{query.startDate}, '%Y-%m-%d')
AND a.date <![CDATA[ <=]]> STR_TO_DATE(#{query.endDate}, '%Y-%m-%d')
</where>
ORDER BY a.date DESC
</select>
<insert id="insertBillImage">
INSERT INTO bill_image (bill_id, image_url) VALUES
<foreach collection="list" item="item" separator=",">
(#{billId}, #{item})
</foreach>
</insert>
<select id="queryBillStats" resultType="com.cxx.common.dto.StatsChartDto">
SELECT
<if test="type eq 'month'">
DATE_FORMAT(a.date,'%Y-%m-%d') AS name,
</if>
<if test="type eq 'year'">
DATE_FORMAT(a.date,'%Y-%m') AS name,
</if>
<if test="type eq 'book'">
b.name AS name,
</if>
<if test="type eq 'category'">
c.name AS name,
</if>
SUM(a.amount) AS value
FROM bill_record a
LEFT JOIN bill_book b ON a.book_id = b.id
LEFT JOIN bill_category c ON a.category_id = c.id
<where>
<if test="query.type != null and query.type != ''">
a.type = #{query.type}
</if>
<if test="query.bookName != null and query.bookName != ''">
AND b.name = #{query.bookName}
</if>
AND a.date <![CDATA[ >=]]> STR_TO_DATE(#{query.startDate}, '%Y-%m-%d')
AND a.date <![CDATA[ <=]]> STR_TO_DATE(#{query.endDate}, '%Y-%m-%d')
</where>
<if test="type eq 'month'">
GROUP BY DATE_FORMAT(a.date,'%Y-%m-%d')
ORDER BY DATE_FORMAT(a.date,'%Y-%m-%d')
</if>
<if test="type eq 'year'">
GROUP BY DATE_FORMAT(a.date,'%Y-%m')
ORDER BY DATE_FORMAT(a.date,'%Y-%m')
</if>
<if test="type eq 'book'">
GROUP BY b.name
</if>
<if test="type eq 'category'">
GROUP BY c.name
</if>
</select>
<select id="queryBillPay" resultType="com.cxx.common.dto.bill.BillItemDto">
SELECT id AS id,
name AS name,
icon AS icon,
color AS color
FROM bill_pay
</select>
<select id="queryBillBook" resultType="com.cxx.common.dto.bill.BillItemDto">
SELECT id AS id,
name AS name,
icon AS icon,
color AS color
FROM bill_book
</select>
<select id="queryBillCategory" resultType="com.cxx.common.dto.bill.BillCategoryDto">
SELECT a.id AS id,
b.name AS bookName,
a.name AS name,
a.type AS type,
a.icon AS icon,
a.color AS color
FROM bill_category a
LEFT JOIN bill_book b on a.book_id = b.id
ORDER BY bookName, type
</select>
</mapper>

View File

@@ -0,0 +1,37 @@
<?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.BudgetDao">
<select id="queryBudget" resultType="com.cxx.common.dto.budget.BudgetDto">
SELECT a.id AS id,
b.name AS category,
a.project AS project,
a.content AS content,
a.vendor AS vendor,
a.budget AS budget,
a.actual AS actual,
a.pay_time AS payTime,
a.remake AS remake
FROM budget a
LEFT JOIN budget_category b on a.category_id = b.id
WHERE b.name = #{category}
</select>
<select id="queryBudgetRankStats" resultType="com.cxx.common.dto.StatsChartDto">
SELECT a.content AS name,
a.actual AS value
FROM budget a
LEFT JOIN budget_category b on a.category_id = b.id
WHERE b.name = #{category}
ORDER BY a.actual DESC
LIMIT 10
</select>
<select id="queryBudgetProjectStats" resultType="com.cxx.common.dto.StatsChartDto">
SELECT a.project AS name,
SUM(a.actual) AS value
FROM budget a
LEFT JOIN budget_category b on a.category_id = b.id
WHERE b.name = #{category}
GROUP BY a.project
</select>
</mapper>

View File

@@ -0,0 +1,147 @@
<?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.FoodDao">
<resultMap id="foodRecipeResultMap" type="com.cxx.home.dto.food.FoodRecipeDto">
<id property="id" column="id"/>
<result property="name" column="name"/>
<result property="category" column="category"/>
<result property="recommendRate" column="recommendRate"/>
<result property="remark" column="remark"/>
<collection property="materialList" ofType="com.cxx.home.dto.food.FoodMaterialDto"
column="id" select="queryFoodMaterial">
</collection>
<collection property="stepList" ofType="com.cxx.home.dto.food.FoodStepDto"
column="id" select="queryFoodStep">
</collection>
<collection property="recordList" ofType="com.cxx.home.dto.food.FoodRecordDto"
column="id" select="queryFoodRecordById">
</collection>
</resultMap>
<resultMap id="foodMaterialResultMap" type="com.cxx.home.dto.food.FoodMaterialDto">
<id property="id" column="id"/>
<result property="type" column="type"/>
<result property="name" column="name"/>
<result property="amount" column="amount"/>
</resultMap>
<resultMap id="foodStepResultMap" type="com.cxx.home.dto.food.FoodStepDto">
<id property="id" column="id"/>
<result property="sort" column="sort"/>
<result property="content" column="content"/>
<result property="imageUrl" column="imageUrl"/>
</resultMap>
<resultMap id="foodRecordResultMap" type="com.cxx.home.dto.food.FoodRecordDto">
<id property="id" column="id"/>
<result property="date" column="date"/>
<result property="person" column="person"/>
<result property="imageUrl" column="imageUrl"/>
</resultMap>
<resultMap id="foodSummaryResultMap" type="com.cxx.home.dto.food.FoodSummaryDto">
<id property="id" column="id"/>
<result property="name" column="name"/>
<result property="category" column="category"/>
<result property="recommendRate" column="recommendRate"/>
<collection property="recordList" ofType="com.cxx.home.dto.food.FoodRecordDto">
<id property="id" column="workId"/>
<result property="date" column="recordDate"/>
<result property="person" column="recordPerson"/>
<result property="imageUrl" column="workImageUrl"/>
</collection>
</resultMap>
<select id="queryFoodMaterial" resultMap="foodMaterialResultMap">
SELECT id AS id,
type AS type,
name AS name,
amount AS amount
FROM food_material
WHERE food_id = #{id}
</select>
<select id="queryFoodStep" resultMap="foodStepResultMap">
SELECT id AS id,
sort AS sort,
content AS content,
image_url AS imageUrl
FROM food_step
WHERE food_id = #{id}
ORDER BY sort
</select>
<select id="queryFoodRecordById" resultMap="foodRecordResultMap">
SELECT id AS id,
date AS date,
person AS person,
image_url AS imageUrl
FROM food_record
WHERE food_id = #{id}
ORDER BY date DESC
</select>
<select id="queryFoodRecord" resultType="com.cxx.home.dto.food.FoodRecordDto">
SELECT a.id AS id,
b.name AS name,
b.category AS category,
a.date AS date,
a.person AS person,
a.image_url AS imageUrl
FROM food_record AS a
LEFT JOIN food_recipe AS b ON a.food_id = b.id
WHERE a.date <![CDATA[ >=]]> STR_TO_DATE(#{startDate}, '%Y-%m-%d')
AND a.date <![CDATA[ <=]]> STR_TO_DATE(#{endDate}, '%Y-%m-%d')
ORDER BY date DESC
</select>
<select id="queryFoodRecipe" resultMap="foodRecipeResultMap">
SELECT a.id AS id,
a.name AS name,
a.category AS category,
a.recommend_rate AS recommendRate,
a.remark AS remake
FROM food_recipe a
WHERE a.id = #{id}
</select>
<select id="queryFoodSummary" resultMap="foodSummaryResultMap">
SELECT a.id AS id,
a.name AS name,
a.category AS category,
a.recommend_rate AS recommendRate
FROM food_recipe a
<where>
<if test="query.category != null and query.category != ''">
a.category = #{query.category}
</if>
</where>
</select>
<select id="queryFoodStats" resultType="com.cxx.home.dto.food.FoodStatsDto">
SELECT COUNT(DISTINCT a.name) AS recipeCount,
COUNT(DISTINCT a.category) AS categoryCount,
COUNT(b.id) AS workCount
FROM food_recipe a
LEFT JOIN food_record b ON a.id = b.food_id
</select>
<select id="queryFoodCategory" resultType="string">
SELECT DISTINCT a.category AS category
FROM food_recipe a
</select>
<insert id="insertFoodMaterial">
INSERT INTO food_material (id, food_id, type, name, amount) VALUES
<foreach collection="list" item="item" separator=",">
(#{item.id}, #{foodId}, #{item.type}, #{item.name}, #{item.amount})
</foreach>
</insert>
<insert id="insertFoodStep">
INSERT INTO food_step (id, food_id, sort, content, image_url) VALUES
<foreach collection="list" item="item" separator=",">
(#{item.id}, #{foodId}, #{item.sort}, #{item.content}, #{item.imageUrl})
</foreach>
</insert>
</mapper>

View File

@@ -0,0 +1,19 @@
<?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.JournalDao">
<select id="queryJournal" resultType="com.cxx.home.dto.journal.JournalDto">
SELECT id AS id,
date AS date,
location AS location,
category AS category,
weather AS weather,
mood AS mood,
content AS content,
image_url AS imageUrl,
video_url AS videoUrl
FROM journal AS a
WHERE a.date <![CDATA[ >=]]> STR_TO_DATE(#{query.startDate}, '%Y-%m-%d')
AND a.date <![CDATA[ <=]]> STR_TO_DATE(#{query.endDate}, '%Y-%m-%d')
ORDER BY a.date DESC
</select>
</mapper>

View File

@@ -0,0 +1,15 @@
<?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.KpiDao">
<select id="queryKpi" resultType="com.cxx.home.dto.kpi.KpiDto">
SELECT id AS id,
date AS date,
patient_name AS patientName,
project AS project,
price AS price
FROM kpi AS a
WHERE a.date <![CDATA[ >=]]> STR_TO_DATE(#{query.startDate}, '%Y-%m-%d')
AND a.date <![CDATA[ <=]]> STR_TO_DATE(#{query.endDate}, '%Y-%m-%d')
ORDER BY a.date DESC
</select>
</mapper>

View File

@@ -0,0 +1,25 @@
<?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.LedgerDao">
<select id="queryLedger" resultType="com.cxx.home.dto.ledger.LedgerDto">
SELECT id AS id,
book AS book,
category AS category,
content AS content,
price AS price,
number AS number,
unit AS unit,
(price * number) AS totalPrice,
payer AS payer,
provider AS provider,
imager_url AS imagerUrl,
remark AS remark
FROM ledger AS a
WHERE a.book = #{book}
</select>
<select id="queryLedgerBook" resultType="string">
SELECT DISTINCT (book)
FROM ledger
</select>
</mapper>

View File

@@ -0,0 +1,22 @@
<?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.PeriodDao">
<select id="queryPeriodDay" resultType="com.cxx.home.dto.period.PeriodDayDto">
SELECT id AS id,
date AS date,
CASE WHEN is_drug = 1 THEN true ELSE false END AS isDrug,
CASE WHEN is_menstruate = 1 THEN true ELSE false END AS isMenstruate,
flow_level AS flowLevel,
cramp_level AS crampLevel,
sex_activity AS sexActivity
FROM period_day a
WHERE DATE_FORMAT(date, '%Y-%m') = #{month}
</select>
<select id="getMenstruateFirstDate" resultType="string">
SELECT MIN(date)
FROM period_day
WHERE is_menstruate = 1
AND DATE_FORMAT(date, '%Y-%m') = #{month};
</select>
</mapper>

View File

@@ -0,0 +1,42 @@
<?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.PlanDao">
<select id="queryPlan" resultType="com.cxx.common.dto.plan.PlanDto">
SELECT id AS id,
title AS title,
content AS content,
date AS date,
start_time AS startTime,
end_time AS endTime,
alter_time AS alterTime,
task_id AS taskId,
tag AS tag,
is_top AS isTop,
priority AS priority,
completed AS completed
FROM plan
<where>
<if test="query.planType eq 'completed'">
completed = 1
</if>
<if test="query.planType eq 'notCompleted'">
completed = 0
</if>
</where>
ORDER BY
<if test="query.orderType eq 'priority'">
priority,
</if>
completed,
is_top DESC,
date DESC
</select>
<select id="queryPlanStats" resultType="com.cxx.common.dto.plan.PlanStatsDto">
SELECT COUNT(*) AS totalCount,
IFNULL(SUM(completed), 0) AS completedCount,
IFNULL(SUM(CASE WHEN completed = 0 AND date <![CDATA[ >]]> CURDATE() THEN 1 ELSE 0 END), 0) AS currentCount,
IFNULL(SUM(CASE WHEN completed = 0 AND date <![CDATA[ >]]> CURDATE() THEN 1 ELSE 0 END), 0) AS remainCount
FROM plan
</select>
</mapper>

View File

@@ -0,0 +1,55 @@
<?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.ProductDao">
<select id="queryProduct" resultType="com.cxx.home.dto.product.ProductDto">
SELECT id AS id,
name AS name,
purchase_date AS purchaseDate,
expiry_date AS expiryDate,
price AS price,
category AS category,
purchaser AS purchaser,
channel AS channel,
image_url As imageUrl
FROM product
WHERE id = #{id}
ORDER BY purchase_date DESC
</select>
<select id="queryProductList" resultType="com.cxx.home.dto.product.ProductDto">
SELECT
id AS id,
name AS name,
purchase_date AS purchaseDate,
expiry_date AS expiryDate,
@totalDay := (DATEDIFF(CURDATE(), purchase_date) + 1) AS totalDay,
price AS price,
ROUND(price / @totalDay, 2) AS averagePrice,
category AS category,
purchaser AS purchaser,
channel AS channel,
image_url AS imageUrl
FROM
product
<where>
<if test="query.category != null and query.category != ''">
category = #{query.category}
</if>
</where>
<if test="query.order == 'date' or query.order == '' or query.order == null">
ORDER BY purchase_date DESC
</if>
<if test="query.order == 'day'">
ORDER BY totalDay
</if>
<if test="query.order == 'price'">
ORDER BY averagePrice
</if>
</select>
<select id="queryProductCategory" resultType="string">
SELECT DISTINCT category
FROM product
WHERE category IS NOT NULL AND category != '';
</select>
</mapper>

View File

@@ -0,0 +1,138 @@
<?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.TravelDao">
<resultMap id="travelSpotResultMap" type="com.cxx.home.dto.travel.TravelSpotDto">
<id property="id" column="id"/>
<result property="name" column="name"/>
<result property="area" column="area"
typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
<result property="price" column="price"/>
<result property="address" column="address"/>
<result property="recommendRate" column="recommendRate"/>
<result property="traffic" column="traffic"/>
<result property="router" column="router"/>
<result property="foods" column="foods"
typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
<result property="projects" column="projects"
typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
<result property="remark" column="remark"/>
<collection property="recordList" ofType="com.cxx.home.dto.travel.TravelRecordDto"
column="id" select="queryTravelRecordById">
</collection>
</resultMap>
<resultMap id="travelSummaryResultMap" type="com.cxx.home.dto.travel.TravelSummaryDto">
<id property="id" column="id"/>
<result property="name" column="name"/>
<result property="area" column="area"
typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
<result property="recommendRate" column="recommendRate"/>
<collection property="recordList" ofType="com.cxx.home.dto.travel.TravelRecordDto"
column="id" select="queryTravelRecordById">
</collection>
</resultMap>
<resultMap id="travelRecordResultMap" type="com.cxx.home.dto.travel.TravelRecordDto">
<id property="id" column="id"/>
<result property="name" column="name"/>
<result property="area" column="area"
typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
<result property="date" column="date"/>
<result property="persons" column="persons"
typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
<collection property="imageList" ofType="java.lang.String"
column="id" select="queryRecordImage"/>
<collection property="videoList" ofType="java.lang.String"
column="id" select="queryRecordVideo"/>
</resultMap>
<select id="queryRecordImage" resultType="java.lang.String">
SELECT image_url AS imageUrl
FROM travel_image
WHERE record_id = #{id}
</select>
<select id="queryRecordVideo" resultType="java.lang.String">
SELECT video_url AS videoUrl
FROM travel_video
WHERE record_id = #{id}
</select>
<select id="queryTravelRecordById" resultMap="travelRecordResultMap">
SELECT id AS id,
date AS date,
persons AS persons
FROM travel_record
WHERE travel_id = #{id}
ORDER BY date DESC
</select>
<select id="queryTravelRecord" resultMap="travelRecordResultMap">
SELECT a.id AS id,
b.name AS name,
b.area AS area,
a.date AS date,
a.persons AS persons
FROM travel_record AS a
LEFT JOIN travel_spot AS b ON a.travel_id = b.id
WHERE a.date <![CDATA[ >=]]> STR_TO_DATE(#{startDate}, '%Y-%m-%d')
AND a.date <![CDATA[ <=]]> STR_TO_DATE(#{endDate}, '%Y-%m-%d')
ORDER BY date DESC
</select>
<select id="queryTravelSpot" resultMap="travelSpotResultMap">
SELECT a.id AS id,
a.name AS name,
a.area AS area,
a.address AS address,
a.price AS price,
a.recommend_rate AS recommendRate,
a.traffic AS traffic,
a.router AS router,
a.foods AS foods,
a.projects AS projects,
a.remark AS remake
FROM travel_spot a
WHERE a.id = #{id}
</select>
<select id="queryTravelSummary" resultMap="travelSummaryResultMap">
SELECT a.id AS id,
a.name AS name,
a.area AS area,
a.recommend_rate AS recommendRate
FROM travel_spot a
<where>
<if test="query.category != null and query.category != ''">
a.city = #{query.category}
</if>
</where>
</select>
<select id="queryTravelStats" resultType="com.cxx.home.dto.travel.TravelStatsDto">
SELECT COUNT(DISTINCT a.name) AS spotCount,
COUNT(DISTINCT a.area) AS cityCount,
COUNT(b.id) AS recordCount
FROM travel_spot a
LEFT JOIN travel_record b ON a.id = b.travel_id
</select>
<select id="queryTravelCategory" resultType="string">
SELECT DISTINCT a.city AS city
FROM travel_spot a
</select>
<insert id="insertTravelImage">
INSERT INTO travel_image (record_id, image_url) VALUES
<foreach collection="list" item="item" separator=",">
(#{recordId}, #{item})
</foreach>
</insert>
<insert id="insertTravelVideo">
INSERT INTO travel_video (record_id, video_url) VALUES
<foreach collection="list" item="item" separator=",">
(#{recordId}, #{item})
</foreach>
</insert>
</mapper>