From dc194fb281e0e4c4ec34549adb4ad11f3cb67b35 Mon Sep 17 00:00:00 2001
From: whywhyo <1511349576@qq.com>
Date: 星期一, 05 六月 2023 20:13:30 +0800
Subject: [PATCH] 123

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZPropertyController.java |  113 ++++++++++
 zhang-content/src/main/java/com/ruoyi/service/impl/ZIdeaServiceImpl.java          |  119 ++++++++++
 ruoyi-admin/src/main/resources/application-druid.yml                              |    4 
 zhang-content/src/main/java/com/ruoyi/domain/ZProperty.java                       |   33 ++
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZIdeaController.java     |  114 ++++++++++
 zhang-content/src/main/java/com/ruoyi/service/ZPropertyService.java               |   13 +
 zhang-content/src/main/java/com/ruoyi/service/impl/ZPropertyServiceImpl.java      |  118 ++++++++++
 zhang-content/src/main/java/com/ruoyi/domain/ZIdea.java                           |  103 ++------
 zhang-content/src/main/java/com/ruoyi/service/ZIdeaService.java                   |   13 +
 9 files changed, 543 insertions(+), 87 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZIdeaController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZIdeaController.java
index 448ec30..e9e5c5e 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZIdeaController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZIdeaController.java
@@ -1,9 +1,27 @@
 package com.ruoyi.web.controller.zhang;
 
 
-import org.springframework.web.bind.annotation.RequestMapping;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.text.Convert;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.ServletUtils;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.domain.ZIdea;
+import com.ruoyi.service.ZIdeaService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
-import org.springframework.web.bind.annotation.RestController;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static com.ruoyi.common.core.page.TableSupport.PAGE_NUM;
+import static com.ruoyi.common.core.page.TableSupport.PAGE_SIZE;
 
 /**
  * <p>
@@ -15,7 +33,97 @@
  */
 @RestController
 @RequestMapping("/zIdea")
-public class ZIdeaController {
+@Slf4j
+public class ZIdeaController extends BaseController {
+
+    @Autowired
+    private ZIdeaService zIdeaService;
+
+    /**
+     * 鏌ヨ鎵�鏈夎褰�
+     */
+    @GetMapping("/all")
+    public AjaxResult listAll(ZIdea zIdea){
+        Integer pageNum = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1);
+        Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10);
+        return zIdeaService.selectDataList(zIdea,pageNum,pageSize);
+    }
+
+    /**
+     * 鏍规嵁id鏌ヨ
+     */
+    @GetMapping()
+    public AjaxResult listById(Long id){
+        return AjaxResult.success(zIdeaService.getById(id));
+    }
+
+    /**
+     * 妯℃澘
+     */
+    @GetMapping("/model")
+    public void getModel(HttpServletResponse response){
+        ZIdea zIdea = new ZIdea();
+        List<ZIdea> emptyList = Collections.singletonList(zIdea);
+        ExcelUtil<ZIdea> util = new ExcelUtil<>(ZIdea.class);
+        util.exportExcel(response, emptyList, "鐧惧勾蹇冩効璁板綍鏁版嵁");
+    }
+
+    /**
+     * 瀵煎嚭鐧惧勾蹇冩効璁板綍鍒楄〃
+     */
+//    @PreAuthorize("@ss.hasPermi('system:property:export')")
+    @Log(title = "鐧惧勾蹇冩効璁板綍", businessType = BusinessType.EXPORT)
+    @PostMapping("/export/{ids}")
+    public void export(HttpServletResponse response,@PathVariable Long[] ids)
+    {
+        List<ZIdea> list = zIdeaService.selectByIds(ids);
+        log.info("瀵煎嚭璁板綍涓�:{}",list);
+        ExcelUtil<ZIdea> util = new ExcelUtil<>(ZIdea.class);
+        util.exportExcel(response, list, "鐧惧勾蹇冩効璁板綍鏁版嵁");
+    }
+
+    /**
+     * 瀵煎叆鐧惧勾蹇冩効璁板綍鍒楄〃
+     */
+    @Log(title = "鐢ㄦ埛绠$悊", businessType = BusinessType.IMPORT)
+    @PostMapping("/importData")
+    public AjaxResult importData(@RequestParam("excelImport") MultipartFile file) throws Exception
+    {
+        return zIdeaService.importExcel(file);
+    }
+
+    /**
+     * 鏂板鐧惧勾蹇冩効璁板綍
+     */
+//    @PreAuthorize("@ss.hasPermi('system:property:add')")
+    @Log(title = "鐧惧勾蹇冩効璁板綍", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody ZIdea zIdea)
+    {
+        return zIdeaService.mySave(zIdea);
+    }
+
+    /**
+     * 淇敼鐧惧勾蹇冩効璁板綍
+     */
+//    @PreAuthorize("@ss.hasPermi('system:property:edit')")
+    @Log(title = "鐧惧勾蹇冩効璁板綍", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody ZIdea zIdea)
+    {
+        return toAjax(zIdeaService.updateById(zIdea));
+    }
+//
+    /**
+     * 鎵归噺鍒犻櫎鐧惧勾蹇冩効璁板綍
+     */
+//    @PreAuthorize("@ss.hasPermi('system:property:remove')")
+    @Log(title = "鐧惧勾蹇冩効璁板綍", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(zIdeaService.removeByIds(Arrays.asList(ids)));
+    }
 
 }
 
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZPropertyController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZPropertyController.java
index fc68427..8177101 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZPropertyController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZPropertyController.java
@@ -1,9 +1,27 @@
 package com.ruoyi.web.controller.zhang;
 
 
