Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add income expense api and data object #212 #216

Merged
merged 8 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
* with the License. A copy of the License is located at
*
* http://opensource.wansenai.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.wansenai.api.basic;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wansenai.dto.basic.AddOrUpdateIncomeExpenseDTO;
import com.wansenai.dto.basic.QueryIncomeExpenseDTO;
import com.wansenai.service.basic.IncomeExpenseService;
import com.wansenai.utils.response.Response;
import com.wansenai.vo.basic.IncomeExpenseVO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;

@RestController
@RequestMapping("/basic/incomeExpense")
public class IncomeExpenseController {

private final IncomeExpenseService incomeExpenseService;

public IncomeExpenseController(IncomeExpenseService incomeExpenseService) {
this.incomeExpenseService = incomeExpenseService;
}

@PostMapping("pageList")
public Response<Page<IncomeExpenseVO>> getIncomeExpensePageList(@RequestBody QueryIncomeExpenseDTO queryIncomeExpenseDTO) {
return incomeExpenseService.getIncomeExpensePageList(queryIncomeExpenseDTO);
}

@PostMapping("addOrUpdate")
public Response<String> addOrUpdateIncomeExpense(@RequestBody AddOrUpdateIncomeExpenseDTO addOrUpdateIncomeExpenseDTO) {
return incomeExpenseService.addOrUpdateIncomeExpense(addOrUpdateIncomeExpenseDTO);
}

@DeleteMapping("deleteBatch")
public Response<String> deleteIncomeExpense(@RequestParam("ids") List<Long> ids) {
return incomeExpenseService.deleteBatchIncomeExpense(ids);
}

@PostMapping("updateStatus")
public Response<String> updateIncomeExpenseStatus(@RequestParam("ids") List<Long> ids, @RequestParam("status") Integer status) {
return incomeExpenseService.updateIncomeExpenseStatus(ids, status);
}

@GetMapping("list/{type}")
public Response<List<IncomeExpenseVO>> getIncomeExpenseList(@PathVariable("type") String type) {
return incomeExpenseService.getIncomeExpenseListByType(type);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.wansenai.service;
package com.wansenai.dto.basic;

import com.wansenai.entities.IncomeExpense;
import com.baomidou.mybatisplus.extension.service.IService;
import lombok.Data;

/**
* <p>
* 收支项目 服务类
* </p>
*/
public interface IIncomeExpenseService extends IService<IncomeExpense> {
@Data
public class AddOrUpdateIncomeExpenseDTO {

private Long id;

private String name;

private String type;

private String remark;

private Integer status;

private Integer sort;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,24 @@
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.wansenai.api;
package com.wansenai.dto.basic;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import lombok.Data;

/**
* <p>
* 收支项目 前端控制器
* </p>
*
* @author James Zow
* @since 2023-09-05
*/
@RestController
@RequestMapping("/incomeExpense")
public class IncomeExpenseController {
@Data
public class QueryIncomeExpenseDTO {

private String name;

private String type;

private String remark;

private Long page;

private Long pageSize;

private String startDate;

private String endDate;
}
14 changes: 10 additions & 4 deletions core/domain/src/main/java/com/wansenai/entities/IncomeExpense.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;

import java.io.Serial;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;

import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
Expand All @@ -27,12 +31,14 @@
* </p>
*/
@Data
@Builder
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("income_expense")
public class IncomeExpense implements Serializable {

private static final long serialVersionUID = 1L;
@Serial
private static final long serialVersionUID = 799164139936218L;

/**
* 主键
Expand Down Expand Up @@ -63,12 +69,12 @@ public class IncomeExpense implements Serializable {
/**
* 启用
*/
private Boolean status;
private Integer status;

/**
* 排序
*/
private String sort;
private Integer sort;

/**
* 创建时间
Expand All @@ -93,7 +99,7 @@ public class IncomeExpense implements Serializable {
/**
* 删除标记,0未删除,1删除
*/
private Boolean deleteFlag;
private Integer deleteFlag;


}
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,31 @@
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.wansenai.service;
package com.wansenai.vo.basic;

import com.wansenai.entities.IncomeExpense;
import com.wansenai.mappers.IncomeExpenseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Builder;
import lombok.Data;

/**
* <p>
* 收支项目 服务实现类
* </p>
*/
@Service
public class IncomeExpenseServiceImpl extends ServiceImpl<IncomeExpenseMapper, IncomeExpense> implements IIncomeExpenseService {
import java.time.LocalDateTime;

@Data
@Builder
public class IncomeExpenseVO {

@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long id;

private String name;

private String type;

private Integer status;

private Integer sort;

private String remark;

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2023-2033 WanSen AI Team, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
* with the License. A copy of the License is located at
*
* http://opensource.wansenai.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.wansenai.service.basic;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wansenai.dto.basic.AddOrUpdateIncomeExpenseDTO;
import com.wansenai.dto.basic.QueryIncomeExpenseDTO;
import com.wansenai.entities.IncomeExpense;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wansenai.utils.response.Response;
import com.wansenai.vo.basic.IncomeExpenseVO;

import java.util.List;

public interface IncomeExpenseService extends IService<IncomeExpense> {

Response<Page<IncomeExpenseVO>> getIncomeExpensePageList(QueryIncomeExpenseDTO queryIncomeExpenseDTO);

Response<String> addOrUpdateIncomeExpense(AddOrUpdateIncomeExpenseDTO addOrUpdateIncomeExpenseDTO);

Response<String> deleteBatchIncomeExpense(List<Long> ids);

Response<String> updateIncomeExpenseStatus(List<Long> ids, Integer status);

Response<List<IncomeExpenseVO>> getIncomeExpenseListByType(String type);
}
Loading