Browse Source

批量增加 按照时间给状态 完善增加接口

zhangyang 2 years ago
parent
commit
7ab15d960d

+ 23 - 17
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/PoTetherController.java

@@ -5,6 +5,7 @@ import java.util.List;
 import javax.servlet.http.HttpServletResponse;
 
 import com.ruoyi.common.constant.UserConstants;
+import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.system.domain.PoCollection;
 import com.ruoyi.system.domain.PoTetherandcollection;
 import com.ruoyi.system.domain.PoUser;
@@ -141,7 +142,8 @@ public class PoTetherController extends BaseController
     @PreAuthorize("@ss.hasPermi('system:tether:add')")
     @Log(title = "套系", businessType = BusinessType.INSERT)
     @PostMapping("/add")
-    public AjaxResult add(@RequestBody TetherVo tetherVo, @RequestBody @Param("poUser") PoUser poUser)
+    public AjaxResult add(@RequestBody TetherVo tetherVo,
+                          @RequestBody @Param("poUser") PoUser poUser)
     {
         //判断当前用户是否有操作的权限
         poUserService.checkUserAllowed(poUser);
@@ -152,9 +154,23 @@ public class PoTetherController extends BaseController
         if(UserConstants.NOT_UNIQUE.equals(poTetherService.checkPostTetherImageUnique(tetherVo))){
             return AjaxResult.error("新增失败"+tetherVo.getImage()+"已经存在");
         }
+
         tetherVo.setCreateBy(getUsername());
         tetherVo.setCreateTime(new Date());
-        return toAjax(poTetherService.insertPoTetherWithCollection(tetherVo));
+
+        Date nowTime = new Date();
+        nowTime = DateUtils.getNowDate();
+
+        if (nowTime.after(tetherVo.getShowTimeEnd())){
+            tetherVo.setSellStatus(2);
+        }
+        else if (nowTime.before(tetherVo.getShowTimeStart())){
+            tetherVo.setSellStatus(1);
+        }else{
+            tetherVo.setSellStatus(0);
+        }
+        poTetherService.insertPoTetherWithCollection(tetherVo);
+        return success("新增成功");
     }
 
     /**
@@ -197,13 +213,10 @@ public class PoTetherController extends BaseController
             return AjaxResult.error("修改失败"+tetherVo.getImage()+"已经存在");
         }
 
-        //清理所有套系的缓存数
-        //因为对于修改操作,用户是可以修改藏品的分类的,如果用户修改了藏品的分类,
-        // 那么原来分类下将少一个藏品,新的分类下将多一个藏品,这样的话,两个分类下的藏品列表数据都发生了变化。
-
         tetherVo.setUpdateBy(getUsername());
         tetherVo.setUpdateTime(new Date());
-        return toAjax(poTetherService.updatePoTetherWithCollection(tetherVo));
+        poTetherService.updatePoTetherWithCollection(tetherVo);
+        return success("修改成功");
     }
 
     /**
@@ -213,19 +226,12 @@ public class PoTetherController extends BaseController
     @PreAuthorize("@ss.hasPermi('system:tether:remove')")
     @Log(title = "套系", businessType = BusinessType.DELETE)
     @DeleteMapping("/remove/{tetherIds}")
-    public AjaxResult remove(@PathVariable Long[] tetherIds)
-    {
+    public AjaxResult remove(@PathVariable Long[] tetherIds) throws Exception {
         if (!getUsername().equals("admin")){
             return AjaxResult.error("删除消息失败当前用户不是管理员");
         }
-        TetherVo tetherVo = poTetherService.selectPoTetherByTetherIdsWithCollection(tetherIds);
-        if (tetherVo == null){
-            return error("想要删除的套系不存在");
-        }
-        if (tetherVo.getCochain() == 0){
-            return error("想要删除的套系已经上链");
-        }
-        return toAjax(poTetherService.deletePoTetherByTetherIdsWithCollection(tetherIds));
+        poTetherService.deletePoTetherByTetherIdsWithCollection(tetherIds);
+        return success("删除成功");
     }
 
     /**

+ 2 - 2
ruoyi-admin/src/main/resources/application-druid.yml

@@ -6,7 +6,7 @@ spring:
         druid:
             # 主库数据源
             master:
-                url: jdbc:mysql://localhost: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&allowMultiQueries=true
                 username: root
                 password: zhangyang0311
             # 从库数据源
@@ -51,7 +51,7 @@ spring:
                     # 慢SQL记录
                     log-slow-sql: true
                     slow-sql-millis: 1000
-                    merge-sql: true
+                    merge-sql: false
                 wall:
                     config:
                         multi-statement-allow: true   

+ 53 - 8
ruoyi-admin/src/main/resources/application.yml

@@ -99,14 +99,59 @@ token:
     # 令牌有效期(默认30分钟)
     expireTime: 30
   
-# MyBatis配置
-mybatis:
-    # 搜索指定包别名
-    typeAliasesPackage: com.ruoyi.**.domain
-    # 配置mapper的扫描,找到所有的mapper.xml映射文件
-    mapperLocations: classpath*:mapper/**/*Mapper.xml
-    # 加载全局的配置文件
-    configLocation: classpath:mybatis/mybatis-config.xml
+## MyBatis配置
+#mybatis:
+#    # 搜索指定包别名
+#    typeAliasesPackage: com.ruoyi.**.domain
+#    # 配置mapper的扫描,找到所有的mapper.xml映射文件
+#    mapperLocations: classpath*:mapper/**/*Mapper.xml
+#    # 加载全局的配置文件
+#    configLocation: classpath:mybatis/mybatis-config.xml
+# MyBatis Plus配置
+mybatis-plus:
+  # 不支持多包, 如有需要可在注解配置 或 提升扫包等级
+  # 例如 com.**.**.mapper
+  mapperPackage: com.ruoyi.**.mapper
+
+
+  # 对应的 XML 文件位置
+  mapperLocations: classpath*:mapper/**/*Mapper.xml
+  # 实体扫描,多个package用逗号或者分号分隔
+  typeAliasesPackage: com.ruoyi.**.domain
+  # 启动时是否检查 MyBatis XML 文件的存在,默认不检查
+  checkConfigLocation: false
+  configuration:
+    # 自动驼峰命名规则(camel case)映射
+    mapUnderscoreToCamelCase: true
+    # MyBatis 自动映射策略
+    # NONE:不启用 PARTIAL:只对非嵌套 resultMap 自动映射 FULL:对所有 resultMap 自动映射
+    autoMappingBehavior: PARTIAL
+    # MyBatis 自动映射时未知列或未知属性处理策
+    # NONE:不做处理 WARNING:打印相关警告 FAILING:抛出异常和详细信息
+    autoMappingUnknownColumnBehavior: NONE
+    # 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl
+    # 关闭日志记录 (可单纯使用 p6spy 分析) org.apache.ibatis.logging.nologging.NoLoggingImpl
+    # 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl
+    logImpl: org.apache.ibatis.logging.slf4j.Slf4jImpl
+  global-config:
+    # 是否打印 Logo banner
+    banner: false
+    dbConfig:
+      # 主键类型
+      # AUTO 自增 NONE 空 INPUT 用户输入 ASSIGN_ID 雪花 ASSIGN_UUID 唯一 UUID
+      idType: ASSIGN_ID
+      # 逻辑已删除值
+      logicDeleteValue: 2
+      # 逻辑未删除值
+      logicNotDeleteValue: 0
+      # 字段验证策略之 insert,在 insert 的时候的字段验证策略
+      # IGNORED 忽略 NOT_NULL 非NULL NOT_EMPTY 非空 DEFAULT 默认 NEVER 不加入 SQL
+      insertStrategy: NOT_NULL
+      # 字段验证策略之 update,在 update 的时候的字段验证策略
+      updateStrategy: NOT_NULL
+      # 字段验证策略之 select,在 select 的时候的字段验证策略既 wrapper 根据内部 entity 生成的 where 条件
+      where-strategy: NOT_NULL
+
 
 # PageHelper分页插件
 pagehelper: 