-import org.springframework.web.bind.annotation.RequestMapping;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.text.Convert;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.ServletUtils;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.domain.ZProperty;
+import com.ruoyi.service.ZPropertyService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
-import org.springframework.web.bind.annotation.RestController;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static com.ruoyi.common.core.page.TableSupport.PAGE_NUM;
+import static com.ruoyi.common.core.page.TableSupport.PAGE_SIZE;
 
 /**
  * <p>
@@ -15,7 +33,96 @@
  */
 @RestController
 @RequestMapping("/zProperty")
-public class ZPropertyController {
+@Slf4j
+public class ZPropertyController extends BaseController {
+    @Autowired
+    private ZPropertyService zPropertyService;
+
+    /**
+     * 鏌ヨ鎵�鏈夎褰�
+     */
+    @GetMapping("/all")
+    public AjaxResult listAll(ZProperty zProperty){
+        Integer pageNum = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1);
+        Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10);
+        return zPropertyService.selectDataList(zProperty,pageNum,pageSize);
+    }
+
+    /**
+     * 鏍规嵁id鏌ヨ
+     */
+    @GetMapping()
+    public AjaxResult listById(Long id){
+        return AjaxResult.success(zPropertyService.getById(id));
+    }
+
+    /**
+     * 妯℃澘
+     */
+    @GetMapping("/model")
+    public void getModel(HttpServletResponse response){
+        ZProperty zProperty = new ZProperty();
+        List<ZProperty> emptyList = Collections.singletonList(zProperty);
+        ExcelUtil<ZProperty> util = new ExcelUtil<>(ZProperty.class);
+        util.exportExcel(response, emptyList, "涓汉璐骇璁板綍鏁版嵁");
+    }
+
+    /**
+     * 瀵煎嚭涓汉璐骇璁板綍鍒楄〃
+     */
+//    @PreAuthorize("@ss.hasPermi('system:property:export')")
+    @Log(title = "涓汉璐骇璁板綍", businessType = BusinessType.EXPORT)
+    @PostMapping("/export/{ids}")
+    public void export(HttpServletResponse response,@PathVariable Long[] ids)
+    {
+        List<ZProperty> list = zPropertyService.selectByIds(ids);
+        log.info("瀵煎嚭璁板綍涓�:{}",list);
+        ExcelUtil<ZProperty> util = new ExcelUtil<>(ZProperty.class);
+        util.exportExcel(response, list, "涓汉璐骇璁板綍鏁版嵁");
+    }
+
+    /**
+     * 瀵煎叆涓汉璐骇璁板綍鍒楄〃
+     */
+    @Log(title = "鐢ㄦ埛绠$悊", businessType = BusinessType.IMPORT)
+    @PostMapping("/importData")
+    public AjaxResult importData(@RequestParam("excelImport") MultipartFile file) throws Exception
+    {
+        return zPropertyService.importExcel(file);
+    }
+
+    /**
+     * 鏂板涓汉璐骇璁板綍
+     */
+//    @PreAuthorize("@ss.hasPermi('system:property:add')")
+    @Log(title = "涓汉璐骇璁板綍", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody ZProperty zProperty)
+    {
+        return zPropertyService.mySave(zProperty);
+    }
+
+    /**
+     * 淇敼涓汉璐骇璁板綍
+     */
+//    @PreAuthorize("@ss.hasPermi('system:property:edit')")
+    @Log(title = "涓汉璐骇璁板綍", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody ZProperty zProperty)
+    {
+        return toAjax(zPropertyService.updateById(zProperty));
+    }
+//
+    /**
+     * 鎵归噺鍒犻櫎涓汉璐骇璁板綍
+     */
+//    @PreAuthorize("@ss.hasPermi('system:property:remove')")
+    @Log(title = "涓汉璐骇璁板綍", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(zPropertyService.removeByIds(Arrays.asList(ids)));
+    }
 
 }
 
diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml
index 045d564..b2e66b2 100644
--- a/ruoyi-admin/src/main/resources/application-druid.yml
+++ b/ruoyi-admin/src/main/resources/application-druid.yml
@@ -6,8 +6,8 @@
         druid:
             # 涓诲簱鏁版嵁婧�
             master:
-#                url: jdbc:mysql://47.93.189.255:3306/ruoyi?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
-                url: jdbc:mysql://localhost:3306/ruoyi?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                url: jdbc:mysql://47.93.189.255:3306/ruoyi?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+#                url: jdbc:mysql://localhost:3306/ruoyi?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
                 username: root
                 password: ZhangApp123!
 #                password: 123456
diff --git a/zhang-content/src/main/java/com/ruoyi/domain/ZIdea.java b/zhang-content/src/main/java/com/ruoyi/domain/ZIdea.java
index 6657445..172a52c 100644
--- a/zhang-content/src/main/java/com/ruoyi/domain/ZIdea.java
+++ b/zhang-content/src/main/java/com/ruoyi/domain/ZIdea.java
@@ -1,9 +1,15 @@
 package com.ruoyi.domain;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.annotation.Excel;
+import lombok.Data;
+
 import java.io.Serializable;
+import java.util.Date;
 
 /**
  * <p>
@@ -14,124 +20,75 @@
  * @since 2023-03-14
  */
 @TableName("z_idea")
+@Data
 public class ZIdea implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
     @TableId(value = "id", type = IdType.AUTO)
-    private Integer id;
+    private Long id;
+
+    private Long uid;
+
+    @Excel(name = "鏃堕棿")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date happenTime;
 
     /**
      * 鐞嗘兂鏍囬/鐧惧勾鎰挎湜
      */
+    @Excel(name = "鐞嗘兂鏍囬/鐧惧勾鎰挎湜")
     private String title;
 
     /**
      * 濮嬩簬浣曞洜
      */
+    @Excel(name = "濮嬩簬浣曞洜")
     private String cause;
 
     /**
      * 鍙楁儬浜哄悕瀛�
      */
+    @Excel(name = "鍙楁儬浜哄悕瀛�")
     private String beneficiary;
 
     /**
      * 缁ф壙浜哄悕瀛�
      */
+    @Excel(name = "缁ф壙浜哄悕瀛�")
     private String heir;
 
     /**
      * 瀹炵幇闅惧害
      */
+    @Excel(name = "瀹炵幇闅惧害")
     private String difficulty;
 
     /**
      * 鏄惁渚濇棫鏈夋晥
      */
+    @Excel(name = "鏄惁渚濇棫鏈夋晥(濉槸鎴栧惁)",readConverterExp = "1=鏄�,0=鍚�")
     private Integer isEffective;
 
     /**
      * 澶囨敞
      */
+    @Excel(name = "澶囨敞")
     private String remark;
 
+    private String url;
 
-    public Integer getId() {
-        return id;
-    }
 
-    public void setId(Integer id) {
-        this.id = id;
-    }
+    @TableField(exist = false)
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date happenStartTime;
 
-    public String getTitle() {
-        return title;
-    }
+    @TableField(exist = false)
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date happenEndTime;
 
