微信API
This commit is contained in:
@@ -8,10 +8,8 @@ import com.quinn.dto.res.ResponseDTO;
|
||||
import com.quinn.pojo.AccSetting;
|
||||
import com.quinn.service.AccSettingService;
|
||||
import com.quinn.service.AccountCheckService;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -39,8 +37,8 @@ public class WxSettingsController extends BaseWxController{
|
||||
private AccSettingService accSettingService;
|
||||
|
||||
@PostMapping("user/login")
|
||||
public ResponseDTO userIndexBlog(SearchPage searchPage){
|
||||
return ResponseDTO.ok().setData(accountCheckService.getUserId("openid"));
|
||||
public ResponseDTO userIndexBlog(String openId){
|
||||
return ResponseDTO.ok().setData(accountCheckService.getUserId(openId));
|
||||
}
|
||||
|
||||
@PostMapping("user/settings")
|
||||
@@ -55,15 +53,24 @@ public class WxSettingsController extends BaseWxController{
|
||||
|
||||
/**
|
||||
* 本年度支出统计
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("user/settings/{id}")
|
||||
public ResponseDTO addSetting(HttpServletRequest request, @PathVariable("id") String id){
|
||||
@PostMapping("user/setting/{id}")
|
||||
public ResponseDTO getSetting(@PathVariable("id") String id){
|
||||
AccSetting byId = accSettingService.getById(id);
|
||||
return ResponseDTO.ok().setData(byId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本年度支出统计
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("user/settings/del/{id}")
|
||||
public ResponseDTO deleteSetting(@PathVariable("id") String id){
|
||||
accSettingService.removeById(id);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 本年度支出统计
|
||||
* @param request
|
||||
@@ -85,7 +92,11 @@ public class WxSettingsController extends BaseWxController{
|
||||
@PostMapping("user/settings/expend")
|
||||
public ResponseDTO getBillExpend(HttpServletRequest request){
|
||||
List<YearAmnt> billByType = accSettingService.getBillByType(getLoginUserId(request), AccSettingType.EXPEND_SETTING);
|
||||
return ResponseDTO.ok().setData(billByType);
|
||||
Map<Integer,Double> result = new HashMap<>();
|
||||
if (!CollectionUtils.isEmpty(billByType)){
|
||||
result = billByType.stream().collect(Collectors.toMap(YearAmnt::getSettingId, YearAmnt::getMoney, (k1, k2) -> k1));
|
||||
}
|
||||
return ResponseDTO.ok().setData(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,7 +107,11 @@ public class WxSettingsController extends BaseWxController{
|
||||
@PostMapping("user/settings/income")
|
||||
public ResponseDTO getBillIncome(HttpServletRequest request){
|
||||
List<YearAmnt> billByType = accSettingService.getBillByType(getLoginUserId(request), AccSettingType.INCOME_SETTING);
|
||||
return ResponseDTO.ok().setData(billByType);
|
||||
Map<Integer,Double> result = new HashMap<>();
|
||||
if (!CollectionUtils.isEmpty(billByType)){
|
||||
result = billByType.stream().collect(Collectors.toMap(YearAmnt::getSettingId, YearAmnt::getMoney, (k1, k2) -> k1));
|
||||
}
|
||||
return ResponseDTO.ok().setData(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class CodeGenerator {
|
||||
|
||||
// 5、策略配置
|
||||
StrategyConfig strategy = new StrategyConfig();
|
||||
strategy.setInclude("qn_acc_bill");//设置要映射的表名
|
||||
strategy.setInclude("qn_acc_setting");//设置要映射的表名
|
||||
strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略
|
||||
strategy.setTablePrefix("qn_");//设置表前缀不生成
|
||||
|
||||
|
||||
16
src/main/java/com/quinn/mapper/AccBillMapper.java
Normal file
16
src/main/java/com/quinn/mapper/AccBillMapper.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.quinn.mapper;
|
||||
|
||||
import com.quinn.pojo.AccBill;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author limqsh
|
||||
* @since 2023-02-02
|
||||
*/
|
||||
public interface AccBillMapper extends BaseMapper<AccBill> {
|
||||
|
||||
}
|
||||
21
src/main/java/com/quinn/mapper/AccSettingMapper.java
Normal file
21
src/main/java/com/quinn/mapper/AccSettingMapper.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.quinn.mapper;
|
||||
|
||||
import com.quinn.common.wx.AccSettingType;
|
||||
import com.quinn.common.wx.YearAmnt;
|
||||
import com.quinn.pojo.AccSetting;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author limqsh
|
||||
* @since 2023-02-02
|
||||
*/
|
||||
public interface AccSettingMapper extends BaseMapper<AccSetting> {
|
||||
|
||||
List<YearAmnt> getBillByType(String userId, AccSettingType settingType);
|
||||
}
|
||||
5
src/main/java/com/quinn/mapper/xml/AccBillMapper.xml
Normal file
5
src/main/java/com/quinn/mapper/xml/AccBillMapper.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?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.AccBillMapper">
|
||||
|
||||
</mapper>
|
||||
11
src/main/java/com/quinn/mapper/xml/AccSettingMapper.xml
Normal file
11
src/main/java/com/quinn/mapper/xml/AccSettingMapper.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?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.AccSettingMapper">
|
||||
|
||||
<select id="getBillByType" resultType="com.quinn.common.wx.YearAmnt">
|
||||
select a.bill_type "settingId",sum(a.money) "money" from qn_acc_bill a,qn_acc_setting b
|
||||
where a.bill_type = b.id and a.user_id = #{userId} and b.setting_type = #{settingType}
|
||||
group by a.bill_type
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
54
src/main/java/com/quinn/pojo/AccBill.java
Normal file
54
src/main/java/com/quinn/pojo/AccBill.java
Normal file
@@ -0,0 +1,54 @@
|
||||
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-02
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("qn_acc_bill")
|
||||
@ApiModel(value="AccBill对象", description="")
|
||||
public class AccBill implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "自增id")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty(value = "金额")
|
||||
private Double money;
|
||||
|
||||
@ApiModelProperty(value = "账单分类ID")
|
||||
private Integer billType;
|
||||
|
||||
@ApiModelProperty(value = "账户分类ID")
|
||||
private Integer accountType;
|
||||
|
||||
private Date date;
|
||||
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty(value = "收藏创建时间")
|
||||
private Date gmtCreate;
|
||||
|
||||
|
||||
}
|
||||
55
src/main/java/com/quinn/pojo/AccSetting.java
Normal file
55
src/main/java/com/quinn/pojo/AccSetting.java
Normal file
@@ -0,0 +1,55 @@
|
||||
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 com.quinn.common.wx.AccSettingType;
|
||||
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-06
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("qn_acc_setting")
|
||||
@ApiModel(value="AccSetting对象", description="")
|
||||
public class AccSetting implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "自增id")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "设置类型1-支出 2-收入 3-账户")
|
||||
private AccSettingType settingType;
|
||||
|
||||
@ApiModelProperty(value = "0-普通账户 1-负债账户")
|
||||
private String accType;
|
||||
|
||||
@ApiModelProperty(value = "收藏者id")
|
||||
private String icon;
|
||||
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty(value = "收藏创建时间")
|
||||
private Date gmtCreate;
|
||||
|
||||
|
||||
}
|
||||
16
src/main/java/com/quinn/service/AccBillService.java
Normal file
16
src/main/java/com/quinn/service/AccBillService.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.quinn.service;
|
||||
|
||||
import com.quinn.pojo.AccBill;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author limqsh
|
||||
* @since 2023-02-02
|
||||
*/
|
||||
public interface AccBillService extends IService<AccBill> {
|
||||
|
||||
}
|
||||
22
src/main/java/com/quinn/service/AccSettingService.java
Normal file
22
src/main/java/com/quinn/service/AccSettingService.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.quinn.service;
|
||||
|
||||
import com.quinn.common.wx.AccSettingType;
|
||||
import com.quinn.common.wx.YearAmnt;
|
||||
import com.quinn.pojo.AccSetting;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author limqsh
|
||||
* @since 2023-02-02
|
||||
*/
|
||||
public interface AccSettingService extends IService<AccSetting> {
|
||||
|
||||
List<YearAmnt> getBillByType(String userId, AccSettingType accSetting);
|
||||
|
||||
}
|
||||
20
src/main/java/com/quinn/service/impl/AccBillServiceImpl.java
Normal file
20
src/main/java/com/quinn/service/impl/AccBillServiceImpl.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.quinn.service.impl;
|
||||
|
||||
import com.quinn.pojo.AccBill;
|
||||
import com.quinn.mapper.AccBillMapper;
|
||||
import com.quinn.service.AccBillService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author limqsh
|
||||
* @since 2023-02-02
|
||||
*/
|
||||
@Service
|
||||
public class AccBillServiceImpl extends ServiceImpl<AccBillMapper, AccBill> implements AccBillService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.quinn.service.impl;
|
||||
|
||||
import com.quinn.common.wx.AccSettingType;
|
||||
import com.quinn.common.wx.YearAmnt;
|
||||
import com.quinn.pojo.AccSetting;
|
||||
import com.quinn.mapper.AccSettingMapper;
|
||||
import com.quinn.service.AccSettingService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author limqsh
|
||||
* @since 2023-02-02
|
||||
*/
|
||||
@Service
|
||||
public class AccSettingServiceImpl extends ServiceImpl<AccSettingMapper, AccSetting> implements AccSettingService {
|
||||
|
||||
@Resource
|
||||
AccSettingMapper accSettingMapper;
|
||||
|
||||
@Override
|
||||
public List<YearAmnt> getBillByType(String userId, AccSettingType settingType) {
|
||||
return accSettingMapper.getBillByType(userId,settingType);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user