Explorar o código

[update] message:

kelei hai 6 meses
pai
achega
460b8c8159
Modificáronse 27 ficheiros con 617 adicións e 82 borrados
  1. 5 1
      admin/pom.xml
  2. 2 0
      admin/src/main/java/com/flyer/foster/controller/AppUserController.java
  3. 21 6
      admin/src/main/java/com/flyer/foster/controller/AreaController.java
  4. 69 2
      admin/src/main/java/com/flyer/foster/controller/GardenController.java
  5. 57 0
      admin/src/main/java/com/flyer/foster/controller/OSSController.java
  6. 18 7
      admin/src/main/java/com/flyer/foster/controller/UserController.java
  7. 25 0
      admin/src/main/java/com/flyer/foster/dto/AreaRespDTO.java
  8. 45 0
      admin/src/main/java/com/flyer/foster/dto/GardenAddDTO.java
  9. 17 0
      admin/src/main/java/com/flyer/foster/dto/GardenQueryDTO.java
  10. 31 0
      admin/src/main/java/com/flyer/foster/dto/GardenRespDTO.java
  11. 41 0
      admin/src/main/java/com/flyer/foster/dto/GardenUpdateDTO.java
  12. 1 1
      admin/src/main/java/com/flyer/foster/dto/UserQueryDTO.java
  13. 71 0
      admin/src/main/java/com/flyer/foster/dto/UserRespDTO.java
  14. 2 2
      admin/src/main/java/com/flyer/foster/mapper/IAreaMapper.java
  15. 21 0
      admin/src/main/java/com/flyer/foster/mapper/IGardenMapper.java
  16. 9 6
      admin/src/main/java/com/flyer/foster/mapper/IUserMapper.java
  17. 0 16
      admin/src/main/java/com/flyer/foster/pojo/UserRespPOJO.java
  18. 3 3
      admin/src/main/java/com/flyer/foster/service/IAreaService.java
  19. 27 0
      admin/src/main/java/com/flyer/foster/service/IGardenService.java
  20. 10 5
      admin/src/main/java/com/flyer/foster/service/IUserService.java
  21. 18 5
      admin/src/main/java/com/flyer/foster/service/impl/AreaServiceImpl.java
  22. 61 1
      admin/src/main/java/com/flyer/foster/service/impl/GardenServiceImpl.java
  23. 19 9
      admin/src/main/java/com/flyer/foster/service/impl/UserServiceImpl.java
  24. 1 1
      admin/src/main/resources/application-dev.yml
  25. 1 1
      admin/src/main/resources/mapper/AreaMapper.xml
  26. 22 0
      admin/src/main/resources/mapper/GardenMapper.xml
  27. 20 16
      admin/src/main/resources/mapper/UserMapper.xml

+ 5 - 1
admin/pom.xml

@@ -34,7 +34,11 @@
             <artifactId>easyexcel</artifactId>
         </dependency>
 
-
+        <dependency>
+            <groupId>com.aliyun.oss</groupId>
+            <artifactId>aliyun-sdk-oss</artifactId>
+            <version>3.12.0</version>
+        </dependency>
 
     </dependencies>
 

+ 2 - 0
admin/src/main/java/com/flyer/foster/controller/AppUserController.java

@@ -1,5 +1,6 @@
 package com.flyer.foster.controller;
 
+import cn.dev33.satoken.annotation.SaCheckLogin;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -9,6 +10,7 @@ import org.springframework.web.bind.annotation.RestController;
  * @author flyer
  * @since 2024-05-09
  */
