From 1dfe61fdf1b36061871ead5337172801e64df201 Mon Sep 17 00:00:00 2001
From: Jinquan_Ou <Jinquan@gdut.com>
Date: 星期一, 03 四月 2023 16:07:36 +0800
Subject: [PATCH] 魅宠、家庭小医生1.0

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZInfoUserController.java |  137 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 132 insertions(+), 5 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 c83c026..5e294e7 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,28 +1,155 @@
 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>
- *  鍓嶇鎺у埗鍣�
+ * 鍓嶇鎺у埗鍣�
  * </p>
  *
  * @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 AjaxResult.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));
+    }
 
 
+    /**
+     * 鏌ヨ瀹跺涵涓昏鎴愬憳鍙婂叧绯�
+     */
+
+    @GetMapping("/relation")
+    public AjaxResult listMyRelation() {
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        Long userId = user.getUserId();
+        return zInfoUserService.searchMyRelation(userId);
+    }
 
 
 }

--
Gitblit v1.9.1