-    public void setTitle(String title) {
-        this.title = title;
-    }
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date createTime;
 
-    public String getCause() {
-        return cause;
-    }
 
-    public void setCause(String cause) {
-        this.cause = cause;
-    }
-
-    public String getBeneficiary() {
-        return beneficiary;
-    }
-
-    public void setBeneficiary(String beneficiary) {
-        this.beneficiary = beneficiary;
-    }
-
-    public String getHeir() {
-        return heir;
-    }
-
-    public void setHeir(String heir) {
-        this.heir = heir;
-    }
-
-    public String getDifficulty() {
-        return difficulty;
-    }
-
-    public void setDifficulty(String difficulty) {
-        this.difficulty = difficulty;
-    }
-
-    public Integer getIsEffective() {
-        return isEffective;
-    }
-
-    public void setIsEffective(Integer isEffective) {
-        this.isEffective = isEffective;
-    }
-
-    public String getRemark() {
-        return remark;
-    }
-
-    public void setRemark(String remark) {
-        this.remark = remark;
-    }
-
-    @Override
-    public String toString() {
-        return "ZIdea{" +
-        "id=" + id +
-        ", title=" + title +
-        ", cause=" + cause +
-        ", beneficiary=" + beneficiary +
-        ", heir=" + heir +
-        ", difficulty=" + difficulty +
-        ", isEffective=" + isEffective +
-        ", remark=" + remark +
-        "}";
-    }
 }
diff --git a/zhang-content/src/main/java/com/ruoyi/domain/ZProperty.java b/zhang-content/src/main/java/com/ruoyi/domain/ZProperty.java
index 9709e07..f932166 100644
--- a/zhang-content/src/main/java/com/ruoyi/domain/ZProperty.java
+++ b/zhang-content/src/main/java/com/ruoyi/domain/ZProperty.java
@@ -1,12 +1,15 @@
 package com.ruoyi.domain;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ruoyi.common.annotation.Excel;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.util.Date;
 
 /**
  * <p>
@@ -23,18 +26,27 @@
     private static final long serialVersionUID = 1L;
 
     @TableId(value = "id", type = IdType.AUTO)
-    private Integer id;
+    private Long id;
 
     /**
      * 鏈汉id
      */
