【WX】预算配置
This commit is contained in:
41
src/main/java/com/quinn/common/wx/AccBudgetDTO.java
Normal file
41
src/main/java/com/quinn/common/wx/AccBudgetDTO.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package com.quinn.common.wx;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.quinn.pojo.AccBudget;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <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 AccBudgetDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Double sumBudget = 0.0;
|
||||
|
||||
private Double sumUsed = 0.0;
|
||||
|
||||
private Double sumBalance = 0.0;
|
||||
|
||||
List<BudgetDTO> payTypeList;
|
||||
}
|
||||
34
src/main/java/com/quinn/common/wx/BudgetDTO.java
Normal file
34
src/main/java/com/quinn/common/wx/BudgetDTO.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package com.quinn.common.wx;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.quinn.pojo.AccBudget;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author limqsh
|
||||
* @since 2023-02-09
|
||||
*/
|
||||
@Data
|
||||
public class BudgetDTO extends AccBudget {
|
||||
|
||||
private String expendName;
|
||||
|
||||
private Double used;
|
||||
|
||||
private String expendIcon;
|
||||
|
||||
}
|
||||
11
src/main/java/com/quinn/common/wx/EditBudget.java
Normal file
11
src/main/java/com/quinn/common/wx/EditBudget.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.quinn.common.wx;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class EditBudget implements Serializable {
|
||||
private Integer expendId;
|
||||
private Double budget;
|
||||
}
|
||||
@@ -98,6 +98,8 @@ public class WxBillController extends BaseWxController{
|
||||
*/
|
||||
@PostMapping("user/bill/del/{id}")
|
||||
public ResponseDTO deleteBill(@PathVariable("id") Integer id){
|
||||
AccBill byId = accBillService.getById(id);
|
||||
modifyBalance(true,byId);
|
||||
accBillService.removeById(id);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.quinn.controller.wx;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.quinn.common.wx.AccBudgetDTO;
|
||||
import com.quinn.common.wx.BudgetDTO;
|
||||
import com.quinn.common.wx.EditBudget;
|
||||
import com.quinn.dto.res.ResponseDTO;
|
||||
import com.quinn.pojo.AccBudget;
|
||||
import com.quinn.service.AccBudgetService;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author limqsh
|
||||
* @since 2022-05-01
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/wx")
|
||||
public class WxBudgetController extends BaseWxController{
|
||||
|
||||
@Resource
|
||||
AccBudgetService accBudgetService;
|
||||
|
||||
@PostMapping("user/budget")
|
||||
public ResponseDTO getBudget(HttpServletRequest request){
|
||||
AccBudgetDTO result = new AccBudgetDTO();
|
||||
List<BudgetDTO> accBills = accBudgetService.getBudget(getLoginUserId(request));
|
||||
List<BudgetDTO> sum = accBills.stream().filter(x -> x.getExpendId() == 1).collect(Collectors.toList());
|
||||
if (sum != null && sum.size() > 0){
|
||||
BudgetDTO budgetDTO = sum.get(0);
|
||||
result.setSumBudget(budgetDTO.getBudget());
|
||||
result.setSumUsed(budgetDTO.getUsed());
|
||||
result.setSumBalance(budgetDTO.getBudget() - budgetDTO.getUsed());
|
||||
}
|
||||
List<BudgetDTO> list = accBills.stream().filter(x -> x.getExpendId() != -1).collect(Collectors.toList());
|
||||
result.setPayTypeList(list);
|
||||
return ResponseDTO.ok().setData(result);
|
||||
}
|
||||
|
||||
@PostMapping("user/budget/edit")
|
||||
public ResponseDTO editBudget(HttpServletRequest request, EditBudget editBudget){
|
||||
AccBudget one = accBudgetService.getOne(new QueryWrapper<AccBudget>().eq("user_id", getLoginUserId(request)).eq("expend_id", editBudget.getExpendId()));
|
||||
if (one == null){
|
||||
AccBudget budget = new AccBudget();
|
||||
budget.setExpendId(editBudget.getExpendId());
|
||||
budget.setBudget(editBudget.getBudget());
|
||||
budget.setUserId(getLoginUserId(request));
|
||||
budget.setGmtCreate(new Date());
|
||||
accBudgetService.save(budget);
|
||||
}else {
|
||||
one.setBudget(editBudget.getBudget());
|
||||
accBudgetService.updateById(one);
|
||||
}
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class CodeGenerator {
|
||||
|
||||
// 5、策略配置
|
||||
StrategyConfig strategy = new StrategyConfig();
|
||||
strategy.setInclude("qn_acc_bill");//设置要映射的表名
|
||||
strategy.setInclude("qn_acc_budget");//设置要映射的表名
|
||||
strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略
|
||||
strategy.setTablePrefix("qn_");//设置表前缀不生成
|
||||
|
||||
|
||||
@@ -28,3 +28,12 @@ CREATE TABLE `qn_acc_bill` (
|
||||
`gmt_create` datetime NOT NULL COMMENT '收藏创建时间',
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
DROP TABLE IF EXISTS `qn_acc_budget`;
|
||||
CREATE TABLE `qn_acc_budget` (
|
||||
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`expend_id` varchar(20) DEFAULT NULL COMMENT '设置类型',
|
||||
`budget` double(9,2) NOT NULL DEFAULT 0 COMMENT '预算',
|
||||
`user_id` varchar(200) DEFAULT NULL,
|
||||
`gmt_create` datetime NOT NULL COMMENT '收藏创建时间',
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user