+ 7 - 0
ruoyi-common/pom.xml

@@ -23,6 +23,13 @@
             <artifactId>spring-context-support</artifactId>
         </dependency>
 
+        <!--整合mybatis-plus-->
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+            <version>3.5.2</version>
+        </dependency>
+
         <!-- SpringWeb模块 -->
         <dependency>
             <groupId>org.springframework</groupId>

+ 132 - 132
ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java

@@ -1,132 +1,132 @@
-package com.ruoyi.framework.config;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import javax.sql.DataSource;
-import org.apache.ibatis.io.VFS;
-import org.apache.ibatis.session.SqlSessionFactory;
-import org.mybatis.spring.SqlSessionFactoryBean;
-import org.mybatis.spring.boot.autoconfigure.SpringBootVFS;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.env.Environment;
-import org.springframework.core.io.DefaultResourceLoader;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
-import org.springframework.core.io.support.ResourcePatternResolver;
-import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
-import org.springframework.core.type.classreading.MetadataReader;
-import org.springframework.core.type.classreading.MetadataReaderFactory;
-import org.springframework.util.ClassUtils;
-import com.ruoyi.common.utils.StringUtils;
-
-/**
- * Mybatis支持*匹配扫描包
- * 
- * @author ruoyi
- */
-@Configuration
-public class MyBatisConfig
-{
-    @Autowired
-    private Environment env;
-
-    static final String DEFAULT_RESOURCE_PATTERN = "**/*.class";
-
-    public static String setTypeAliasesPackage(String typeAliasesPackage)
-    {
-        ResourcePatternResolver resolver = (ResourcePatternResolver) new PathMatchingResourcePatternResolver();
-        MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resolver);
-        List<String> allResult = new ArrayList<String>();
-        try
-        {
-            for (String aliasesPackage : typeAliasesPackage.split(","))
-            {
-                List<String> result = new ArrayList<String>();
-                aliasesPackage = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX
-                        + ClassUtils.convertClassNameToResourcePath(aliasesPackage.trim()) + "/" + DEFAULT_RESOURCE_PATTERN;
-                Resource[] resources = resolver.getResources(aliasesPackage);
-                if (resources != null && resources.length > 0)
-                {
-                    MetadataReader metadataReader = null;
-                    for (Resource resource : resources)
-                    {
-                        if (resource.isReadable())
-                        {
-                            metadataReader = metadataReaderFactory.getMetadataReader(resource);
-                            try
-                            {
-                                result.add(Class.forName(metadataReader.getClassMetadata().getClassName()).getPackage().getName());
-                            }
-                            catch (ClassNotFoundException e)
-                            {
-                                e.printStackTrace();
-                            }
-                        }
-                    }
-                }
-                if (result.size() > 0)
-                {
-                    HashSet<String> hashResult = new HashSet<String>(result);
-                    allResult.addAll(hashResult);
-                }
-            }
-            if (allResult.size() > 0)
-            {
-                typeAliasesPackage = String.join(",", (String[]) allResult.toArray(new String[0]));
-            }
-            else
-            {
-                throw new RuntimeException("mybatis typeAliasesPackage 路径扫描错误,参数typeAliasesPackage:" + typeAliasesPackage + "未找到任何包");
-            }
-        }
-        catch (IOException e)
-        {
-            e.printStackTrace();
-        }
-        return typeAliasesPackage;
-    }
-
-    public Resource[] resolveMapperLocations(String[] mapperLocations)
-    {
-        ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
-        List<Resource> resources = new ArrayList<Resource>();
-        if (mapperLocations != null)
-        {
-            for (String mapperLocation : mapperLocations)
-            {
-                try
-                {
-                    Resource[] mappers = resourceResolver.getResources(mapperLocation);
-                    resources.addAll(Arrays.asList(mappers));
-                }
-                catch (IOException e)
-                {
-                    // ignore
-                }
-            }
-        }
-        return resources.toArray(new Resource[resources.size()]);
-    }
-
-    @Bean
-    public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception
-    {
-        String typeAliasesPackage = env.getProperty("mybatis.typeAliasesPackage");
-        String mapperLocations = env.getProperty("mybatis.mapperLocations");
-        String configLocation = env.getProperty("mybatis.configLocation");
-        typeAliasesPackage = setTypeAliasesPackage(typeAliasesPackage);
-        VFS.addImplClass(SpringBootVFS.class);
-
-        final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
-        sessionFactory.setDataSource(dataSource);
-        sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
-        sessionFactory.setMapperLocations(resolveMapperLocations(StringUtils.split(mapperLocations, ",")));
-        sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(configLocation));
-        return sessionFactory.getObject();
-    }
-}
+//package com.ruoyi.framework.config;
+//
+//import java.io.IOException;
+//import java.util.ArrayList;
+//import java.util.Arrays;
+//import java.util.HashSet;
+//import java.util.List;
+//import javax.sql.DataSource;
+//import org.apache.ibatis.io.VFS;
+//import org.apache.ibatis.session.SqlSessionFactory;
+//import org.mybatis.spring.SqlSessionFactoryBean;
+//import org.mybatis.spring.boot.autoconfigure.SpringBootVFS;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.core.env.Environment;
+//import org.springframework.core.io.DefaultResourceLoader;
+//import org.springframework.core.io.Resource;
+//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+//import org.springframework.core.io.support.ResourcePatternResolver;
+//import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
+//import org.springframework.core.type.classreading.MetadataReader;
+//import org.springframework.core.type.classreading.MetadataReaderFactory;
+//import org.springframework.util.ClassUtils;
+//import com.ruoyi.common.utils.StringUtils;
+//
+///**
+// * Mybatis支持*匹配扫描包
+// *
+// * @author ruoyi
+// */
+//@Configuration
+//public class MyBatisConfig
+//{
+//    @Autowired
+//    private Environment env;
+//
+//    static final String DEFAULT_RESOURCE_PATTERN = "**/*.class";
+//
+//    public static String setTypeAliasesPackage(String typeAliasesPackage)
+//    {
+//        ResourcePatternResolver resolver = (ResourcePatternResolver) new PathMatchingResourcePatternResolver();
+//        MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resolver);
+//        List<String> allResult = new ArrayList<String>();
+//        try
+//        {
+//            for (String aliasesPackage : typeAliasesPackage.split(","))
+//            {
+//                List<String> result = new ArrayList<String>();
+//                aliasesPackage = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX
+//                        + ClassUtils.convertClassNameToResourcePath(aliasesPackage.trim()) + "/" + DEFAULT_RESOURCE_PATTERN;
+//                Resource[] resources = resolver.getResources(aliasesPackage);
+//                if (resources != null && resources.length > 0)
+//                {
+//                    MetadataReader metadataReader = null;
+//                    for (Resource resource : resources)
+//                    {
+//                        if (resource.isReadable())
+//                        {
+//                            metadataReader = metadataReaderFactory.getMetadataReader(resource);
+//                            try
+//                            {
+//                                result.add(Class.forName(metadataReader.getClassMetadata().getClassName()).getPackage().getName());
+//                            }
+//                            catch (ClassNotFoundException e)
+//                            {
+//                                e.printStackTrace();
+//                            }
+//                        }
+//                    }
+//                }
+//                if (result.size() > 0)
+//                {
+//                    HashSet<String> hashResult = new HashSet<String>(result);
+//                    allResult.addAll(hashResult);
+//                }
+//            }
+//            if (allResult.size() > 0)
+//            {
+//                typeAliasesPackage = String.join(",", (String[]) allResult.toArray(new String[0]));
+//            }
+//            else
+//            {
+//                throw new RuntimeException("mybatis typeAliasesPackage 路径扫描错误,参数typeAliasesPackage:" + typeAliasesPackage + "未找到任何包");
+//            }
+//        }
+//        catch (IOException e)
+//        {
+//            e.printStackTrace();
+//        }
+//        return typeAliasesPackage;
+//    }
+//
+//    public Resource[] resolveMapperLocations(String[] mapperLocations)
+//    {
+//        ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
+//        List<Resource> resources = new ArrayList<Resource>();
+//        if (mapperLocations != null)
+//        {
+//            for (String mapperLocation : mapperLocations)
+//            {
+//                try
+//                {
+//                    Resource[] mappers = resourceResolver.getResources(mapperLocation);
+//                    resources.addAll(Arrays.asList(mappers));
+//                }
+//                catch (IOException e)
+//                {
+//                    // ignore
+//                }
+//            }
+//        }
+//        return resources.toArray(new Resource[resources.size()]);
+//    }
+//
+//    @Bean
+//    public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception
+//    {
+//        String typeAliasesPackage = env.getProperty("mybatis.typeAliasesPackage");
+//        String mapperLocations = env.getProperty("mybatis.mapperLocations");
+//        String configLocation = env.getProperty("mybatis.configLocation");
+//        typeAliasesPackage = setTypeAliasesPackage(typeAliasesPackage);
+//        VFS.addImplClass(SpringBootVFS.class);
+//
+//        final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
+//        sessionFactory.setDataSource(dataSource);
+//        sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
+//        sessionFactory.setMapperLocations(resolveMapperLocations(StringUtils.split(mapperLocations, ",")));
+//        sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(configLocation));
+//        return sessionFactory.getObject();
+//    }
+//}