+@SaCheckLogin
 @RestController
 @RequestMapping("/app-user")
 public class AppUserController {

+ 21 - 6
admin/src/main/java/com/flyer/foster/controller/AreaController.java

@@ -1,8 +1,10 @@
 package com.flyer.foster.controller;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.flyer.foster.dto.AreaAddDTO;
 import com.flyer.foster.dto.AreaQueryDTO;
+import com.flyer.foster.dto.AreaRespDTO;
 import com.flyer.foster.dto.AreaUpdateDTO;
 import com.flyer.foster.service.IAreaService;
 import com.flyer.util.R;
@@ -33,22 +35,35 @@ public class AreaController {
      */
     @GetMapping("/list/{current}/{size}")
     public R getPageList(@PathVariable Integer current, @PathVariable Integer size, AreaQueryDTO queryDTO) {
-        return R.ok().result(iAreaService.getPageList(new Page<>(current, size), queryDTO));
+        IPage<AreaRespDTO> page = new Page<>(current, size);
+        return R.ok().result(iAreaService.getPageList(page, queryDTO));
+    }
+
+    @GetMapping("/{areaId}")
+    public R getById(@PathVariable Integer areaId) {
+        return R.ok().result(iAreaService.getById(areaId));
     }
 
     /**
      * 新增区域
      *
-     * @param addDTO
+     * @param addDTOList
      * @return
      */
     @PostMapping("")
-    public R addArea(@Valid @RequestBody AreaAddDTO addDTO) {
-        return R.ok().result(iAreaService.addArea(addDTO));
+    public R addArea(@Valid @RequestBody List<AreaAddDTO> addDTOList) {
+        return R.ok().result(iAreaService.addArea(addDTOList));
     }
 
+    /**
+     * 修改区域
+     *
+     * @param areaId
+     * @param updateDTO
+     * @return
+     */
     @PutMapping("/{areaId}")
-    public R updateArea(@PathVariable Integer areaId,@RequestBody AreaUpdateDTO updateDTO){
+    public R updateArea(@PathVariable Integer areaId, @RequestBody AreaUpdateDTO updateDTO) {
         updateDTO.setId(areaId);
         return R.ok().result(iAreaService.updateArea(updateDTO));
     }
@@ -58,7 +73,7 @@ public class AreaController {
      *
      * @return
      */
-    @DeleteMapping("/delete")
+    @PostMapping("/delete")
     public R deleteArea(@RequestBody List<Integer> idList) {
         return R.ok().result(iAreaService.deleteByIdList(idList));
     }

+ 69 - 2
admin/src/main/java/com/flyer/foster/controller/GardenController.java

@@ -1,7 +1,16 @@
 package com.flyer.foster.controller;
 
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.flyer.foster.dto.*;
+import com.flyer.foster.entity.Garden;
+import com.flyer.foster.service.IGardenService;
+import com.flyer.util.R;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import java.util.List;
 
 /**
  * 果园
@@ -12,5 +21,63 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 @RequestMapping("/garden")
 public class GardenController {
+    @Autowired
+    private IGardenService iGardenService;
+
+    /**
+     * 果园列表-分页
+     *
+     * @param current 当前页,默认1
+     * @param size    当前页显示条数,默认10
+     * @return
+     */
+    @GetMapping("/list/{current}/{size}")
+    public R getPageList(@PathVariable Integer current, @PathVariable Integer size, GardenQueryDTO queryDTO) {
+        IPage<GardenRespDTO> page = new Page<>(current, size);
+        return R.ok().result(iGardenService.getPageList(page, queryDTO));
+    }
+
+    /**
+     * 根据id获取果园详情
+     *
+     * @return
+     */
+    @GetMapping("/{gardenId}")
+    public R getById(@PathVariable Integer gardenId) {
+        return R.ok().result(iGardenService.getById(gardenId));
+    }
+
+    /**
+     * 新增果园
+     *
+     * @param addDTO
+     * @return
+     */
+    @PostMapping("")
+    public R addArea(@Valid @RequestBody GardenAddDTO addDTO) {
+        return R.ok().result(iGardenService.addGarden(addDTO));
+    }
+
+    /**
+     * 修改果园
+     *
+     * @param areaId
+     * @param updateDTO
+     * @return
+     */
+    @PutMapping("/{areaId}")
+    public R updateArea(@PathVariable Integer areaId, @RequestBody GardenUpdateDTO updateDTO) {
+        updateDTO.setId(areaId);
+        return R.ok().result(iGardenService.updateGarden(updateDTO));
+    }
 
+    /**
+     * 删除果园
+     *
+     * @return
+     */
+    @PostMapping("/delete")
+    public R deleteGarden(@RequestBody List<Integer> idList) {
+        return R.ok().result(iGardenService.deleteByIdList(idList));
+    }
 }

+ 57 - 0
admin/src/main/java/com/flyer/foster/controller/OSSController.java

@@ -0,0 +1,57 @@
+package com.flyer.foster.controller;
+
+import cn.dev33.satoken.annotation.SaCheckLogin;
+import com.aliyuncs.DefaultAcsClient;
+import com.aliyuncs.IAcsClient;
+import com.aliyuncs.auth.sts.AssumeRoleRequest;
+import com.aliyuncs.auth.sts.AssumeRoleResponse;
+import com.aliyuncs.exceptions.ClientException;
+import com.aliyuncs.profile.DefaultProfile;
+import com.flyer.util.R;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * OSS上传
+ *
+ * @author kelei
+ * @since 2024/5/9/15:06
+ */
+@Slf4j
+@SaCheckLogin
+@RestController
+@RequestMapping("/oss")
+public class OSSController {
+    private static String endpoint = "http://oss-cn-guangzhou.aliyuncs.com";
+    private static String accessKeyId = "LTAI5t78gep5D1RCqvAEx8eJ";
+    private static String accessKeySecret = "Mu3FX9xTXGtZzVvabNEaFdBI4wUz7w";
+    private static String bucketName = "birdseye";
+    private static String region = "cn-shenzhen";
+
+    @PostMapping(value = "/credential")
+    public R credential() {
+        return R.ok().result(getCredentials());
+    }
+
+    private AssumeRoleResponse.Credentials getCredentials() {
+        try {
+            DefaultProfile profile = DefaultProfile.getProfile(region, accessKeyId, accessKeySecret);
+            IAcsClient client = new DefaultAcsClient(profile);
+
+            AssumeRoleRequest request = new AssumeRoleRequest();
+            request.setDurationSeconds(3600l);
+            request.setRoleArn("acs:ram::1359375599298722:role/ramosstest");
+            request.setRoleSessionName("SessionTest");
+
+            AssumeRoleResponse response = client.getAcsResponse(request);
+            return response.getCredentials();
+
+        } catch (ClientException e) {
+            log.debug("Failed to obtain sts.");
+            e.printStackTrace();
+        }
+        return null;
+    }
+}

+ 18 - 7
admin/src/main/java/com/flyer/foster/controller/UserController.java

@@ -8,9 +8,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.flyer.foster.dto.LoginDTO;
 import com.flyer.foster.dto.UserAddDto;
-import com.flyer.foster.dto.UserSearchDTO;
+import com.flyer.foster.dto.UserQueryDTO;
+import com.flyer.foster.dto.UserRespDTO;
 import com.flyer.foster.entity.User;
-import com.flyer.foster.pojo.UserRespPOJO;
 import com.flyer.foster.service.IUserService;
 import com.flyer.util.R;
 import lombok.extern.slf4j.Slf4j;
@@ -36,6 +36,7 @@ public class UserController {
 
     /**
      * 登录
+     *
      * @param loginDto
      * @return
      */
@@ -60,11 +61,11 @@ public class UserController {
     public R getUserInfo() {
         String username = StpUtil.getLoginId().toString();
         User user = iUserService.lambdaQuery().eq(User::getUsername, username).eq(User::getStatus, 1).one();
-        UserRespPOJO userRespPOJO = new UserRespPOJO();
+        UserRespDTO userRespDTO = new UserRespDTO();
         if (user != null) {
-            BeanUtil.copyProperties(user, userRespPOJO);
+            BeanUtil.copyProperties(user, userRespDTO);
         }
-        return R.ok().result(userRespPOJO);
+        return R.ok().result(userRespDTO);
     }
 
     /**
@@ -79,6 +80,16 @@ public class UserController {
     }
 
     /**
+     * 用户列表
+     *
+     * @return
+     */
+    @GetMapping("/list")
+    public R getList(UserQueryDTO queryDTO) {
+        return R.ok().result(iUserService.getList(queryDTO));
+    }
+
+    /**
      * 用户列表-分页
      *
      * @param current 当前页,默认1
@@ -86,9 +97,9 @@ public class UserController {
      * @return
      */
     @GetMapping("/list/{current}/{size}")
-    public R getUsers(@PathVariable Integer current, @PathVariable Integer size, UserSearchDTO queryDTO) {
+    public R getPageList(@PathVariable Integer current, @PathVariable Integer size, UserQueryDTO queryDTO) {
         IPage<User> page = new Page<>(current, size);
-        return R.ok().result(iUserService.selectByPage(page, queryDTO));
+        return R.ok().result(iUserService.getPageList(page, queryDTO));
     }
 
     /**

+ 25 - 0
admin/src/main/java/com/flyer/foster/dto/AreaRespDTO.java

@@ -10,5 +10,30 @@ import lombok.Data;
  */
 @Data
 public class AreaRespDTO {
+    private Integer id;
 
+    /**
+     * 区域名称
+     */
+    private String name;
+
+    /**
+     * 区域状态-{0:禁用,1:启用}
+     */
+    private String areaStatus;
+
+    /**
+     * 果园名称
+     */
+    private String gardenName;
+
+    /**
+     * 区域创建时间
+     */
+    private String createdTime;
+
+    /**
+     * 区域修改时间
+     */
+    private String updatedTime;
 }

+ 45 - 0
admin/src/main/java/com/flyer/foster/dto/GardenAddDTO.java

@@ -0,0 +1,45 @@
+package com.flyer.foster.dto;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+/**
+ * AreaSearchDTO
+ *
+ * @author kelei
+ * @since 2024/5/9/10:54
+ */
+@Data
+public class GardenAddDTO {
+    private Integer id;
+
+    /**
+     * 果园名称
+     */
+    @NotBlank(message = "果园名称不能为空")
+    private String name;
+
+    /**
+     * 用户id
+     */
+    @NotNull(message = "用户不能为空")
+    private Integer userId;
+
+    /**
+     * 底图
+     */
+    @NotBlank(message = "果园底图不能为空")
+    private String baseMapUrl;
+
+    /**
+     * 二维码
+     */
+    private String qrCode;
+
+    /**
+     * 状态-{0.不可用 1.可用}
+     */
+    private Integer status;
+}

+ 17 - 0
admin/src/main/java/com/flyer/foster/dto/GardenQueryDTO.java

@@ -0,0 +1,17 @@
+package com.flyer.foster.dto;
+
+import lombok.Data;
+
+/**
+ * AreaSearchDTO
+ *
+ * @author kelei
+ * @since 2024/5/9/10:54
+ */
+@Data
+public class GardenQueryDTO {
+    /**
+     * 果园名称
+     */
+    private String name;
+}

+ 31 - 0
admin/src/main/java/com/flyer/foster/dto/GardenRespDTO.java

@@ -0,0 +1,31 @@
+package com.flyer.foster.dto;
+
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * AreaRespDTO
+ *
+ * @author kelei
+ * @since 2024/5/9/10:58
+ */
+@Data
+public class GardenRespDTO {
+    private Integer id;
+
+    private String name;
+
+    private String userId;
+
+    private String username;
+
+    private String statusName;
+
+    private List<String> areaNameList = new ArrayList<>();
+
+    private String createdTime;
+
+    private String updatedTime;
+}

+ 41 - 0
admin/src/main/java/com/flyer/foster/dto/GardenUpdateDTO.java

@@ -0,0 +1,41 @@
+package com.flyer.foster.dto;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * AreaSearchDTO
+ *
+ * @author kelei
+ * @since 2024/5/9/10:54
+ */
+@Data
+public class GardenUpdateDTO {
+    private Integer id;
+
+    /**
+     * 果园名称
+     */
+    private String name;
+
+    /**
+     * 用户id
+     */
+    private Integer userId;
+
+    /**
+     * 底图
+     */
+    private String baseMapUrl;
+
+    /**
+     * 二维码
+     */
+    private String qrCode;
+
+    /**
+     * 状态-{0.不可用 1.可用}
+     */
+    private Integer status;
+}

+ 1 - 1
admin/src/main/java/com/flyer/foster/dto/UserSearchDTO.java → admin/src/main/java/com/flyer/foster/dto/UserQueryDTO.java

@@ -14,7 +14,7 @@ import java.util.List;
  * @since 2022/3/28/14:02
  */
 @Data
-public class UserSearchDTO {
+public class UserQueryDTO {
     /**
      * 主键id
      */

+ 71 - 0
admin/src/main/java/com/flyer/foster/dto/UserRespDTO.java

@@ -0,0 +1,71 @@
+package com.flyer.foster.dto;
+
+import com.flyer.foster.entity.Role;
+import com.flyer.foster.pojo.CheckBox;
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * UserRespDTO
+ *
+ * @author kelei
+ * @since 2024/5/8/11:48
+ */
+@Data
+public class UserRespDTO {
+    /**
+     * 主键id
+     */
+    private Integer id;
+
+    /**
+     * 登录名
+     */
+    private String username;
+
+    /**
+     * 昵称
+     */
+    private String nickname;
+
+    /**
+     * 备注信息
+     */
+    private String remarks;
+
+    /**
+     * 状态{0.不可用 1.可用}
+     */
+    private Integer status;
+
+    /**
+     * 角色对象集合
+     */
+    private List<Role> roles = new ArrayList();
+
+    private List<CheckBox> moduleList = new ArrayList<>();
+
+    /**
+     * 角色描述
+     */
+    private String description;
+
+
+    /**
+     * 1:经销商,2:医院
+     */
+    private Integer tenantType;
+
+    private Integer tenantId;
+
+    private String tenantName;
+
+    /**
+     * 是否是默认经销商-{0:非,1:是}
+     */
+    private Integer isDefault;
+
+    private Integer adminUserId;
+}

+ 2 - 2
admin/src/main/java/com/flyer/foster/mapper/IAreaMapper.java

@@ -21,10 +21,10 @@ public interface IAreaMapper extends BaseMapper<Area> {
     /**
      *区域列表-分页
      * @param page
-     * @param searchDTO
+     * @param queryDTO
      * @return
      */
-    IPage<AreaRespDTO> getPageList(@Param("page") IPage<AreaRespDTO> page, @Param("queryDTO") AreaQueryDTO searchDTO);
+    IPage<AreaRespDTO> getPageList(@Param("page") IPage<AreaRespDTO> page, @Param("queryDTO") AreaQueryDTO queryDTO);
 
     /**
      * 物理删除

+ 21 - 0
admin/src/main/java/com/flyer/foster/mapper/IGardenMapper.java

@@ -1,7 +1,14 @@
 package com.flyer.foster.mapper;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.flyer.foster.dto.GardenQueryDTO;
+import com.flyer.foster.dto.GardenRespDTO;
 import com.flyer.foster.entity.Garden;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +20,18 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface IGardenMapper extends BaseMapper<Garden> {
 
+    /**
+     * 物理删除
+     * @param idList
+     * @return
+     */
+    boolean deleteByIdList(@Param("idList") List<Integer> idList);
+
+    /**
+     * 果园列表-分页
+     * @param page
+     * @param queryDTO
+     * @return
+     */
+    IPage<GardenRespDTO> getPageList(IPage<GardenRespDTO> page, GardenQueryDTO queryDTO);
 }

+ 9 - 6
admin/src/main/java/com/flyer/foster/mapper/IUserMapper.java

@@ -1,7 +1,8 @@
 package com.flyer.foster.mapper;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.flyer.foster.dto.UserSearchDTO;
+import com.flyer.foster.dto.UserQueryDTO;
+import com.flyer.foster.dto.UserRespDTO;
 import com.flyer.foster.entity.User;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
@@ -24,19 +25,19 @@ public interface IUserMapper extends BaseMapper<User> {
      * @param queryDTO 查询对象
      * @return 分页数据集
      */
-    IPage<UserSearchDTO> selectByPage(@Param("page") IPage<User> page, @Param("queryDTO") UserSearchDTO queryDTO);
+    IPage<UserRespDTO> getPageList(@Param("page") IPage<User> page, @Param("queryDTO") UserQueryDTO queryDTO);
 
     /**
      * 组织机构管理员分页列表
      *
      * @param page
-     * @param searchDTO
+     * @param queryDTO
      * @param userIdList
      * @return
      */
-    IPage<UserSearchDTO> adminListByPage(@Param("page") IPage<UserSearchDTO> page,
-                                         @Param("searchDTO") UserSearchDTO searchDTO,
-                                         @Param("userIdList") List<Integer> userIdList);
+    IPage<UserRespDTO> adminListByPage(@Param("page") IPage<UserQueryDTO> page,
+                                        @Param("queryDTO") UserQueryDTO queryDTO,
+                                        @Param("userIdList") List<Integer> userIdList);
 
     /**
      * 物理删除
@@ -45,4 +46,6 @@ public interface IUserMapper extends BaseMapper<User> {
      * @return
      */
     boolean deleteByIdList(@Param("idList") List<Integer> idList, @Param("tenantId") Integer tenantId);
+
+    List<UserRespDTO> getList(@Param("queryDTO") UserQueryDTO queryDTO);
 }

+ 0 - 16
admin/src/main/java/com/flyer/foster/pojo/UserRespPOJO.java

@@ -1,16 +0,0 @@
-package com.flyer.foster.pojo;
-
-import lombok.Data;
-
-/**
- * UserRespPOJO
- *
- * @author kelei
- * @since 2024/5/8/11:48
- */
-@Data
-public class UserRespPOJO {
-    private Integer id;
-
-    private String username;
-}

+ 3 - 3
admin/src/main/java/com/flyer/foster/service/IAreaService.java

@@ -19,14 +19,14 @@ import java.util.List;
  * @since 2024-05-09
  */
 public interface IAreaService extends IService<Area> {
-    IPage<AreaRespDTO> getPageList(IPage<AreaRespDTO> page, AreaQueryDTO searchDTO);
+    IPage<AreaRespDTO> getPageList(IPage<AreaRespDTO> page, AreaQueryDTO queryDTO);
 
     /**
      * 新增区域
-     * @param addDTO
+     * @param addDTOList
      * @return
      */
-    boolean addArea(AreaAddDTO addDTO);
+    boolean addArea(List<AreaAddDTO> addDTOList);
 
     /**
      * 物理删除

+ 27 - 0
admin/src/main/java/com/flyer/foster/service/IGardenService.java

@@ -1,8 +1,13 @@
 package com.flyer.foster.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.flyer.foster.dto.*;
 import com.flyer.foster.entity.Garden;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * <p>
  * 果园 服务类
@@ -13,4 +18,26 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IGardenService extends IService<Garden> {
 
+    IPage<GardenRespDTO> getPageList(IPage<GardenRespDTO> page, GardenQueryDTO queryDTO);
+
+    /**
+     * 新增区域
+     * @param addDTO
+     * @return
+     */
+    boolean addGarden(GardenAddDTO addDTO);
+
+    /**
+     * 物理删除
+     * @param idList
+     * @return
+     */
+    boolean deleteByIdList(List<Integer> idList);
+
+    /**
+     * 修改区域
+     * @param updateDTO
+     * @return
+     */
+    boolean updateGarden(GardenUpdateDTO updateDTO);
 }

+ 10 - 5
admin/src/main/java/com/flyer/foster/service/IUserService.java

@@ -1,16 +1,14 @@
 package com.flyer.foster.service;
 
-import cn.hutool.crypto.asymmetric.RSA;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.flyer.foster.dto.LoginDTO;
 import com.flyer.foster.dto.UserAddDto;
-import com.flyer.foster.dto.UserAddOrUpdateDTO;
-import com.flyer.foster.dto.UserSearchDTO;
+import com.flyer.foster.dto.UserQueryDTO;
+import com.flyer.foster.dto.UserRespDTO;
 import com.flyer.foster.entity.User;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.util.List;
-import java.util.Map;
 
 /**
  * <p>
@@ -42,7 +40,7 @@ public interface IUserService extends IService<User> {
      *
      * @return list
      */
-    IPage<UserSearchDTO> selectByPage(IPage<User> page, UserSearchDTO queryDTO);
+    IPage<UserRespDTO> getPageList(IPage<User> page, UserQueryDTO queryDTO);
 
     /**
      * 物理删除
@@ -52,4 +50,11 @@ public interface IUserService extends IService<User> {
     boolean removeByIdList(List<Integer> idList);
 
     boolean addUser(UserAddDto addDTO);
+
+    /**
+     * 用户列表
+     * @param queryDTO
+     * @return
+     */
+    List<UserRespDTO> getList(UserQueryDTO queryDTO);
 }

+ 18 - 5
admin/src/main/java/com/flyer/foster/service/impl/AreaServiceImpl.java

@@ -28,16 +28,29 @@ import java.util.List;
 @Service
 public class AreaServiceImpl extends ServiceImpl<IAreaMapper, Area> implements IAreaService {
     @Override
-    public IPage<AreaRespDTO> getPageList(IPage<AreaRespDTO> page, AreaQueryDTO searchDTO) {
-        return baseMapper.getPageList(page, searchDTO);
+    public IPage<AreaRespDTO> getPageList(IPage<AreaRespDTO> page, AreaQueryDTO queryDTO) {
+        return baseMapper.getPageList(page, queryDTO);
     }
 
     @Transactional
     @Override
-    public boolean addArea(AreaAddDTO addDTO) {
+    public boolean addArea(List<AreaAddDTO> addDTOList) {
         Area area = new Area();
-        BeanUtil.copyProperties(addDTO, area);
-        return this.save(area);
+        for (AreaAddDTO addDTO : addDTOList) {
+            BeanUtil.copyProperties(addDTO, area);
+            if (area.getId() == null) {
+                return this.save(area);
+            } else {
+                return this.lambdaUpdate()
+                        .set(Area::getName, addDTO.getName())
+                        .set(Area::getGardenId, addDTO.getGardenId())
+                        .set(Area::getWkt, addDTO.getWkt())
+                        .set(Area::getStatus, addDTO.getStatus())
+                        .eq(Area::getId, addDTO.getId())
+                        .update();
+            }
+        }
+        return true;
     }
 
     @Transactional

+ 61 - 1
admin/src/main/java/com/flyer/foster/service/impl/GardenServiceImpl.java

@@ -1,10 +1,23 @@
 package com.flyer.foster.service.impl;
 
+import cn.dev33.satoken.stp.StpUtil;
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.flyer.exception.BusinessException;
+import com.flyer.foster.dto.*;
+import com.flyer.foster.entity.Area;
 import com.flyer.foster.entity.Garden;
 import com.flyer.foster.mapper.IGardenMapper;
+import com.flyer.foster.service.IAreaService;
 import com.flyer.foster.service.IGardenService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -16,5 +29,52 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class GardenServiceImpl extends ServiceImpl<IGardenMapper, Garden> implements IGardenService {
+    @Autowired
+    private IAreaService iAreaService;
+
+    @Override
+    public IPage<GardenRespDTO> getPageList(IPage<GardenRespDTO> page, GardenQueryDTO queryDTO) {
+        IPage<GardenRespDTO> pageList = baseMapper.getPageList(page, queryDTO);
+        for (GardenRespDTO record : pageList.getRecords()) {
+            // 获取区域
+            List<String> areaNameList = iAreaService.lambdaQuery()
+                    .eq(Area::getGardenId, record.getId())
+                    .list()
+                    .stream().map(Area::getName).collect(Collectors.toList());
+            record.setAreaNameList(areaNameList);
+        }
+        return pageList;
+    }
+
+    @Transactional
+    @Override
+    public boolean addGarden(GardenAddDTO addDTO) {
+        int tenantId = StpUtil.getTokenSession().getInt("tenantId");
+        Garden garden = new Garden();
+        garden.setTenantId(tenantId);
+        BeanUtil.copyProperties(addDTO, garden);
+        return this.save(garden);
+    }
+
+    @Transactional
+    @Override
+    public boolean deleteByIdList(List<Integer> idList) {
+        return baseMapper.deleteByIdList(idList);
+    }
 
+    @Transactional
+    @Override
+    public boolean updateGarden(GardenUpdateDTO updateDTO) {
+        Garden garden = baseMapper.selectById(updateDTO.getId());
+        if (garden == null) {
+            throw new BusinessException("无效的果园id");
+        }
+        return this.lambdaUpdate()
+                .set(Garden::getName, updateDTO.getName())
+                .set(updateDTO.getUserId() != null, Garden::getUserId, updateDTO.getUserId())
+                .set(StrUtil.isNotBlank(updateDTO.getBaseMapUrl()), Garden::getBaseMapUrl, updateDTO.getBaseMapUrl())
+                .set(updateDTO.getStatus() != null, Garden::getStatus, updateDTO.getStatus())
+                .eq(Garden::getId, updateDTO.getId())
+                .update();
+    }
 }

+ 19 - 9
admin/src/main/java/com/flyer/foster/service/impl/UserServiceImpl.java

@@ -3,19 +3,17 @@ package com.flyer.foster.service.impl;
 import cn.dev33.satoken.session.SaSession;
 import cn.dev33.satoken.stp.StpUtil;
 import cn.hutool.core.bean.BeanUtil;
-import cn.hutool.core.convert.Convert;
 import cn.hutool.crypto.SecureUtil;
 import cn.hutool.crypto.asymmetric.KeyType;
 import cn.hutool.crypto.asymmetric.RSA;
-import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.flyer.exception.BusinessException;
 import com.flyer.foster.consts.LoginDevice;
 import com.flyer.foster.consts.RedisKeyConst;
 import com.flyer.foster.dto.LoginDTO;
 import com.flyer.foster.dto.UserAddDto;
-import com.flyer.foster.dto.UserAddOrUpdateDTO;
-import com.flyer.foster.dto.UserSearchDTO;
+import com.flyer.foster.dto.UserQueryDTO;
+import com.flyer.foster.dto.UserRespDTO;
 import com.flyer.foster.entity.Role;
 import com.flyer.foster.entity.User;
 import com.flyer.foster.entity.UserRole;
@@ -113,17 +111,17 @@ public class UserServiceImpl extends ServiceImpl<IUserMapper, User> implements I
     }
 
     @Override
-    public IPage<UserSearchDTO> selectByPage(IPage<User> page, UserSearchDTO searchDTO) {
+    public IPage<UserRespDTO> getPageList(IPage<User> page, UserQueryDTO queryDTO) {
         int tenantId = StpUtil.getTokenSession().getInt("tenantId");
-        searchDTO.setTenantId(tenantId);
+        queryDTO.setTenantId(tenantId);
         // 查询管理员角色的账号
         Role adminRole = iRoleService.lambdaQuery().eq(Role::getIsAdmin, 1).eq(Role::getTenantId, tenantId).one();
         // 获取管理员用户id
         UserRole userRole = iUserRoleService.lambdaQuery().eq(UserRole::getRoleId, adminRole.getId()).one();
-        searchDTO.setAdminUserId(userRole.getUserId());
-        IPage<UserSearchDTO> pageResult = baseMapper.selectByPage(page, searchDTO);
+        queryDTO.setAdminUserId(userRole.getUserId());
+        IPage<UserRespDTO> pageResult = baseMapper.getPageList(page, queryDTO);
         // 获取单个视频对象的标签集合
-        for (UserSearchDTO record : pageResult.getRecords()) {
+        for (UserRespDTO record : pageResult.getRecords()) {
             List<Integer> roleIdList = iUserRoleService.lambdaQuery()
                     .eq(UserRole::getUserId, record.getId()).list()
                     .stream().map(UserRole::getRoleId).collect(Collectors.toList());
@@ -178,4 +176,16 @@ public class UserServiceImpl extends ServiceImpl<IUserMapper, User> implements I
         iUserRoleService.save(userRole);
         return true;
     }
+
+    @Override
+    public List<UserRespDTO> getList(UserQueryDTO queryDTO) {
+        int tenantId = StpUtil.getTokenSession().getInt("tenantId");
+        queryDTO.setTenantId(tenantId);
+        // 查询管理员角色的账号
+        Role adminRole = iRoleService.lambdaQuery().eq(Role::getIsAdmin, 1).eq(Role::getTenantId, tenantId).one();
+        // 获取管理员用户id
+        UserRole userRole = iUserRoleService.lambdaQuery().eq(UserRole::getRoleId, adminRole.getId()).one();
+        queryDTO.setAdminUserId(userRole.getUserId());
+        return baseMapper.getList(queryDTO);
+    }
 }

+ 1 - 1
admin/src/main/resources/application-dev.yml

@@ -21,7 +21,7 @@ sa-token:
   # token 名称(同时也是 cookie 名称)
   token-name: token
   # token 有效期(单位:秒) 默认30天,-1 代表永久有效
-  timeout: 3600
+  timeout: 86400
   # token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结
   active-timeout: -1
   # 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)

+ 1 - 1
admin/src/main/resources/mapper/AreaMapper.xml

@@ -10,7 +10,7 @@
 
     <select id="getPageList" resultType="com.flyer.foster.dto.AreaRespDTO">
         select a.id,
-               a.name         as areaName,
+               a.name         as name,
                case a.status
                    when 0 then '禁用'
                    when 1 then '启用'

+ 22 - 0
admin/src/main/resources/mapper/GardenMapper.xml

@@ -2,4 +2,26 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.flyer.foster.mapper.IGardenMapper">
 
+    <delete id="deleteByIdList">
+        delete from tb_garden where id in
+        <foreach collection="idList" item="id" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+
+    <select id="getPageList" resultType="com.flyer.foster.dto.GardenRespDTO">
+        select a.id           as id,
+               a.name         as name,
+               a.user_id      as userId,
+               b.username     as username,
+               case
+                   a.status
+                   when 0 then '禁用'
+                   when 1 then '启用'
+                   end        as statusName,
+               a.created_time as createdTime,
+               b.updated_time as updatedTime
+        from tb_garden a
+                 left join tb_user b on a.user_id = b.id
+    </select>
 </mapper>

+ 20 - 16
admin/src/main/resources/mapper/UserMapper.xml

@@ -7,7 +7,7 @@
             #{id}
         </foreach>
     </delete>
-    <select id="selectByPage" resultType="com.flyer.foster.dto.UserSearchDTO">
+    <select id="getPageList" resultType="com.flyer.foster.dto.UserRespDTO">
         select a.id        as id,
                a.username  as userName,
                a.status    as status,
@@ -28,24 +28,28 @@
         order by a.created_time desc
     </select>
 
-    <select id="selectUserAndRoleByUserIdOrUserName" resultType="com.flyer.foster.dto.UserSearchDTO">
-        select a.username  as username,
-               c.role_name as roleName
+    <select id="getList" resultType="com.flyer.foster.dto.UserRespDTO">
+        select a.id        as id,
+               a.username  as userName,
+               a.status    as status,
+               a.tenant_id as tenantId
         from tb_user a
-                 left join tb_user_role b on a.id = b.user_id and b.is_deleted = 0
-                 left join tb_role c on b.role_id = c.id and c.is_deleted = 0
-        <where>
-            a.is_deleted = 0
-            <if test="searchDTO.id!=null">
-                and a.id = #{searchDTO.id}
-            </if>
-            <if test="searchDTO.username!=null and searchDTO.username!=''">
-                and a.username = #{searchDTO.username}
-            </if>
-        </where>
+        where a.is_deleted = 0
+        <choose>
+            <when test="queryDTO.tenantId==0">
+                and a.tenant_id is not null
+            </when>
+            <otherwise>
+                and a.tenant_id = #{queryDTO.tenantId}
+            </otherwise>
+        </choose>
+        <if test="queryDTO.adminUserId!=null">
+            and a.id != #{queryDTO.adminUserId}
+        </if>
+        order by a.created_time desc
     </select>
 
-    <select id="adminListByPage" resultType="com.flyer.foster.dto.UserSearchDTO">
+    <select id="adminListByPage" resultType="com.flyer.foster.dto.UserRespDTO">
         select a.id          as id,
                a.username    as userName,
                a.status      as status,