From 6fe2d3e9a1348078cc7ffad1c55968c5ad97e207 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期二, 23 四月 2024 11:53:34 +0800
Subject: [PATCH] 核算报告代码生成

---
 ycl-server/src/main/java/com/ycl/platform/controller/CalculateReportController.java    |   87 +++++++++
 ycl-pojo/src/main/java/com/ycl/platform/domain/vo/CalculateReportVO.java               |   52 +++++
 ycl-server/src/main/java/com/ycl/platform/service/impl/CalculateReportServiceImpl.java |  145 ++++++++++++++++
 ycl-pojo/src/main/java/com/ycl/platform/domain/form/CalculateReportForm.java           |   62 ++++++
 ycl-pojo/src/main/java/com/ycl/platform/domain/entity/CalculateReport.java             |   52 +++++
 ycl-server/src/main/java/com/ycl/platform/mapper/CalculateReportMapper.java            |   19 ++
 ycl-server/src/main/java/com/ycl/platform/service/CalculateReportService.java          |   65 +++++++
 ycl-pojo/src/main/java/com/ycl/platform/domain/query/CalculateReportQuery.java         |   23 ++
 8 files changed, 505 insertions(+), 0 deletions(-)

diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/entity/CalculateReport.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/entity/CalculateReport.java
new file mode 100644
index 0000000..733a28d
--- /dev/null
+++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/entity/CalculateReport.java
@@ -0,0 +1,52 @@
+package com.ycl.platform.domain.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import com.ycl.platform.base.AbsEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * 鏍哥畻鎶ュ憡
+ *
+ * @author xp
+ * @since 2024-04-23
+ */
+@Data
+@Accessors(chain = true)
+@TableName("t_calculate_report")
+@ApiModel(value = "CalculateReport瀵硅薄", description = "鏍哥畻鎶ュ憡")
+public class CalculateReport extends AbsEntity {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty("鍚堝悓")
+    @TableField("contract_id")
+    private Integer contractId;
+
+    @ApiModelProperty("鏍哥畻鏃ユ湡")
+    @TableField("calculate_time")
+    private LocalDateTime calculateTime;
+
+    @ApiModelProperty("鎵e噺鎬婚噾棰�")
+    @TableField("deduct_money")
+    private BigDecimal deductMoney;
+
+    @ApiModelProperty("鍝勾鐨�")
+    @TableField("which_year")
+    private Integer whichYear;
+
+    @ApiModelProperty("鍝湀鐨�")
+    @TableField("which_month")
+    private Integer whichMonth;
+
+    @ApiModelProperty("淇敼浜�")
+    @TableField("update_by")
+    private Long updateBy;
+
+
+}
diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/form/CalculateReportForm.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/form/CalculateReportForm.java
new file mode 100644
index 0000000..07c53f0
--- /dev/null
+++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/form/CalculateReportForm.java
@@ -0,0 +1,62 @@
+package com.ycl.platform.domain.form;
+
+import com.ycl.system.domain.group.Update;
+import com.ycl.system.domain.group.Add;
+import com.ycl.platform.base.AbsForm;
+import com.ycl.platform.domain.entity.CalculateReport;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import org.springframework.beans.BeanUtils;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import org.springframework.lang.NonNull;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * 鏍哥畻鎶ュ憡琛ㄥ崟
+ *
+ * @author xp
+ * @since 2024-04-23
+ */
+@Data
+@Accessors(chain = true)
+@ApiModel(value = "CalculateReport琛ㄥ崟", description = "鏍哥畻鎶ュ憡琛ㄥ崟")
+public class CalculateReportForm extends AbsForm {
+
+    @NotNull(message = "鍚堝悓涓嶈兘涓虹┖", groups = {Add.class, Update.class})
+    @ApiModelProperty("鍚堝悓")
+    private Integer contractId;
+
+    @NotNull(message = "鏍哥畻鏃ユ湡涓嶈兘涓虹┖", groups = {Add.class, Update.class})
+    @ApiModelProperty("鏍哥畻鏃ユ湡")
+    private LocalDateTime calculateTime;
+
+    @NotNull(message = "鎵e噺鎬婚噾棰濅笉鑳戒负绌�", groups = {Add.class, Update.class})
+    @ApiModelProperty("鎵e噺鎬婚噾棰�")
+    private BigDecimal deductMoney;
+
+    @NotNull(message = "鍝勾鐨勪笉鑳戒负绌�", groups = {Add.class, Update.class})
+    @ApiModelProperty("鍝勾鐨�")
+    private Integer whichYear;
+
+    @NotNull(message = "鍝湀鐨勪笉鑳戒负绌�", groups = {Add.class, Update.class})
+    @ApiModelProperty("鍝湀鐨�")
+    private Integer whichMonth;
+
+    @NotNull(message = "淇敼浜轰笉鑳戒负绌�", groups = {Add.class, Update.class})
+    @ApiModelProperty("淇敼浜�")
+    private Long updateBy;
+
+    public static CalculateReport getEntityByForm(@NonNull CalculateReportForm form, CalculateReport entity) {
+        if(entity == null) {
+          entity = new CalculateReport();
+        }
+        BeanUtils.copyProperties(form, entity);
+        return entity;
+    }
+
+}
diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/query/CalculateReportQuery.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/query/CalculateReportQuery.java
new file mode 100644
index 0000000..328a6d8
--- /dev/null
+++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/query/CalculateReportQuery.java
@@ -0,0 +1,23 @@
+package com.ycl.platform.domain.query;
+
+import com.ycl.platform.base.AbsQuery;
+import java.util.List;
+import org.springframework.lang.NonNull;
+import jakarta.validation.constraints.NotBlank;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * 鏍哥畻鎶ュ憡鏌ヨ
+ *
+ * @author xp
+ * @since 2024-04-23
+ */
+@Data
+@Accessors(chain = true)
+@ApiModel(value = "CalculateReport鏌ヨ", description = "鏍哥畻鎶ュ憡鏌ヨ")
+public class CalculateReportQuery extends AbsQuery {
+}
+
diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/vo/CalculateReportVO.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/vo/CalculateReportVO.java
new file mode 100644
index 0000000..6252ece
--- /dev/null
+++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/vo/CalculateReportVO.java
@@ -0,0 +1,52 @@
+package com.ycl.platform.domain.vo;
+
+import com.ycl.platform.base.AbsVo;
+import com.ycl.platform.domain.entity.CalculateReport;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.time.LocalDateTime;
+import org.springframework.lang.NonNull;
+import org.springframework.beans.BeanUtils;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * 鏍哥畻鎶ュ憡灞曠ず
+ *
+ * @author xp
+ * @since 2024-04-23
+ */
+@Data
+@Accessors(chain = true)
+public class CalculateReportVO extends AbsVo {
+
+    /** 鍚堝悓 */
+    private Integer contractId;
+
+    /** 鏍哥畻鏃ユ湡 */
+    private LocalDateTime calculateTime;
+
+    /** 鎵e噺鎬婚噾棰� */
+    private BigDecimal deductMoney;
+
+    /** 鍝勾鐨� */
+    private Integer whichYear;
+
+    /** 鍝湀鐨� */
+    private Integer whichMonth;
+
+    /** 淇敼浜� */
+    private Long updateBy;
+
+    public static CalculateReportVO getVoByEntity(@NonNull CalculateReport entity, CalculateReportVO vo) {
+        if(vo == null) {
+            vo = new CalculateReportVO();
+        }
+        BeanUtils.copyProperties(entity, vo);
+        return vo;
+    }
+
+}
diff --git a/ycl-server/src/main/java/com/ycl/platform/controller/CalculateReportController.java b/ycl-server/src/main/java/com/ycl/platform/controller/CalculateReportController.java
new file mode 100644
index 0000000..04330b7
--- /dev/null
+++ b/ycl-server/src/main/java/com/ycl/platform/controller/CalculateReportController.java
@@ -0,0 +1,87 @@
+package com.ycl.platform.controller;
+
+import com.ycl.system.domain.group.Update;
+import com.ycl.system.domain.group.Add;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import lombok.RequiredArgsConstructor;
+import java.util.List;
+import org.springframework.validation.annotation.Validated;
+import jakarta.validation.constraints.NotEmpty;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import com.ycl.platform.service.CalculateReportService;
+import com.ycl.system.Result;
+import com.ycl.platform.domain.form.CalculateReportForm;
+import com.ycl.platform.domain.query.CalculateReportQuery;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 鏍哥畻鎶ュ憡 鍓嶇鎺у埗鍣�
+ *
+ * @author xp
+ * @since 2024-04-23
+ */
+@Validated
+@RequiredArgsConstructor
+@Api(value = "鏍哥畻鎶ュ憡", tags = "鏍哥畻鎶ュ憡绠$悊")
+@RestController
+@RequestMapping("/calculate-report")
+public class CalculateReportController {
+
+    private final CalculateReportService calculateReportService;
+
+//    @PostMapping
+//    @ApiOperation(value = "娣诲姞", notes = "娣诲姞")
+//    public Result add(@RequestBody @Validated(Add.class) CalculateReportForm form) {
+//        return calculateReportService.add(form);
+//    }
+
+//    @PutMapping
+//    @ApiOperation(value = "淇敼", notes = "淇敼")
+//    public Result update(@RequestBody @Validated(Update.class) CalculateReportForm form) {
+//        return calculateReportService.update(form);
+//    }
+
+    @PutMapping
+    @ApiOperation(value = "淇敼閲戦", notes = "淇敼閲戦")
+    @PreAuthorize("@ss.hasPermi('system:calculate:report:edit:money')")
+    public Result adjustMoney(@RequestBody @Validated(Update.class) CalculateReportForm form) {
+        return calculateReportService.update(form);
+    }
+
+    @GetMapping("/page")
+    @ApiOperation(value = "鍒嗛〉", notes = "鍒嗛〉")
+    @PreAuthorize("@ss.hasPermi('system:calculate:report:page')")
+    public Result page(CalculateReportQuery query) {
+        return calculateReportService.page(query);
+    }
+
+    @GetMapping("/{id}")
+    @ApiOperation(value = "璇︽儏", notes = "璇︽儏")
+    @PreAuthorize("@ss.hasPermi('system:calculate:report:detail')")
+    public Result detail(@PathVariable("id") String id) {
+        return calculateReportService.detail(id);
+    }
+
+//    @GetMapping("/list")
+//    @ApiOperation(value = "鍒楄〃", notes = "鍒楄〃")
+//    public Result list() {
+//        return calculateReportService.all();
+//    }
+
+//    @DeleteMapping("/{id}")
+//    @ApiOperation(value = "ID鍒犻櫎", notes = "ID鍒犻櫎")
+//    public Result removeById(@PathVariable("id") String id) {
+//        return calculateReportService.removeById(id);
+//    }
+//
+//    @DeleteMapping("/batch")
+//    @ApiOperation(value = "鎵归噺鍒犻櫎", notes = "鎵归噺鍒犻櫎")
+//    public Result remove(@RequestBody @NotEmpty(message = "璇烽�夋嫨鏁版嵁") List<String> ids) {
+//        return calculateReportService.remove(ids);
+//    }
+
+
+}
diff --git a/ycl-server/src/main/java/com/ycl/platform/mapper/CalculateReportMapper.java b/ycl-server/src/main/java/com/ycl/platform/mapper/CalculateReportMapper.java
new file mode 100644
index 0000000..96aa60a
--- /dev/null
+++ b/ycl-server/src/main/java/com/ycl/platform/mapper/CalculateReportMapper.java
@@ -0,0 +1,19 @@
+package com.ycl.platform.mapper;
+
+import com.ycl.platform.domain.entity.CalculateReport;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ycl.platform.domain.vo.CalculateReportVO;
+import com.ycl.platform.domain.form.CalculateReportForm;
+import java.util.List;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 鏍哥畻鎶ュ憡 Mapper 鎺ュ彛
+ *
+ * @author xp
+ * @since 2024-04-23
+ */
+@Mapper
+public interface CalculateReportMapper extends BaseMapper<CalculateReport> {
+
+}
diff --git a/ycl-server/src/main/java/com/ycl/platform/service/CalculateReportService.java b/ycl-server/src/main/java/com/ycl/platform/service/CalculateReportService.java
new file mode 100644
index 0000000..7c0b835
--- /dev/null
+++ b/ycl-server/src/main/java/com/ycl/platform/service/CalculateReportService.java
@@ -0,0 +1,65 @@
+package com.ycl.platform.service;
+
+import com.ycl.platform.domain.entity.CalculateReport;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ycl.system.Result;
+import com.ycl.platform.domain.form.CalculateReportForm;
+import com.ycl.platform.domain.query.CalculateReportQuery;
+import java.util.List;
+
+/**
+ * 鏍哥畻鎶ュ憡 鏈嶅姟绫�
+ *
+ * @author xp
+ * @since 2024-04-23
+ */
+public interface CalculateReportService extends IService<CalculateReport> {
+
+    /**
+     * 娣诲姞
+     * @param form
+     * @return
+     */
+    Result add(CalculateReportForm form);
+
+    /**
+     * 淇敼
+     * @param form
+     * @return
+     */
+    Result update(CalculateReportForm form);
+
+    /**
+     * 鎵归噺鍒犻櫎
+     * @param ids
+     * @return
+     */
+    Result remove(List<String> ids);
+
+    /**
+     * id鍒犻櫎
+     * @param id
+     * @return
+     */
+    Result removeById(String id);
+
+    /**
+     * 鍒嗛〉鏌ヨ
+     * @param query
+     * @return
+     */
+    Result page(CalculateReportQuery query);
+
+    /**
+     * 鏍规嵁id鏌ユ壘
+     * @param id
+     * @return
+     */
+    Result detail(String id);
+
+    /**
+     * 鍒楄〃
+     * @return
+     */
+    Result all();
+}
diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/CalculateReportServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/CalculateReportServiceImpl.java
new file mode 100644
index 0000000..b599917
--- /dev/null
+++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/CalculateReportServiceImpl.java
@@ -0,0 +1,145 @@
+package com.ycl.platform.service.impl;
+
+import com.ycl.platform.domain.entity.CalculateReport;
+import com.ycl.platform.mapper.CalculateReportMapper;
+import com.ycl.platform.service.CalculateReportService;
+import com.ycl.system.Result;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ycl.platform.domain.form.CalculateReportForm;
+import com.ycl.platform.domain.vo.CalculateReportVO;
+import com.ycl.platform.domain.query.CalculateReportQuery;
+import java.util.List;
+import org.apache.commons.lang3.StringUtils;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.ycl.system.page.PageUtil;
+import org.springframework.stereotype.Service;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.beans.BeanUtils;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.Assert;
+import java.util.ArrayList;
+import java.util.stream.Collectors;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
+import lombok.RequiredArgsConstructor;
+
+/**
+ * 鏍哥畻鎶ュ憡 鏈嶅姟瀹炵幇绫�
+ *
+ * @author xp
+ * @since 2024-04-23
+ */
+@Service
+@RequiredArgsConstructor
+public class CalculateReportServiceImpl extends ServiceImpl<CalculateReportMapper, CalculateReport> implements CalculateReportService {
+
+    private final CalculateReportMapper calculateReportMapper;
+
+    /**
+     * 娣诲姞
+     * @param form
+     * @return
+     */
+    @Override
+    public Result add(CalculateReportForm form) {
+        CalculateReport entity = CalculateReportForm.getEntityByForm(form, null);
+        if(baseMapper.insert(entity) > 0) {
+            return Result.ok("娣诲姞鎴愬姛");
+        }
+        return Result.error("娣诲姞澶辫触");
+    }
+
+    /**
+     * 淇敼
+     * @param form
+     * @return
+     */
+    @Override
+    public Result update(CalculateReportForm form) {
+
+        CalculateReport entity = baseMapper.selectById(form.getId());
+
+        // 涓虹┖鎶汭llegalArgumentException锛屽仛鍏ㄥ眬寮傚父澶勭悊
+        Assert.notNull(entity, "璁板綍涓嶅瓨鍦�");
+        BeanUtils.copyProperties(form, entity);
+        if (baseMapper.updateById(entity) > 0) {
+            return Result.ok("淇敼鎴愬姛");
+        }
+        return Result.error("淇敼澶辫触");
+    }
+
+    /**
+     * 鎵归噺鍒犻櫎
+     * @param ids
+     * @return
+     */
+    @Override
+    public Result remove(List<String> ids) {
+        if(baseMapper.deleteBatchIds(ids) > 0) {
+            return Result.ok("鍒犻櫎鎴愬姛");
+        }
+        return Result.error("鍒犻櫎澶辫触");
+    }
+
+    /**
+     * id鍒犻櫎
+     * @param id
+     * @return
+     */
+    @Override
+    public Result removeById(String id) {
+        if(baseMapper.deleteById(id) > 0) {
+            return Result.ok("鍒犻櫎鎴愬姛");
+        }
+        return Result.error("鍒犻櫎澶辫触");
+    }
+
+    /**
+     * 鍒嗛〉鏌ヨ
+     * @param query
+     * @return
+     */
+    @Override
+    public Result page(CalculateReportQuery query) {
+
+        IPage<CalculateReport> page = new LambdaQueryChainWrapper<>(baseMapper)
+                .orderByDesc(CalculateReport::getCreateTime)
+                .page(PageUtil.getPage(query, CalculateReport.class));
+
+        List<CalculateReportVO> vos = page.getRecords().stream()
+                .map(
+                        entity -> CalculateReportVO.getVoByEntity(entity, null)
+                )
+                .collect(Collectors.toList());
+        return Result.ok().data(vos).total(page.getTotal());
+    }
+
+    /**
+     * 鏍规嵁id鏌ユ壘
+     * @param id
+     * @return
+     */
+    @Override
+    public Result detail(String id) {
+
+        CalculateReport entity = baseMapper.selectById(id);
+        Assert.notNull(entity, "璁板綍涓嶅瓨鍦�");
+        CalculateReportVO vo = CalculateReportVO.getVoByEntity(entity, null);
+        return Result.ok().data(vo);
+    }
+
+    /**
+     * 鍒楄〃
+     * @return
+     */
+    @Override
+    public Result all() {
+        List<CalculateReport> entities = baseMapper.selectList(null);
+        List<CalculateReportVO> vos = entities.stream()
+                .map(
+                        entity -> CalculateReportVO.getVoByEntity(entity, null)
+                )
+                .collect(Collectors.toList());
+        return Result.ok().data(vos);
+    }
+}

--
Gitblit v1.8.0