+ 19 - 0
ruoyi-framework/src/main/java/com/ruoyi/framework/config/MybatisPlusConfig.java

@@ -0,0 +1,19 @@
+package com.ruoyi.framework.config;
+
+import com.baomidou.mybatisplus.annotation.DbType;
+import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class MybatisPlusConfig {
+    @Bean
+    public MybatisPlusInterceptor mybatisPlusInterceptor() {
+        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
+        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
+        return interceptor;
+    }
+}
+
+

+ 22 - 6
ruoyi-system/src/main/java/com/ruoyi/system/domain/PoTether.java

@@ -1,6 +1,8 @@
 package com.ruoyi.system.domain;
 
 import java.util.Date;
+
+import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
@@ -41,7 +43,12 @@ public class PoTether extends BaseEntity
     /** 展示时间 */
     @JsonFormat(pattern = "yyyy-MM-dd")
     @Excel(name = "展示时间", width = 30, dateFormat = "yyyy-MM-dd")
-    private Date showTime;
+    private Date showTimeStart;
+
+    /** 展示时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "展示时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date showTimeEnd;
 
     /** 数量 */
     @Excel(name = "数量")
@@ -66,6 +73,14 @@ public class PoTether extends BaseEntity
      */
     private String delFlag;
 
+    public void setShowTimeEnd(Date showTimeEnd) {
+        this.showTimeEnd = showTimeEnd;
+    }
+
+    public Date getShowTimeEnd() {
+        return showTimeEnd;
+    }
+
     public void setExchange(Integer exchange) {
         this.exchange = exchange;
     }
