Explorar el Código

更新了,新增标本编号不能重复功能,list查询,分页查询(待实现)

lwh hace 3 meses
padre
commit
a5cf1a2a60

+ 6 - 0
yudao-module-museum/yudao-module-museum-biz/pom.xml

@@ -46,6 +46,12 @@
             <groupId>cn.iocoder.boot</groupId>
             <artifactId>yudao-spring-boot-starter-test</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>easyexcel-core</artifactId>
+            <version>4.0.3</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 
 </project>

+ 44 - 17
yudao-module-museum/yudao-module-museum-biz/src/main/java/cn/iocoder/yudao/module/museum/controller/admin/museuminfo/MuseumInfoController.java

@@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import javax.validation.Valid;
+import java.util.List;
 
 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 
@@ -32,22 +33,22 @@ public class MuseumInfoController {
     //TODO 判断标本编号是否重复
     @PostMapping("/create")
     @Operation(summary = "新增标本")
-    public CommonResult<Integer> createMuseumInfo(@RequestBody MuseumInfoSaveVO saveVO){
-            String sampleId = saveVO.getSampleId();
-
-//        MuseumInfoDO result = museumInfoService.;
-//        if (result!=null){
-//            return CommonResult.error(1,"标本编号已存在");
-//        }else {
+    public CommonResult<Integer> createMuseumInfo(@RequestBody MuseumInfoSaveVO saveVO) {
+        String sampleId = saveVO.getSampleId();
+        MuseumInfoDO result = museumInfoService.getMuseumInfoBySampleId(sampleId);
+        if (result != null) {
+            return CommonResult.error(1, "标本编号已存在");
+        } else {
             return CommonResult.success(museumInfoService.createMuseumInfo(saveVO));
-//        }
+        }
     }
 
     @Operation(summary = "更新标本")
     public CommonResult<Boolean> updateMuseumInfo(@RequestBody MuseumInfoSaveVO saveVO){
+        museumInfoService.updateMuseumInfo(saveVO);
+        return CommonResult.success(true);
 //         saveVO.setSampleType(1);
-         museumInfoService.updateMuseumInfo(saveVO);
-         return CommonResult.success(true);
+
     }
 
     //TODO 需要提供原因,调用更新方法
@@ -71,23 +72,47 @@ public class MuseumInfoController {
 
     @GetMapping("/get")
     @Operation(summary = "查找标本")
-    public CommonResult<MuseumInfoRespVO> getMuseumInfo(@RequestParam("id") Integer id){
+    public CommonResult<MuseumInfoRespVO> selectMuseumInfo(@RequestParam("id") Integer id){
         MuseumInfoDO result = museumInfoService.selectMuseumInfo(id);
         MuseumInfoRespVO result1 = BeanUtils.toBean(result,MuseumInfoRespVO.class);
       return CommonResult.success(result1);
     }
 
+    @GetMapping("/selectMuseumInfoList")
+    @Operation(summary = "查询SampleTypeList")
+    public CommonResult<List<MuseumInfoDO>> getMuseumInfoList(@RequestParam("sampleType") Integer sampleType){
+        List<MuseumInfoDO> result = museumInfoService.selectMuseumInfoListBySampleType(sampleType);
+        return CommonResult.success(result);
+    }
+
     @GetMapping("/page")
     @Operation(summary = "获取分页")
-//    @PreAuthorize("@ss.hasPermission('system:user:query')")
-    public CommonResult<MuseumInfoPageReqVO> pageMuseumInfo(@Valid MuseumInfoPageReqVO pageReqVO){
-        PageResult<MuseumInfoDO> pageResult = museumInfoService.getUserPage(pageReqVO);
-        if (CollUtil.isEmpty(pageResult.getList())) {
-            return success(new PageResult<>(pageResult.getTotal()));
-        }
+    @PreAuthorize("@ss.hasPermission('museum:museuminfo:query')")
+    public CommonResult<PageResult<MuseumInfoRespVO>> getMuseumInfoPage(@Valid MuseumInfoPageReqVO pageVO){
+        PageResult<MuseumInfoDO> pageResult = museumInfoService.getMuseumInfoPage(pageVO);
+        return success(BeanUtils.toBean(pageResult, MuseumInfoRespVO.class));
     }
 
 
+
+
+
+
+//    @GetMapping("/get")
+//    @Operation(summary = "list数组")
+//   public CommonResult<MuseumInfoRespVO> getdo(@RequestParam("sampleType") Integer sampleType){
+//          MuseumInfoRespVO list =new MuseumInfoRespVO();
+//          Integer Ynmber =  selectMuseumInfoBySampleType(1)
+//          Integer  hs =  selectMuseumInfoBySampleType(2)
+
+//          DO.setYnmber(Ynmber);
+
+
+//    public CommonResult<MuseumInfoRespVO> getMuseumInfo(@RequestParam("sampleId") String sampleId){
+//
+//    }
+
+
     //@GetMapping("/get")
 //    @Operation(summary = "查询")
 //    public CommonResult<List<MuseumTextRespVO>> getMuseumText(@RequestParam("id") Integer id){
@@ -115,4 +140,6 @@ public class MuseumInfoController {
 ////          DO.setYnumber(Ynmber);
 //   }
 
+
+
 }

+ 8 - 43
yudao-module-museum/yudao-module-museum-biz/src/main/java/cn/iocoder/yudao/module/museum/controller/admin/museuminfo/vo/MuseumInfoPageReqVO.java

@@ -1,13 +1,19 @@
 package cn.iocoder.yudao.module.museum.controller.admin.museuminfo.vo;
 
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import cn.iocoder.yudao.module.museum.controller.admin.museuminfo.MuseumInfoController;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
 
 import java.time.LocalDateTime;
 
 @Schema(description = "博物馆-标本信息-分页 pageReq VO")
 @Data
-public class MuseumInfoPageReqVO {
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class MuseumInfoPageReqVO extends PageParam {
     private Integer id;
 
     @Schema(description = "标本编号")
@@ -16,47 +22,6 @@ public class MuseumInfoPageReqVO {
     private Integer sampleType;
 
     private String place;
-
-    private String chineseName;
-
-    private String englishName;
-
-    private String internationName;
-
-    private Integer keepType;
-
-    private String element;
-
-    private String  local;
-
-    private LocalDateTime bronTime ;
-
-    private String stratum;
-
-    private LocalDateTime findTime;
-
-    private String size;
-
-    private Long weight;
-
-    private String origin;
-
-    private String offerMan;
-
-    private String character;
-
-    private String condition;
-
-    private String joinTime;
-
-    private String useWay;
-
-    private String moneyId;
-
-    private String deleteReason;
-
-    private String samplePicture;
-
-    private String tip;
+    
 }
 

+ 11 - 9
yudao-module-museum/yudao-module-museum-biz/src/main/java/cn/iocoder/yudao/module/museum/controller/admin/museuminfo/vo/MuseumInfoRespVO.java

@@ -1,5 +1,6 @@
 package cn.iocoder.yudao.module.museum.controller.admin.museuminfo.vo;
 
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
@@ -7,6 +8,7 @@ import java.time.LocalDateTime;
 
 @Schema(description = "博物馆-标本信息 Resp VO")
 @Data
+@ExcelIgnoreUnannotated
 public class MuseumInfoRespVO {
 
     //    private Integer Ynumber;
@@ -47,17 +49,17 @@ public class MuseumInfoRespVO {
 
     private String character;
 
-    private String condition;
+//    private Integer condition;
 
-    private String joinTime;
+//    private String joinTime;
 
-    private String useWay;
+//    private String useWay;
 
-    private String moneyId;
+//    private String moneyId;
 
-    private String deleteReason;
-
-    private String samplePicture;
-
-    private String tip;
+//    private String deleteReason;
+//
+//    private String samplePicture;
+//
+//    private String tip;
 }

+ 13 - 13
yudao-module-museum/yudao-module-museum-biz/src/main/java/cn/iocoder/yudao/module/museum/controller/admin/museuminfo/vo/MuseumInfoSaveVO.java

@@ -46,17 +46,17 @@ public class MuseumInfoSaveVO {
 
     private String character;
 
-    private String condition;
-
-    private String joinTime;
-
-    private String useWay;
-
-    private String moneyId;
-
-    private String deleteReason;
-
-    private String samplePicture;
-
-    private String tip;
+//    private Integer condition;
+//
+//    private String joinTime;
+//
+//    private String useWay;
+//
+//    private String moneyId;
+//
+//    private String deleteReason;
+//
+//    private String samplePicture;
+//
+//    private String tip;
 }

+ 26 - 26
yudao-module-museum/yudao-module-museum-biz/src/main/java/cn/iocoder/yudao/module/museum/dal/database/museuminfo/MuseumInfoDO.java

@@ -24,7 +24,7 @@ public class MuseumInfoDO extends BaseDO {
      * 标本ID
      */
     @TableId
-    private Integer id;
+    private Long id;
     /**
      * 标本编号
      */
@@ -96,30 +96,30 @@ public class MuseumInfoDO extends BaseDO {
     /**
      * 馆藏状态
      */
-    private String condition;
-    /**
-     * 入藏时间
-     */
-    private String joinTime;
-    /**
-     * 用途
-     */
-    private String useWay;
-    /**
-     * 资产号
-     */
-    private String moneyId;
-    /**
-     * 删除原因
-     */
-    private String deleteReason;
-    /**
-     * 标本图片
-     */
-    private String samplePicture;
-    /**
-     * 备注
-     */
-    private String tip;
+//    private Integer condition;
+//    /**
+//     * 入藏时间
+//     */
+//    private String joinTime;
+//    /**
+//     * 用途
+//     */
+//    private String useWay;
+//    /**
+//     * 资产号
+//     */
+//    private String moneyId;
+//    /**
+//     * 删除原因
+//     */
+//    private String deleteReason;
+//    /**
+//     * 标本图片
+//     */
+//    private String samplePicture;
+//    /**
+//     * 备注
+//     */
+//    private String tip;
 
 }

+ 36 - 5
yudao-module-museum/yudao-module-museum-biz/src/main/java/cn/iocoder/yudao/module/museum/dal/mysql/museuminfo/MuseumInfoMapper.java

@@ -1,8 +1,12 @@
 package cn.iocoder.yudao.module.museum.dal.mysql.museuminfo;
 
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.museum.controller.admin.museuminfo.vo.MuseumInfoPageReqVO;
 import cn.iocoder.yudao.module.museum.dal.database.museuminfo.MuseumInfoDO;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
@@ -21,10 +25,37 @@ public interface MuseumInfoMapper extends BaseMapperX<MuseumInfoDO> {
     @Select("SELECT * FROM museum_info WHERE id =#{id} AND deleted =0 ")
     MuseumInfoDO selectMuseumInfoById(@Param("id") Integer id);
 
-//    @Select("SELECT * FROM museum_info WHERE sample_type  =#{sampleType} AND deleted =0 ")
-//    List<MuseumInfoDO> selectMuseumInfoBySampleType(@Param("sampleType") Integer sampleType);
+    @Select("SELECT * FROM museum_info WHERE sample_id =#{sampleId} ")
+    MuseumInfoDO getMuseumInfoBySampleId(@Param("sampleId") String sampleId);
+
+    @Select("SELECT * FROM museum_info WHERE sample_type  =#{sampleType}")
+    List<MuseumInfoDO> selectMuseumInfoListBySampleType(@Param("sampleType") Integer sampleType);
+
+//    @Select("SELECT COUNT(*)  FROM museum_info WHERE sample_type  =#{sampleType} ")
+//    Integer countMuseumInfoBySampleType(@Param("sampleType") Integer sampleType);
+
+
+    default PageResult<MuseumInfoDO> selectPage(MuseumInfoPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<MuseumInfoDO>())
+//                .likeIfPresent(MuseumInfoDO::getSampleId,reqVO.getSampleId())
+//                .eqIfPresent(MuseumInfoDO::getSampleType,reqVO.getSampleType())
+//                .likeIfPresent(MuseumInfoDO::getPlace,reqVO.getPlace())
+//                .orderByDesc(reqVO.getId() != null,MuseumInfoDO::getId));
+                ;}
+
+//    default PageResult<MuseumInfoDO> selectPage1(MuseumInfoPageReqVO reqVO) {
+//        return selectPage(reqVO, new LambdaQueryWrapperX<MuseumInfoDO>()
+//                .likeIfPresent(MuseumInfoDO::getSampleId,reqVO.getSampleId())
+//                .eqIfPresent(MuseumInfoDO::getSampleType,reqVO.getSampleType())
+//                .likeIfPresent(MuseumInfoDO::getPlace,reqVO.getPlace())
+//                .orderByDesc(reqVO.getId() != null,MuseumInfoDO::getId)); // 按照 id 倒序
+//    }
+//
+//    default PageResult<MuseumInfoDO> selectPage2(MuseumInfoPageReqVO reqVO) {
+//        return selectPage(reqVO, new LambdaQueryWrapperX<MuseumInfoDO>()
+//                .likeIfPresent(MuseumInfoDO::getPlace, reqVO.getPlace())
+//        );
+//    }
 
-        @Select("SELECT COUNT(*)  FROM museum_info WHERE sample_type  =#{sampleType} ")
-        Integer selectMuseumInfoBySampleType(@Param("sampleType") Integer sampleType);
 
-}
+    }

+ 16 - 4
yudao-module-museum/yudao-module-museum-biz/src/main/java/cn/iocoder/yudao/module/museum/service/museuminfo/MuseumInfoService.java

@@ -4,8 +4,11 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.module.museum.controller.admin.museuminfo.vo.MuseumInfoPageReqVO;
 import cn.iocoder.yudao.module.museum.controller.admin.museuminfo.vo.MuseumInfoSaveVO;
 import cn.iocoder.yudao.module.museum.dal.database.museuminfo.MuseumInfoDO;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 @Service
 public interface MuseumInfoService {
    /**
@@ -25,12 +28,21 @@ public interface MuseumInfoService {
    /**
     * 查询标本
     * */
-   MuseumInfoDO selectMuseumInfo(Integer id);
+   MuseumInfoDO selectMuseumInfo (Integer id);
+
    /**
-    * 获得用户分页列表
+    * 查询标本编号
+    * */
+   MuseumInfoDO getMuseumInfoBySampleId(String sampleId);
+   /**
+   * 查询标本类型List
+   * */
+   List<MuseumInfoDO> selectMuseumInfoListBySampleType(Integer sampleType);
+    /**
+    * 分页列表
     *
-    * @param pageReqVO 分页条件
+    * @param pageVO 分页条件
     * @return 分页列表
     */
-   PageResult<MuseumInfoDO> getUserPage(MuseumInfoPageReqVO pageReqVO);
+   PageResult<MuseumInfoDO> getMuseumInfoPage(MuseumInfoPageReqVO pageVO);
 }

+ 47 - 10
yudao-module-museum/yudao-module-museum-biz/src/main/java/cn/iocoder/yudao/module/museum/service/museuminfo/MuseumInfoServiceImpl.java

@@ -1,46 +1,83 @@
 package cn.iocoder.yudao.module.museum.service.museuminfo;
 
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.module.museum.controller.admin.museuminfo.vo.MuseumInfoPageReqVO;
 import cn.iocoder.yudao.module.museum.controller.admin.museuminfo.vo.MuseumInfoSaveVO;
 import cn.iocoder.yudao.module.museum.dal.database.museuminfo.MuseumInfoDO;
 import cn.iocoder.yudao.module.museum.dal.mysql.museuminfo.MuseumInfoMapper;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.List;
+import java.util.Set;
+
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.singleton;
 
 @Service
 public  class  MuseumInfoServiceImpl implements MuseumInfoService {
 
    @Resource
    private MuseumInfoMapper museumInfoMapper;
+
    /**
-    *新增标本
+    * 新增标本
     */
    @Override
-   public Integer createMuseumInfo(MuseumInfoSaveVO saveVO){
-     return museumInfoMapper.insert(BeanUtils.toBean(saveVO, MuseumInfoDO.class));//insert(内置)
+   public Integer createMuseumInfo(MuseumInfoSaveVO saveVO) {
+      return museumInfoMapper.insert(BeanUtils.toBean(saveVO, MuseumInfoDO.class));//insert(内置)
    }
+
    /**
-    *更新标本
+    * 更新标本
     */
    @Override
-   public void updateMuseumInfo(MuseumInfoSaveVO saveVO){
-      museumInfoMapper.updateMuseumInfo(BeanUtils.toBean(saveVO,MuseumInfoDO.class));
+   public void updateMuseumInfo(MuseumInfoSaveVO saveVO) {
+      museumInfoMapper.updateMuseumInfo(BeanUtils.toBean(saveVO, MuseumInfoDO.class));
    }
+
    /**
-    *删除标本
+    * 删除标本
     */
    @Override
-   public void deleteMuseumInfo(Integer id){
+   public void deleteMuseumInfo(Integer id) {
 //      museumInfoMapper.deleteMuseumInfo(id);
       museumInfoMapper.deleteById(id);
    }
+
    /**
-    *查询标本
+    * 查询标本id
     */
    @Override
-   public MuseumInfoDO selectMuseumInfo(Integer id){
+   public MuseumInfoDO selectMuseumInfo(Integer id) {
       return museumInfoMapper.selectMuseumInfoById(id);
    }
 
+   /**
+    * 查询标本SampleId
+    */
+   @Override
+   public MuseumInfoDO getMuseumInfoBySampleId (String sampleId) {
+      return museumInfoMapper.getMuseumInfoBySampleId(sampleId);
+   }
+   /**
+    * 查询SampleTypeList
+    */
+   @Override
+   public List<MuseumInfoDO> selectMuseumInfoListBySampleType(Integer sampleType){
+      return museumInfoMapper.selectMuseumInfoListBySampleType(sampleType);
+   }
+   /**
+   * 分页列表
+    */
+   @Override
+   public PageResult<MuseumInfoDO> getMuseumInfoPage(MuseumInfoPageReqVO reqVO){
+//      Set<Long> ids = reqVO.getId() != null ?
+//              permissionService.getUserRoleIdListByRoleId(singleton(reqVO.getRoleId())) : null;
+      return museumInfoMapper.selectPage(reqVO);
+   }
+
+
 }
+
+

+ 1 - 1
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java

@@ -268,7 +268,7 @@ public class AdminUserServiceImpl implements AdminUserService {
     public AdminUserDO getUserByMobile(String mobile) {
         return userMapper.selectByMobile(mobile);
     }
-
+//1
     @Override
     public PageResult<AdminUserDO> getUserPage(UserPageReqVO reqVO) {
         // 如果有角色编号,查询角色对应的用户编号