【WX】预算配置

This commit is contained in:
limqhz
2023-02-09 17:45:43 +08:00
parent 94dc4e7cf3
commit 658ec47494
5 changed files with 136 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
package com.quinn.mapper;
import com.quinn.common.wx.BudgetDTO;
import com.quinn.pojo.AccBudget;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author limqsh
* @since 2023-02-09
*/
public interface AccBudgetMapper extends BaseMapper<AccBudget> {
List<BudgetDTO> getBudget(String userId, String startDate, String endDate);
}

View File

@@ -0,0 +1,13 @@
<?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.quinn.mapper.AccBudgetMapper">
<select id="getBudget" resultType="com.quinn.common.wx.BudgetDTO">
select a.id,b.id "expendId",IFNULL(a.budget,0) "budget",b.user_id,a.gmt_create,
IFNULL(
(select sum(money) from qn_acc_bill c where c.money_type = a.expend_id and c.user_id = #{userId} and c.date <![CDATA[ >= ]]> #{startDate} and c.date <![CDATA[ <= ]]> #{endDate})
,0) "used",
b.icon "expendIcon"
from qn_acc_budget a right join qn_acc_setting b on a.expend_id = b.id
where b.user_id = #{userId}
</select>
</mapper>

View File

@@ -0,0 +1,47 @@
package com.quinn.pojo;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author limqsh
* @since 2023-02-09
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("qn_acc_budget")
@ApiModel(value="AccBudget对象", description="")
public class AccBudget implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "自增id")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "设置类型")
private Integer expendId;
@ApiModelProperty(value = "预算")
private Double budget;
private String userId;
@ApiModelProperty(value = "收藏创建时间")
private Date gmtCreate;
}

View File

@@ -0,0 +1,20 @@
package com.quinn.service;
import com.quinn.common.wx.BudgetDTO;
import com.quinn.pojo.AccBudget;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author limqsh
* @since 2023-02-09
*/
public interface AccBudgetService extends IService<AccBudget> {
List<BudgetDTO> getBudget(String userId);
}

View File

@@ -0,0 +1,36 @@
package com.quinn.service.impl;
import com.quinn.common.wx.BudgetDTO;
import com.quinn.pojo.AccBudget;
import com.quinn.mapper.AccBudgetMapper;
import com.quinn.service.AccBudgetService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.quinn.utils.QuinnUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author limqsh
* @since 2023-02-09
*/
@Service
public class AccBudgetServiceImpl extends ServiceImpl<AccBudgetMapper, AccBudget> implements AccBudgetService {
@Resource
AccBudgetMapper accBudgetMapper;
@Override
public List<BudgetDTO> getBudget(String userId) {
String viewStrFromDate = QuinnUtils.getViewStrFromDate(new Date());
String startDate = viewStrFromDate.substring(0,7) + "-01";
String endDate = viewStrFromDate.substring(0,7) + "-31";
return accBudgetMapper.getBudget(userId,startDate,endDate);
}
}