From 578e1df3a3c32bc0027de169ff6beea8f1527048 Mon Sep 17 00:00:00 2001
From: Jinquan_Ou <Jinquan@gdut.com>
Date: 星期四, 23 三月 2023 18:51:09 +0800
Subject: [PATCH] 完成个人信息、家庭大事记

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZInfoUserController.java |  128 +++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 124 insertions(+), 4 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZInfoUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZInfoUserController.java
index 07f3998..557bef7 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZInfoUserController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZInfoUserController.java
@@ -1,12 +1,28 @@
 package com.ruoyi.web.controller.zhang;
 
 
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.core.text.Convert;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.ServletUtils;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.domain.ZInfoUser;
+import com.ruoyi.service.ZInfoUserService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Arrays;
+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>
@@ -16,10 +32,114 @@
  * @author ojq
  * @since 2023-03-14
  */
+@Slf4j
 @RestController
 @RequestMapping("/self/user")
-public class ZInfoUserController {
+public class ZInfoUserController extends BaseController {
 
+    @Resource
+    private ZInfoUserService zInfoUserService;
+
+//    @GetMapping("/all")
+//    public AjaxResult  listAll(ZInfoUser zInfoUser){
+//        Integer pageNum = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1);
+//        Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10);
+//        return zInfoUserService.selectInfoList(zInfoUser, pageNum, pageSize);
+//    }
+
+
+    /**
+     * 瀵煎嚭涓汉璇︾粏淇℃伅璁板綍鍒楄〃
+     */
+//    @PreAuthorize("@ss.hasPermi('system:property:export')")
+    @Log(title = "涓汉璇︾粏淇℃伅璁板綍", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, ZInfoUser zInfoUser)
+    {
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        Long userId = user.getUserId();
+        zInfoUser.setUserId(userId);
+        List<ZInfoUser> list = zInfoUserService.selectByCondition(zInfoUser);
+        log.info("瀵煎嚭璁板綍涓�:{}",list);
+        ExcelUtil<ZInfoUser> util = new ExcelUtil<>(ZInfoUser.class);
+        util.exportExcel(response, list, "涓汉璇︾粏淇℃伅璁板綍鏁版嵁");
+    }
+
+    /**
+     * 瀵煎叆涓汉璇︾粏淇℃伅璁板綍鍒楄〃
+     */
+    @Log(title = "鐢ㄦ埛绠$悊", businessType = BusinessType.IMPORT)
+    @PostMapping("/importData")
+    public AjaxResult importData(@RequestParam("excelImport") MultipartFile file) throws Exception
+    {
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        Long userId = user.getUserId();
+        ExcelUtil<ZInfoUser> util = new ExcelUtil<>(ZInfoUser.class);
+        List<ZInfoUser> eventList = util.importExcel(file.getInputStream());
+        log.info("涓汉璇︾粏淇℃伅鍒楄〃涓猴細{}",eventList);
+        if(eventList.size()>1){
+            return AjaxResult.error("瀵煎叆涓汉淇℃伅鍙兘鏈変竴鏉¤褰�");
+        }
+
+        ZInfoUser zInfoUser = eventList.get(0);
+        zInfoUser.setUserId(userId);
+
+        if (zInfoUserService.updateById(zInfoUser)) {
+            return AjaxResult.success("瀵煎叆鏁版嵁鎴愬姛");
+        }
+        return AjaxResult.error("瀵煎叆鏁版嵁澶辫触");
+
+    }
+
+    /**
+     * 鑾峰彇涓汉璇︾粏淇℃伅璁板綍璇︾粏淇℃伅
+     */
+//    @PreAuthorize("@ss.hasPermi('system:property:query')")
+    @GetMapping()
+    public AjaxResult getInfo()
+    {
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        Long userId = user.getUserId();
+        return success(zInfoUserService.getById(userId));
+    }
+//
+    /**
+     * 鏂板銆佷慨鏀逛釜浜鸿缁嗕俊鎭褰�
+     */
+//    @PreAuthorize("@ss.hasPermi('system:property:add')")
+    @Log(title = "涓汉璇︾粏淇℃伅璁板綍", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody ZInfoUser zInfoUser)
+    {
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        Long userId = user.getUserId();
+        zInfoUser.setUserId(userId);
+        return toAjax(zInfoUserService.saveOrUpdate(zInfoUser));
+    }
+
+//    /**
+//     * 淇敼涓汉璇︾粏淇℃伅璁板綍
+//     */
+////    @PreAuthorize("@ss.hasPermi('system:property:edit')")
+//    @Log(title = "涓汉璇︾粏淇℃伅璁板綍", businessType = BusinessType.UPDATE)
+//    @PutMapping
+//    public AjaxResult edit(@RequestBody ZInfoUser zInfoUser)
+//    {
+//        return toAjax(zInfoUserService.updateById(zInfoUser));
+//    }
+//
+    /**
+     * 鍒犻櫎涓汉璇︾粏淇℃伅璁板綍
+     */
+//    @PreAuthorize("@ss.hasPermi('system:property:remove')")
+    @Log(title = "涓汉璇︾粏淇℃伅璁板綍", businessType = BusinessType.DELETE)
+    @DeleteMapping()
+    public AjaxResult remove()
+    {
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        Long userId = user.getUserId();
+        return toAjax(zInfoUserService.removeById(userId));
+    }
 
 
 }

--
Gitblit v1.9.1