feat:更新物品返回数据类型
This commit is contained in:
@@ -32,18 +32,10 @@ public class ProductDto {
|
|||||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
private Date expiryDate;
|
private Date expiryDate;
|
||||||
|
|
||||||
@Schema(description = "总天数")
|
|
||||||
@JsonView(ReadView.class)
|
|
||||||
private Integer totalDay;
|
|
||||||
|
|
||||||
@Schema(description = "价格")
|
@Schema(description = "价格")
|
||||||
@PositiveOrZero(message = "商品价格必须大于等于0")
|
@PositiveOrZero(message = "商品价格必须大于等于0")
|
||||||
private Double price;
|
private Double price;
|
||||||
|
|
||||||
@Schema(description = "日均价格")
|
|
||||||
@JsonView(ReadView.class)
|
|
||||||
private Double averagePrice;
|
|
||||||
|
|
||||||
@Schema(description = "类别")
|
@Schema(description = "类别")
|
||||||
private String category;
|
private String category;
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,7 @@
|
|||||||
name AS name,
|
name AS name,
|
||||||
purchase_date AS purchaseDate,
|
purchase_date AS purchaseDate,
|
||||||
expiry_date AS expiryDate,
|
expiry_date AS expiryDate,
|
||||||
@totalDay := (DATEDIFF(CURDATE(), purchase_date) + 1) AS totalDay,
|
|
||||||
price AS price,
|
price AS price,
|
||||||
ROUND(price / @totalDay, 2) AS averagePrice,
|
|
||||||
category AS category,
|
category AS category,
|
||||||
purchaser AS purchaser,
|
purchaser AS purchaser,
|
||||||
channel AS channel,
|
channel AS channel,
|
||||||
@@ -24,11 +22,8 @@
|
|||||||
<if test="query.order == 'date' or query.order == '' or query.order == null">
|
<if test="query.order == 'date' or query.order == '' or query.order == null">
|
||||||
ORDER BY purchase_date DESC
|
ORDER BY purchase_date DESC
|
||||||
</if>
|
</if>
|
||||||
<if test="query.order == 'day'">
|
|
||||||
ORDER BY totalDay
|
|
||||||
</if>
|
|
||||||
<if test="query.order == 'price'">
|
<if test="query.order == 'price'">
|
||||||
ORDER BY averagePrice
|
ORDER BY price DESC
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user