-    private Integer userId;
+    private Long userId;
+
+
+    @Excel(name = "鏃ユ湡",dateFormat = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date happenTime;
+
+
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date createTime;
 
     /**
      * 璐骇绫诲埆
      */
-    @Excel(name = "璐骇绫诲埆",readConverterExp = "1=宸ヨ祫,2=瀛樻,3=鐞嗚储,4=瀹炰笟,5=鎴夸骇,6=璇佸埜,7=鑲$エ,8=鍊哄埜,9=鏈熻揣,10=浜鸿韩,11=璐骇淇濋櫓,12=榛勯噾,13=閭エ,14=鍙ょ帺")
-    private Integer type;
+    @Excel(name = "璐骇绫诲埆")
+    private String type;
 
     /**
      * 鏀舵敮鍚嶇О
@@ -46,7 +58,7 @@
      * 閲戦
      */
     @Excel(name = "閲戦")
-    private Double price;
+    private String price;
 
     /**
      * 鏈熼檺
@@ -57,6 +69,7 @@
     /**
      * 鍙樻洿鎴栨敞閿�
      */
+    @Excel(name = "鍙樻洿鎴栨敞閿�")
     private String isChange;
 
     /**
@@ -79,8 +92,16 @@
 
     private String url;
 
-    @Excel(name = "鏄惁娉ㄩ攢",readConverterExp = "0=姝e父,1=宸叉敞閿�")
+    @Excel(name = "鏄惁娉ㄩ攢(濉槸鎴栧惁)",readConverterExp = "0=鍚�,1=鏄�")
     private Integer status;
 
+    @TableField(exist = false)
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date happenStartTime;
+
+    @TableField(exist = false)
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date happenEndTime;
+
 
 }
diff --git a/zhang-content/src/main/java/com/ruoyi/service/ZIdeaService.java b/zhang-content/src/main/java/com/ruoyi/service/ZIdeaService.java
index 09400ce..6b15e44 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/ZIdeaService.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/ZIdeaService.java
@@ -2,7 +2,12 @@
 
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.domain.ZIdea;
+import com.ruoyi.domain.ZIdea;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,5 +18,13 @@
  * @since 2023-03-14
  */
 public interface ZIdeaService extends IService<ZIdea> {
+    AjaxResult selectDataList(ZIdea zIdea, Integer pageNum, Integer pageSize);
+
+    List<ZIdea> selectByIds(Long[] ids);
+
+    AjaxResult importExcel(MultipartFile file);
+
+    AjaxResult mySave(ZIdea zIdea);
+    
 
 }
diff --git a/zhang-content/src/main/java/com/ruoyi/service/ZPropertyService.java b/zhang-content/src/main/java/com/ruoyi/service/ZPropertyService.java
index 3232d9b..9dbf640 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/ZPropertyService.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/ZPropertyService.java
@@ -2,7 +2,12 @@
 
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.domain.ZProperty;
+import com.ruoyi.domain.ZProperty;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
 
 /**
  * <p>
@@ -14,4 +19,12 @@
  */
 public interface ZPropertyService extends IService<ZProperty> {
 
+    AjaxResult selectDataList(ZProperty zProperty, Integer pageNum, Integer pageSize);
+
+    List<ZProperty> selectByIds(Long[] ids);
+
+    AjaxResult importExcel(MultipartFile file);
+
+    AjaxResult mySave(ZProperty zProperty);
+
 }
diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZIdeaServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZIdeaServiceImpl.java
index d5f5f0b..ce7ff0b 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZIdeaServiceImpl.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZIdeaServiceImpl.java
@@ -1,11 +1,28 @@
 package com.ruoyi.service.impl;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.utils.MapUtils;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.domain.ZIdea;
 import com.ruoyi.domain.ZIdea;
 import com.ruoyi.mapper.ZIdeaMapper;
 import com.ruoyi.service.ZIdeaService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
 
 /**
  * <p>
@@ -18,4 +35,106 @@
 @Service
 public class ZIdeaServiceImpl extends ServiceImpl<ZIdeaMapper, ZIdea> implements ZIdeaService {
 
+    @Autowired
+    ZIdeaServiceImpl zIdeaService;
+
+    private LambdaQueryWrapper<ZIdea> uniqueCondition(ZIdea zIdea) {
+        LambdaQueryWrapper<ZIdea> lqw = new LambdaQueryWrapper<>();
+        lqw.eq(StringUtils.isNotEmpty(zIdea.getTitle()), ZIdea::getTitle, zIdea.getTitle())
+                .eq(StringUtils.isNotEmpty(zIdea.getCause()), ZIdea::getCause, zIdea.getCause())
+                .eq(StringUtils.isNotEmpty(zIdea.getBeneficiary()), ZIdea::getBeneficiary, zIdea.getBeneficiary())
+                .eq(StringUtils.isNotEmpty(zIdea.getHeir()), ZIdea::getHeir, zIdea.getHeir())
+                .eq(StringUtils.isNotEmpty(zIdea.getDifficulty()), ZIdea::getDifficulty, zIdea.getDifficulty())
+                .eq(zIdea.getHappenTime() != null, ZIdea::getHappenTime, zIdea.getHappenTime())
+                .eq(zIdea.getIsEffective() != null, ZIdea::getIsEffective, zIdea.getIsEffective())
+                .eq(StringUtils.isNotEmpty(zIdea.getRemark()), ZIdea::getRemark, zIdea.getRemark())
+                .eq(zIdea.getUid() != null, ZIdea::getUid, zIdea.getUid());
+        return lqw;
+    }
+
+    private LambdaQueryWrapper<ZIdea> buildCondition(ZIdea zIdea, Long userId) {
+        LambdaQueryWrapper<ZIdea> lqw = new LambdaQueryWrapper<>();
+        lqw.eq(userId != null, ZIdea::getUid, userId)
+                .like(StringUtils.isNotEmpty(zIdea.getTitle()), ZIdea::getTitle, zIdea.getTitle())
+                .like(StringUtils.isNotEmpty(zIdea.getBeneficiary()), ZIdea::getBeneficiary, zIdea.getBeneficiary())
+                .like(StringUtils.isNotEmpty(zIdea.getHeir()), ZIdea::getHeir, zIdea.getHeir())
+                .between(zIdea.getHappenStartTime() != null && zIdea.getHappenEndTime() != null, ZIdea::getHappenTime, zIdea.getHappenStartTime(), zIdea.getHappenEndTime())
+                .orderByDesc(ZIdea::getCreateTime);
+        return lqw;
+    }
+
+    /**
+     * 鍒嗛〉鏌ユ壘
+     */
+    @Override
+    public AjaxResult selectDataList(ZIdea zIdea, Integer pageNum, Integer pageSize) {
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        Long userId = user.getUserId();
+        LambdaQueryWrapper<ZIdea> lqw = buildCondition(zIdea, userId);
+
+        Page<ZIdea> pageBean = new Page<>(pageNum, pageSize);
+        Page<ZIdea> pageResult = page(pageBean, lqw);
+
+        List<ZIdea> beanRecords = pageResult.getRecords();//寰楀埌鏌ヨ鍑烘潵鐨勬暟鎹�
+
+        HashMap<String, Object> data = MapUtils.getResult(pageResult, beanRecords);
+        return AjaxResult.success(data);
+
+    }
+
+
+    @Override
+    public List<ZIdea> selectByIds(Long[] ids) {
+        List<ZIdea> list = new ArrayList<>();
+        if (ids.length != 0)
+            list = listByIds(Arrays.asList(ids));
+        else
+            list = list();
+        return list;
+    }
+
+    @Override
+    public AjaxResult mySave(ZIdea zIdea) {
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        Long userId = user.getUserId();
+        zIdea.setUid(userId);
+
+        //妫�鏌ユ槸鍚︽湁閲嶅鏁版嵁鎻掑叆
+        LambdaQueryWrapper<ZIdea> lqw = uniqueCondition(zIdea);
+        List<ZIdea> list = list(lqw);
+        if (list.size() > 0) {
+            throw new RuntimeException("璇峰嬁鏂板閲嶅鏁版嵁");
+        }
+
+        if (save(zIdea)) {
+            return AjaxResult.success();
+        } else {
+            return AjaxResult.error();
+        }
+
+    }
+
+    @Override
+    @Transactional
+    public AjaxResult importExcel(MultipartFile file) {
+
+        ExcelUtil<ZIdea> util = new ExcelUtil<>(ZIdea.class);
+        List<ZIdea> dataList = null;
+        try {
+            dataList = util.importExcel(file.getInputStream());
+        } catch (Exception e) {
+            throw new RuntimeException("娌℃湁鎸夌収瑙勫垯瀵煎叆鏁版嵁");
+        }
+
+        assert dataList != null;
+
+        for (ZIdea zIdea : dataList) {
+            zIdeaService.mySave(zIdea);
+        }
+
+        return AjaxResult.success();
+
+    }
+
+
 }
diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZPropertyServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZPropertyServiceImpl.java
index 94a2fb6..b0188c1 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZPropertyServiceImpl.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZPropertyServiceImpl.java
@@ -1,11 +1,28 @@
 package com.ruoyi.service.impl;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.utils.MapUtils;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.domain.ZProperty;
 import com.ruoyi.domain.ZProperty;
 import com.ruoyi.mapper.ZPropertyMapper;
 import com.ruoyi.service.ZPropertyService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
 
 /**
  * <p>
@@ -18,4 +35,105 @@
 @Service
 public class ZPropertyServiceImpl extends ServiceImpl<ZPropertyMapper, ZProperty> implements ZPropertyService {
 
+    @Autowired
+    ZPropertyServiceImpl zPropertyService;
+
+    private LambdaQueryWrapper<ZProperty> uniqueCondition(ZProperty zProperty) {
+        LambdaQueryWrapper<ZProperty> lqw = new LambdaQueryWrapper<>();
+        lqw.eq(StringUtils.isNotEmpty(zProperty.getType()), ZProperty::getType, zProperty.getType())
+                .eq(StringUtils.isNotEmpty(zProperty.getIncomeName()), ZProperty::getIncomeName, zProperty.getIncomeName())
+                .eq(StringUtils.isNotEmpty(zProperty.getPrice()), ZProperty::getPrice, zProperty.getPrice())
+                .eq(StringUtils.isNotEmpty(zProperty.getTimeLimit()), ZProperty::getTimeLimit, zProperty.getTimeLimit())
+                .eq(StringUtils.isNotEmpty(zProperty.getIsChange()), ZProperty::getIsChange, zProperty.getIsChange())
+                .eq(StringUtils.isNotEmpty(zProperty.getPropertyRight()), ZProperty::getPropertyRight, zProperty.getPropertyRight())
+                .eq(zProperty.getHappenTime() != null, ZProperty::getHappenTime, zProperty.getHappenTime())
+                .eq(StringUtils.isNotEmpty(zProperty.getLocation()), ZProperty::getLocation, zProperty.getLocation())
+                .eq(StringUtils.isNotEmpty(zProperty.getRemark()), ZProperty::getRemark, zProperty.getRemark())
+                .eq(zProperty.getUserId() != null, ZProperty::getUserId, zProperty.getUserId());
+        return lqw;
+    }
+
+    private LambdaQueryWrapper<ZProperty> buildCondition(ZProperty zProperty, Long userId) {
+        LambdaQueryWrapper<ZProperty> lqw = new LambdaQueryWrapper<>();
+        lqw.eq(userId != null, ZProperty::getUserId, userId)
+                .like(StringUtils.isNotEmpty(zProperty.getType()), ZProperty::getType, zProperty.getType())
+                .like(StringUtils.isNotEmpty(zProperty.getIncomeName()), ZProperty::getIncomeName, zProperty.getIncomeName())
+                .between(zProperty.getHappenStartTime() != null && zProperty.getHappenEndTime() != null, ZProperty::getHappenTime, zProperty.getHappenStartTime(), zProperty.getHappenEndTime())
+                .orderByDesc(ZProperty::getCreateTime);
+        return lqw;
+    }
+
+    /**
+     * 鍒嗛〉鏌ユ壘
+     */
+    @Override
+    public AjaxResult selectDataList(ZProperty zProperty, Integer pageNum, Integer pageSize) {
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        Long userId = user.getUserId();
+        LambdaQueryWrapper<ZProperty> lqw = buildCondition(zProperty, userId);
+
+        Page<ZProperty> pageBean = new Page<>(pageNum, pageSize);
+        Page<ZProperty> pageResult = page(pageBean, lqw);
+
+        List<ZProperty> beanRecords = pageResult.getRecords();//寰楀埌鏌ヨ鍑烘潵鐨勬暟鎹�
+
+        HashMap<String, Object> data = MapUtils.getResult(pageResult, beanRecords);
+        return AjaxResult.success(data);
+
+    }
+
+
+    @Override
+    public List<ZProperty> selectByIds(Long[] ids) {
+        List<ZProperty> list = new ArrayList<>();
+        if (ids.length != 0)
+            list = listByIds(Arrays.asList(ids));
+        else
+            list = list();
+        return list;
+    }
+
+    @Override
+    public AjaxResult mySave(ZProperty zProperty) {
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        Long userId = user.getUserId();
+        zProperty.setUserId(userId);
+
+        //妫�鏌ユ槸鍚︽湁閲嶅鏁版嵁鎻掑叆
+        LambdaQueryWrapper<ZProperty> lqw = uniqueCondition(zProperty);
+        List<ZProperty> list = list(lqw);
+        if (list.size() > 0) {
+            throw new RuntimeException("璇峰嬁鏂板閲嶅鏁版嵁");
+        }
+
+        if (save(zProperty)) {
+            return AjaxResult.success();
+        } else {
+            return AjaxResult.error();
+        }
+
+    }
+
+    @Override
+    @Transactional
+    public AjaxResult importExcel(MultipartFile file) {
+
+        ExcelUtil<ZProperty> util = new ExcelUtil<>(ZProperty.class);
+        List<ZProperty> dataList = null;
+        try {
+            dataList = util.importExcel(file.getInputStream());
+        } catch (Exception e) {
+            throw new RuntimeException("娌℃湁鎸夌収瑙勫垯瀵煎叆鏁版嵁");
+        }
+
+        assert dataList != null;
+
+        for (ZProperty zProperty : dataList) {
+            zPropertyService.mySave(zProperty);
+        }
+
+        return AjaxResult.success();
+
+    }
+
 }

--
Gitblit v1.9.1