@@ -133,14 +148,14 @@ public class PoTether extends BaseEntity
     {
         return tetherName;
     }
-    public void setShowTime(Date showTime)
+    public void setShowTimeStart(Date showTime)
     {
-        this.showTime = showTime;
+        this.showTimeStart = showTime;
     }
 
-    public Date getShowTime()
+    public Date getShowTimeStart()
     {
-        return showTime;
+        return showTimeStart;
     }
     public void setTotal(Long total)
     {
@@ -166,7 +181,8 @@ public class PoTether extends BaseEntity
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
                 .append("tetherId", getTetherId())
                 .append("tetherName", getTetherName())
-                .append("showTime", getShowTime())
+                .append("showTimeStart", getShowTimeStart())
+                .append("showTimeEnd",getShowTimeEnd())
                 .append("createBy", getCreateBy())
                 .append("createTime", getCreateTime())
                 .append("updateBy", getUpdateBy())

+ 3 - 1
ruoyi-system/src/main/java/com/ruoyi/system/domain/PoTetherandcollection.java

@@ -5,13 +5,15 @@ import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
 
+import java.io.Serializable;
+
 /**
  * 【请填写功能名称】对象 po_TetherAndcollection
  *
  * @author ruoyi
  * @date 2023-02-14
  */
-public class PoTetherandcollection extends BaseEntity
+public class PoTetherandcollection extends BaseEntity implements Serializable
 {
     private static final long serialVersionUID = 1L;
 

+ 9 - 1
ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/TetherVo.java

@@ -10,7 +10,15 @@ import java.util.List;
 
 public class TetherVo extends PoTether {
 
-    private List<PoTetherandcollection> poTetherandcollections = new ArrayList<>(); //套系对应的藏品信息
+    private List<PoTetherandcollection> poTetherandcollections  ; //套系对应的藏品信息
+
+
+    public TetherVo(){}
+
+    public TetherVo(List<PoTetherandcollection> poTetherandcollections ){
+        this.poTetherandcollections = poTetherandcollections;
+
+    }
 
     public void setPoTetherandcollections(List<PoTetherandcollection> poTetherandcollections) {
         this.poTetherandcollections = poTetherandcollections;

+ 2 - 1
ruoyi-system/src/main/java/com/ruoyi/system/mapper/PoTetherMapper.java

@@ -3,6 +3,7 @@ package com.ruoyi.system.mapper;
 import java.util.Date;
 import java.util.List;
 
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ruoyi.system.domain.PoTether;
 import com.ruoyi.system.domain.PoTetherandcollection;
 import org.apache.ibatis.annotations.Param;
@@ -13,7 +14,7 @@ import org.apache.ibatis.annotations.Param;
  * @author ruoyi
  * @date 2023-02-12
  */
-public interface PoTetherMapper
+public interface PoTetherMapper extends BaseMapper<PoTether>
 {
     /**
      * 查询套系

+ 6 - 6
ruoyi-system/src/main/java/com/ruoyi/system/mapper/PoTetherandcollectionMapper.java

@@ -1,6 +1,8 @@
 package com.ruoyi.system.mapper;
 
 import java.util.List;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ruoyi.system.domain.PoTetherandcollection;
 import org.apache.ibatis.annotations.Param;
 
@@ -10,7 +12,7 @@ import org.apache.ibatis.annotations.Param;
  * @author ruoyi
  * @date 2023-02-14
  */
-public interface PoTetherandcollectionMapper
+public interface PoTetherandcollectionMapper extends BaseMapper<PoTetherandcollection>
 {
     /**
      * 查询【请填写功能名称】
@@ -60,11 +62,9 @@ public interface PoTetherandcollectionMapper
      */
     public int deletePoTetherandcollectionByCollectionIds(Long[] collectionIds);
 
-    /**
-     *
-     * @param
-     */
-    void insertPoTetherandcollectionWithStream( List<PoTetherandcollection> list);
+
+
+
 
 }
 

+ 5 - 4
ruoyi-system/src/main/java/com/ruoyi/system/service/IPoTetherService.java

@@ -3,6 +3,7 @@ package com.ruoyi.system.service;
 import java.util.Date;
 import java.util.List;
 
+import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.system.domain.PoCollection;
 import com.ruoyi.system.domain.PoTether;
 import com.ruoyi.system.domain.PoTetherandcollection;
@@ -14,7 +15,7 @@ import com.ruoyi.system.domain.vo.TetherVo;
  * @author ruoyi
  * @date 2023-02-12
  */
-public interface IPoTetherService
+public interface IPoTetherService extends IService<PoTether>
 {
 
     /**
@@ -68,7 +69,7 @@ public interface IPoTetherService
      * @param tetherVo
      * @return
      */
-    boolean insertPoTetherWithCollection(TetherVo tetherVo);
+    void insertPoTetherWithCollection(TetherVo tetherVo);
 
     /**
      * 通过id查询套系信息和对应的藏品信息
@@ -83,7 +84,7 @@ public interface IPoTetherService
      * @return
      */
 
-    boolean updatePoTetherWithCollection(TetherVo tetherVo);
+    void updatePoTetherWithCollection(TetherVo tetherVo);
 
 
 
@@ -92,7 +93,7 @@ public interface IPoTetherService
      * @param tetherIds
      * @return
      */
-    boolean deletePoTetherByTetherIdsWithCollection(Long[] tetherIds);
+    void deletePoTetherByTetherIdsWithCollection(Long[] tetherIds) throws Exception;
 
     /**
      * 校验套系名称是否存在

+ 3 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/IPoTetherandcollectionService.java

@@ -1,6 +1,8 @@
 package com.ruoyi.system.service;
 
 import java.util.List;
+
+import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.system.domain.PoTetherandcollection;
 
 /**
@@ -9,7 +11,7 @@ import com.ruoyi.system.domain.PoTetherandcollection;
  * @author ruoyi
  * @date 2023-02-14
  */
-public interface IPoTetherandcollectionService
+public interface IPoTetherandcollectionService extends IService<PoTetherandcollection>
 {
     /**
      * 查询【请填写功能名称】

+ 71 - 23
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PoTetherServiceImpl.java

@@ -5,19 +5,26 @@ import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.common.constant.UserConstants;
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.bean.BeanUtils;
 import com.ruoyi.system.domain.PoCollection;
 import com.ruoyi.system.domain.PoNews;
 import com.ruoyi.system.domain.PoTetherandcollection;
 import com.ruoyi.system.domain.vo.TetherVo;
+import com.ruoyi.system.mapper.PoTetherandcollectionMapper;
+import org.apache.ibatis.session.SqlSession;
+import org.apache.ibatis.session.SqlSessionFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.system.mapper.PoTetherMapper;
 import com.ruoyi.system.domain.PoTether;
 import com.ruoyi.system.service.IPoTetherService;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * 套系Service业务层处理
@@ -26,10 +33,18 @@ import com.ruoyi.system.service.IPoTetherService;
  * @date 2023-02-12
  */
 @Service
-public class PoTetherServiceImpl implements IPoTetherService
+public class PoTetherServiceImpl extends ServiceImpl<PoTetherMapper,PoTether> implements IPoTetherService
 {
     @Autowired
     private PoTetherMapper poTetherMapper;
+    @Autowired
+    private PoTetherandcollectionMapper poTetherandcollectionMapper;
+
+    @Autowired
+    private PoTetherandcollectionServiceImpl poTetherandcollectionService;
+
+    @Autowired
+    private PoTetherServiceImpl poTetherService;
 
     /**
      * 在售
@@ -133,27 +148,29 @@ public class PoTetherServiceImpl implements IPoTetherService
     }
 
     /**
-     * 新增套系 同时保存对应的藏品数据
+     * 新增套系 同时保存对应的藏品数据到中间表
      *
      * @param tetherVo
      * @return
      */
     @Override
-    public boolean insertPoTetherWithCollection(TetherVo tetherVo) {
+    @Transactional
+    public void insertPoTetherWithCollection(TetherVo tetherVo) {
         //保存套系的基本数据到套系表tether
         this.poTetherMapper.insertPoTether(tetherVo);
-        Long tetherId = tetherVo.getTetherId();
         //套系包含藏品
-        List<PoTetherandcollection> poCollections = tetherVo.getPoTetherandcollections();
-        poCollections.stream().map((item)->{
-            item.setTetherId(tetherId);
-            return item;
-        }).collect(Collectors.toList());
-        //保存藏品数据到藏品表 po_collection
-        //后续添加代码
-       return true;
+        //保存藏品数据到中间表 批量增加
+
+        System.out.println(tetherVo.getPoTetherandcollections().size());
+        for (int i = 0 ; i < tetherVo.getPoTetherandcollections().size();i++) {
+            System.out.println(tetherVo.getPoTetherandcollections().get(i).getCollectionTitle());
+            PoTetherandcollection poTetherandcollection1 = new PoTetherandcollection();
+            poTetherandcollection1.setCollectionTitle(tetherVo.getPoTetherandcollections().get(i).getCollectionTitle());
+            poTetherandcollection1.setCollectionType(tetherVo.getPoTetherandcollections().get(i).getCollectionType());
+            poTetherandcollection1.setTetherId(tetherVo.getTetherId());
+            poTetherandcollectionService.insertPoTetherandcollection(poTetherandcollection1);
+        }
     }
-
     /**
      * 通过id查询套系信息和对应的藏品信息
      * @param tetherId
@@ -167,8 +184,6 @@ public class PoTetherServiceImpl implements IPoTetherService
         if (poTether != null) {
             BeanUtils.copyProperties(poTether, tetherVo);
         }
-        //查询当前套系对应的藏品信息
-        //后续添加代码
         return  tetherVo;
     }
 
@@ -178,12 +193,21 @@ public class PoTetherServiceImpl implements IPoTetherService
      * @return
      */
     @Override
-    public boolean updatePoTetherWithCollection(TetherVo tetherVo) {
+    @Transactional
+    public void updatePoTetherWithCollection(TetherVo tetherVo) {
         //更新po_tether表基本信息
         this.poTetherMapper.updatePoTether(tetherVo);
         //清理po_collection表数据
-        //添加当前提交过来的藏品数据--po_tether表的insert操作
-        return true;
+//        LambdaQueryWrapper<PoTetherandcollection> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+//        lambdaQueryWrapper.eq(PoTetherandcollection::getTetherId,tetherVo.getTetherId());
+//        poTetherandcollectionService.remove(lambdaQueryWrapper);
+//        //添加当前提交过来的藏品数据--po_Tetherandcollection表的insert操作
+//        List<PoTetherandcollection> poTetherandcollections = tetherVo.getPoTetherandcollections();
+//        List<PoTetherandcollection> collect = poTetherandcollections.stream().map((item) -> {
+//            item.setTetherId(tetherVo.getTetherId());
+//            return item;
+//        }).collect(Collectors.toList());
+//        poTetherandcollectionService.saveBatch(collect);
     }
 
 
@@ -193,12 +217,38 @@ public class PoTetherServiceImpl implements IPoTetherService
      * @return
      */
     @Override
-    public boolean deletePoTetherByTetherIdsWithCollection(Long[] tetherIds) {
-        //查询藏品状态确认是否可以删除
+    public void deletePoTetherByTetherIdsWithCollection(Long[] tetherIds) throws Exception {
+        //查询套系状态确认是否可以删除
+        LambdaQueryWrapper<PoTether> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        LambdaQueryWrapper<PoTetherandcollection> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
+
+        //判断套系是否已经被删除
+        lambdaQueryWrapper.in(PoTether::getTetherId,tetherIds);
+        lambdaQueryWrapper.eq(PoTether::getDelFlag ,1);
+        long count2 = this.count(lambdaQueryWrapper);
+        if (count2 > 0){
+            throw new Exception("套系已经被删除");
+        }
+        //判断套系是否上链
+        lambdaQueryWrapper.in(PoTether::getTetherId,tetherIds);
+        lambdaQueryWrapper.eq(PoTether::getCochain,0);
+        long count = this.count(lambdaQueryWrapper);
+        if (count>0){
+                throw new Exception("套系已经上链");
+        }
+        //判断套系是否上架
+        lambdaQueryWrapper.in(PoTether::getTetherId,tetherIds);
+        lambdaQueryWrapper.eq(PoTether::getGrounding,0);
+        long count1 = this.count(lambdaQueryWrapper);
+        if (count1>0){
+
+            throw new Exception("套系已经上架");
+        }
         //如果可以删除 先删除套系po_tether表中的数据
         this.poTetherMapper.deletePoTetherByTetherIds(tetherIds);
         //删除po_collection表中的数据
-        return true;
+        lambdaQueryWrapper1.in(PoTetherandcollection::getTetherId,tetherIds);
+        poTetherandcollectionService.remove(lambdaQueryWrapper1);
     }
     /**
      * 校验套系名称是否存在
@@ -247,8 +297,6 @@ public class PoTetherServiceImpl implements IPoTetherService
         if (poTether != null) {
             BeanUtils.copyProperties(poTether, tetherVo);
         }
-        //查询当前套系对应的藏品信息
-        //后续添加代码
         return  tetherVo;
     }
 

+ 3 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PoTetherandcollectionServiceImpl.java

@@ -1,6 +1,8 @@
 package com.ruoyi.system.service.impl;
 
 import java.util.List;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.common.utils.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -15,7 +17,7 @@ import com.ruoyi.system.service.IPoTetherandcollectionService;
  * @date 2023-02-14
  */
 @Service
-public class PoTetherandcollectionServiceImpl implements IPoTetherandcollectionService
+public class PoTetherandcollectionServiceImpl extends ServiceImpl<PoTetherandcollectionMapper,PoTetherandcollection> implements IPoTetherandcollectionService
 {
     @Autowired
     private PoTetherandcollectionMapper poTetherandcollectionMapper;

+ 24 - 14
ruoyi-system/src/main/resources/mapper/system/PoTetherMapper.xml

@@ -7,7 +7,8 @@
     <resultMap type="PoTether" id="PoTetherResult">
         <result property="tetherId"    column="tether_id"    />
         <result property="tetherName"    column="tether_name"    />
-        <result property="showTime"    column="show_time"    />
+        <result property="showTimeStart"    column="show_time_start"    />
+        <result property="showTimeEnd" column="show_time_end"/>
         <result property="createBy"    column="create_by"    />
         <result property="createTime"    column="create_time"    />
         <result property="updateBy"    column="update_by"    />
@@ -46,7 +47,7 @@
     </resultMap>
 
     <sql id="selectPoTetherVo">
-        select tether_id, tether_name, show_time, create_by, create_time, update_by, update_time, total, status, remark ,sell_status,del_flag,image,exchange ,grounding,cochain ,tether_id from po_tether
+        select tether_id, tether_name, show_time_start, show_time_end, create_by, create_time, update_by, update_time, total, status, remark ,sell_status,del_flag,image,exchange ,grounding,cochain ,tether_id from po_tether
     </sql>
 
 <!--在售-->
@@ -54,7 +55,8 @@
         <include refid="selectPoTetherVo"/>
         <where>
             <if test="tetherName != null  and tetherName != ''"> and tether_name like concat('%', #{tetherName}, '%')</if>
-            <if test="showTime != null "> and show_time = #{showTime}</if>
+            <if test="showTimeStart != null "> and show_time_start = #{showTimeStart}</if>
+            <if test="showTimeEnd != null">and show_time_end = #{showTimeEnd}</if>
             <if test="total != null "> and total = #{total}</if>
             <if test="status != null  and status != ''"> and status = #{status}</if>
             <if test="image != null and image != '' ">and image = #{image}</if>
@@ -79,7 +81,8 @@
         <include refid="selectPoTetherVo"></include>
         <where>
             <if test="tetherName != null  and tetherName != ''"> and tether_name like concat('%', #{tetherName}, '%')</if>
-            <if test="tetherTimeStart != null and tetherTimeEnd != null "> and show_time between #{tetherTimeStart} and #{tetherTimeEnd}</if>
+            <if test="tetherTimeStart != null "> and show_time_start = #{tetherTimeStart}</if>
+            <if test="tetherTimeEnd != null">and show_time_end = #{tetherTimeEnd}</if>
         </where>
     </select>
 
@@ -88,7 +91,8 @@
         <include refid="selectPoTetherVo"/>
         <where>
             <if test="tetherName != null  and tetherName != ''"> and tether_name like concat('%', #{tetherName}, '%')</if>
-            <if test="showTime != null "> and show_time = #{showTime}</if>
+            <if test="showTimeStart != null "> and show_time_start = #{showTimeStart}</if>
+            <if test="showTimeEnd != null">and show_time_end = #{showTimeEnd}</if>
             <if test="total != null "> and total = #{total}</if>
             <if test="status != null  and status != ''"> and status = #{status}</if>
             <if test="image != null and image != '' ">and image = #{image}</if>
@@ -106,7 +110,8 @@
         <include refid="selectPoTetherVo"/>
         <where>
             <if test="tetherName != null  and tetherName != ''"> and tether_name like concat('%', #{tetherName}, '%')</if>
-            <if test="showTime != null "> and show_time = #{showTime}</if>
+            <if test="showTimeStart != null "> and show_time_start = #{showTimeStart}</if>
+            <if test="showTimeEnd != null">and show_time_end = #{showTimeEnd}</if>
             <if test="total != null "> and total = #{total}</if>
             <if test="status != null  and status != ''"> and status = #{status}</if>
             <if test="image != null and image != '' ">and image = #{image}</if>
@@ -124,7 +129,8 @@
         <include refid="selectPoTetherVo"/>
         <where>
             <if test="tetherName != null  and tetherName != ''"> and tether_name like concat('%', #{tetherName}, '%')</if>
-            <if test="showTime != null "> and show_time = #{showTime}</if>
+            <if test="showTimeStart != null "> and show_time_start = #{showTimeStart}</if>
+            <if test="showTimeEnd != null">and show_time_end = #{showTimeEnd}</if>
             <if test="total != null "> and total = #{total}</if>
             <if test="status != null  and status != ''"> and status = #{status}</if>
             <if test="image != null and image != '' ">and image = #{image}</if>
@@ -168,7 +174,8 @@
     <select id="selectPoTetherCollectionList" resultType="PoTether" resultMap="PoTetherResult">
         <include refid="selectPoTetherVo"/>
         <if test="tetherName != null  and tetherName != ''"> and tether_name like concat('%', #{tetherName}, '%')</if>
-        <if test="showTime != null "> and show_time = #{showTime}</if>
+        <if test="showTimeStart != null "> and show_time_start = #{showTimeStart}</if>
+        <if test="showTimeEnd != null">and show_time_end = #{showTimeEnd}</if>
         <if test="total != null "> and total = #{total}</if>
         <if test="status != null  and status != ''"> and status = #{status}</if>
         <if test="image != null and image != '' ">and image = #{image}</if>
@@ -183,7 +190,8 @@
         insert into po_tether
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="tetherName != null">tether_name,</if>
-            <if test="showTime != null">show_time,</if>
+            <if test="showTimeStart != null">show_time_start,</if>
+            <if test="showTimeEnd != null">show_time_end,</if>
             <if test="createBy != null">create_by,</if>
             <if test="createTime != null">create_time,</if>
             <if test="updateBy != null">update_by,</if>
@@ -200,7 +208,8 @@
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="tetherName != null">#{tetherName},</if>
-            <if test="showTime != null">#{showTime},</if>
+            <if test="showTimeStart != null">#{showTimeStart},</if>
+            <if test="showTimeEnd != null">#{showTimeEnd},</if>
             <if test="createBy != null">#{createBy},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="updateBy != null">#{updateBy},</if>
@@ -220,8 +229,9 @@
     <update id="updatePoTether" parameterType="PoTether">
         update po_tether
         <trim prefix="SET" suffixOverrides=",">
-            <if test="tetherName != null">tether_name = #{tetherName},</if>
-            <if test="showTime != null">show_time = #{showTime},</if>
+            <if test="tetherName != null and tetherName != ''">tether_name = #{tetherName},</if>
+            <if test="showTimeStart != null">show_time_start = #{showTimeStart},</if>
+            <if test="showTimeEnd != null">show_time_end = #{showTimeEnd},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
@@ -230,11 +240,11 @@
             <if test="status != null">status = #{status},</if>
             <if test="remark != null">remark = #{remark},</if>
             <if test="sellStatus != null">sell_status = #{sellStatus},</if>
-            <if test="image != null and image != ''">image = #{image},</if>
+            <if test="delFlag != null">del_flag = #{delFlag},</if>
+            <if test="image != null">image = #{image},</if>
             <if test="exchange != null">exchange = #{exchange},</if>
             <if test="grounding != null">grounding = #{grounding},</if>
             <if test="cochain != null">cochain = #{cochain},</if>
-            <if test="tetherId != null">tether_id #{tetherId},</if>
         </trim>
         where tether_id = #{tetherId}
     </update>

+ 2 - 3
ruoyi-system/src/main/resources/mapper/system/PoTetherandcollectionMapper.xml

@@ -53,6 +53,8 @@
         where collection_id = #{collectionId}
     </select>
 
+
+
     <insert id="insertPoTetherandcollection" parameterType="PoTetherandcollection" useGeneratedKeys="true" keyProperty="collectionId">
         insert into po_TetherAndcollection
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -97,9 +99,6 @@
         </trim>
     </insert>
 
-    <insert id="insertPoTetherandcollectionWithStream" parameterType="java.util.List" >
-
-    </insert>
 
     <update id="updatePoTetherandcollection" parameterType="PoTetherandcollection">
         update po_TetherAndcollection