Ver código fonte

数据源分类完成

soft5566 2 anos atrás
pai
commit
e73f26a5f4

+ 46 - 34
.idea/workspace.xml

@@ -1,12 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
+  <component name="AutoImportSettings">
+    <option name="autoReloadType" value="SELECTIVE" />
+  </component>
   <component name="ChangeListManager">
     <list default="true" id="33456f28-da03-4d10-99dd-fd9bd193cf84" name="Default Changelist" comment="">
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/api/SmartDataSourceControllerAPI.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/api/SmartDataSourceControllerAPI.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/api/SmartDataClassControllerAPI.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/api/SmartDataClassControllerAPI.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/controller/SmartDataClassController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/controller/SmartDataClassController.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/services/impl/SmartDataClassServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/services/impl/SmartDataClassServiceImpl.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/target/classes/META-INF/spring-configuration-metadata.json" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/META-INF/spring-configuration-metadata.json" afterDir="false" />
     </list>
-    <ignored path="$PROJECT_DIR$/out/" />
-    <ignored path="$PROJECT_DIR$/target/" />
-    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
     <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -242,11 +246,14 @@
       </list>
     </option>
   </component>
+  <component name="MarkdownSettingsMigration">
+    <option name="stateVersion" value="1" />
+  </component>
   <component name="MavenImportPreferences">
     <option name="generalSettings">
       <MavenGeneralSettings>
         <option name="localRepository" value="D:\Software\Develop\Maven\repository" />
-        <option name="mavenHome" value="D:/Software/Develop/Maven/apache-maven-3.3.9" />
+        <option name="mavenHome" value="$PROJECT_DIR$/../../Software/Develop/Maven/apache-maven-3.3.9" />
         <option name="userSettingsFile" value="D:\Software\Develop\Maven\apache-maven-3.3.9\conf\settings.xml" />
       </MavenGeneralSettings>
     </option>
@@ -275,6 +282,7 @@
     <option name="width" value="974" />
     <option name="height" value="1039" />
   </component>
+  <component name="ProjectId" id="2Z7Eoe1hxxaBtcJvvIIqt71aKX4" />
   <component name="ProjectView">
     <navigator proportions="" version="1">
       <foldersAlwaysOnTop value="true" />
@@ -435,19 +443,29 @@
       <pane id="PackagesPane" />
     </panes>
   </component>
-  <component name="PropertiesComponent">
-    <property name="ExpandSpringBootJavaOptionsPanel" value="true" />
-    <property name="RequestMappingsPanelOrder0" value="0" />
-    <property name="RequestMappingsPanelOrder1" value="1" />
-    <property name="RequestMappingsPanelWidth0" value="75" />
-    <property name="RequestMappingsPanelWidth1" value="75" />
-    <property name="WebServerToolWindowFactoryState" value="false" />
-    <property name="aspect.path.notification.shown" value="true" />
-    <property name="last_opened_file_path" value="$PROJECT_DIR$/../../报修系统/repair_backend" />
-    <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
-    <property name="nodejs_npm_path_reset_for_default_project" value="true" />
-    <property name="settings.editor.selected.configurable" value="File.Encoding" />
+  <component name="ProjectViewState">
+    <option name="autoscrollFromSource" value="true" />
+    <option name="hideEmptyMiddlePackages" value="true" />
+    <option name="showLibraryContents" value="true" />
   </component>
+  <component name="PropertiesComponent">{
+  &quot;keyToString&quot;: {
+    &quot;RequestMappingsPanelOrder0&quot;: &quot;0&quot;,
+    &quot;RequestMappingsPanelOrder1&quot;: &quot;1&quot;,
+    &quot;RequestMappingsPanelWidth0&quot;: &quot;75&quot;,
+    &quot;RequestMappingsPanelWidth1&quot;: &quot;75&quot;,
+    &quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
+    &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
+    &quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
+    &quot;git-widget-placeholder&quot;: &quot;master&quot;,
+    &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
+    &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
+    &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
+    &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
+    &quot;spring.configuration.checksum&quot;: &quot;64bf9ba214eb006c40cb35e0f61a7d20&quot;,
+    &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
+  }
+}</component>
   <component name="RebelAgentSelection">
     <selection>jr</selection>
   </component>
@@ -467,18 +485,6 @@
       <recent name="D:\Bingo\Desktop\工作内容\报修系统\Back-endDevelopmentFramework\src\main\resources\mapper\video" />
     </key>
   </component>
-  <component name="RunDashboard">
-    <option name="ruleStates">
-      <list>
-        <RuleState>
-          <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
-        </RuleState>
-        <RuleState>
-          <option name="name" value="StatusDashboardGroupingRule" />
-        </RuleState>
-      </list>
-    </option>
-  </component>
   <component name="RunManager" selected="Spring Boot.MybatisPlusApplication">
     <configuration name="AutoCode" type="Application" factoryName="Application" nameIsGenerated="true">
       <option name="MAIN_CLASS_NAME" value="com.template.AutoCode" />
@@ -496,16 +502,16 @@
     <configuration name="MybatisPlusApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
       <module name="mybatis_plus" />
       <option name="SPRING_BOOT_MAIN_CLASS" value="com.template.MybatisPlusApplication" />
-      <option name="ALTERNATIVE_JRE_PATH" />
       <method v="2">
         <option name="Make" enabled="true" />
       </method>
     </configuration>
     <list>
-      <item itemvalue="Application.AutoCode" />
       <item itemvalue="Spring Boot.MybatisPlusApplication" />
+      <item itemvalue="应用程序.AutoCode" />
     </list>
   </component>
+  <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="应用程序级" UseSingleDictionary="true" transferred="true" />
   <component name="SvnConfiguration">
     <configuration />
   </component>
@@ -528,6 +534,9 @@
       <workItem from="1688623572162" duration="6039000" />
       <workItem from="1701393315043" duration="136000" />
       <workItem from="1701669886732" duration="27098000" />
+      <workItem from="1701764903042" duration="5734000" />
+      <workItem from="1701865008670" duration="65000" />
+      <workItem from="1701869528061" duration="202000" />
     </task>
     <servers />
   </component>
@@ -626,7 +635,7 @@
     </layout-to-restore>
   </component>
   <component name="TypeScriptGeneratedFilesManager">
-    <option name="version" value="1" />
+    <option name="version" value="3" />
   </component>
   <component name="XDebuggerManager">
     <breakpoint-manager>
@@ -634,17 +643,20 @@
         <line-breakpoint enabled="true" type="java-line">
           <url>file://$PROJECT_DIR$/src/main/java/com/template/common/exception/MyCustomException.java</url>
           <line>14</line>
-          <properties />
           <option name="timeStamp" value="20" />
         </line-breakpoint>
         <line-breakpoint enabled="true" type="java-line">
           <url>file://$PROJECT_DIR$/src/main/java/com/template/common/exception/EmsException.java</url>
           <line>10</line>
-          <properties />
           <option name="timeStamp" value="21" />
         </line-breakpoint>
       </breakpoints>
     </breakpoint-manager>
+    <watches-manager>
+      <configuration name="SpringBootApplicationConfigurationType">
+        <watch expression="smartApply.dsClsId" />
+      </configuration>
+    </watches-manager>
   </component>
   <component name="antWorkspaceConfiguration">
     <option name="IS_AUTOSCROLL_TO_SOURCE" value="false" />

+ 2 - 2
src/main/java/com/template/api/SmartDataClassControllerAPI.java

@@ -19,11 +19,11 @@ import org.springframework.web.bind.annotation.*;
 public interface SmartDataClassControllerAPI {
     @PostMapping(value = "/insertSmartDataClass")
     @ApiOperation(value = "添加数据源类别", notes = "添加数据源类别数据", httpMethod = "POST")
-    CommonResult insertSmartDataClass(@Validated @RequestBody SmartDataClass smartApply, BindingResult bindingResult);
+    CommonResult insertSmartDataClass(@Validated @RequestBody SmartDataClass smartDataClass, BindingResult bindingResult);
 
     @PostMapping(value = "/updateSmartDataClassById")
     @ApiOperation(value = "编辑数据源类别数据", notes = "编辑数据源类别数据", httpMethod = "POST")
-    CommonResult updateSmartDataClassById(@Validated @RequestBody SmartDataClass ra, BindingResult bindingResult);
+    CommonResult updateSmartDataClassById(@Validated @RequestBody SmartDataClass smartDataClass, BindingResult bindingResult);
 
     @GetMapping(value = "/queryPageSmartDataClass")
     @ApiOperation(value = "数据源类别分页数据", notes = "数据源类别分页数据", httpMethod = "GET")

+ 38 - 9
src/main/java/com/template/controller/SmartDataClassController.java

@@ -1,12 +1,15 @@
 package com.template.controller;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.template.api.SmartDataClassControllerAPI;
 import com.template.common.utils.paramUtils;
 import com.template.model.pojo.SmartDataClass;
+import com.template.model.pojo.SmartDataSource;
 import com.template.model.result.CommonResult;
 import com.template.model.result.PageUtils;
 import com.template.services.SmartDataClassService;
+import com.template.services.SmartDataSourceService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -26,43 +29,61 @@ public class SmartDataClassController implements SmartDataClassControllerAPI {
     @Autowired
     private SmartDataClassService smartDataClassService;
 
+    @Autowired
+    private SmartDataSourceService smartDataSourceService;
     /**
-     * 新增楼栋
-     * @param smartApply 楼栋数据
+     * 新增 数据源分类
+     * @param smartDataClass
      * @param bindingResult
      * @return
      */
     @Override
-    public CommonResult insertSmartDataClass(SmartDataClass smartApply, BindingResult bindingResult) {
+    public CommonResult insertSmartDataClass(SmartDataClass smartDataClass, BindingResult bindingResult) {
         if (bindingResult.hasErrors()) {
             String st = paramUtils.getParamError(bindingResult);
             return CommonResult.fail(st);
         }
 
-        int result = smartDataClassService.insertSmartDataClass(smartApply);
+        // 检测是否有重复名称
+        QueryWrapper<SmartDataClass> smartDataClassQueryWrapper = new QueryWrapper<>();
+        smartDataClassQueryWrapper.eq("ds_cls_name", smartDataClass.getDsClsName());
+        int count = smartDataClassService.count(smartDataClassQueryWrapper);
+        if(count > 0){
+            return CommonResult.fail("数据源分类名称有重名,新增失败!");
+        }
+
+        int result = smartDataClassService.insertSmartDataClass(smartDataClass);
 
         return result > 0 ? CommonResult.ok("添加成功") : CommonResult.fail("添加失败");
     }
 
     /**
-     * 更新楼栋
-     * @param sa 楼栋数据
+     * 更新 数据源分类
+     * @param smartDataClass
      * @param bindingResult
      * @return
      */
     @Override
-    public CommonResult updateSmartDataClassById(SmartDataClass sa, BindingResult bindingResult) {
+    public CommonResult updateSmartDataClassById(SmartDataClass smartDataClass, BindingResult bindingResult) {
         if (bindingResult.hasErrors()) {
             String st = paramUtils.getParamError(bindingResult);
             return CommonResult.fail(st);
         }
 
-        int result = smartDataClassService.updateSmartDataClass(sa);
+        // 检测是否有重复名称
+        QueryWrapper<SmartDataClass> smartDataClassQueryWrapper = new QueryWrapper<>();
+        smartDataClassQueryWrapper.eq("ds_cls_name", smartDataClass.getDsClsName());
+        int count = smartDataClassService.count(smartDataClassQueryWrapper);
+        if(count > 0){
+            return CommonResult.fail("数据源分类名称有重名,更新失败!");
+        }
+
+        int result = smartDataClassService.updateSmartDataClass(smartDataClass);
         return result > 0 ? CommonResult.ok("修改成功") : CommonResult.fail("修改失败");
     }
 
     /**
-     * 楼栋分页数据查询
+     * 数据源分类 分页数据查询
      * @param currentPage 当前页数
      * @param pageCount 一页数据条数
      * @param name 查询名称
@@ -85,6 +106,14 @@ public class SmartDataClassController implements SmartDataClassControllerAPI {
             return CommonResult.fail("当前数据不存在,删除失败!");
         }
 
+        // 检测当前类别下是否有数据源,有则不能删除,否则可以删除
+        QueryWrapper<SmartDataSource> smartDataSourceQueryWrapper = new QueryWrapper<>();
+        smartDataSourceQueryWrapper.eq("ds_cls_id", id);
+        int count = smartDataSourceService.count(smartDataSourceQueryWrapper);
+        if(count > 0){
+            return CommonResult.fail("当前类别下有数据,不能删除,删除失败!");
+        }
+
         int result = smartDataClassService.deleteSmartDataClassById(id);
 
         return result > 0 ? CommonResult.ok("删除成功") : CommonResult.fail("删除失败");

+ 8 - 5
src/main/java/com/template/services/impl/SmartDataClassServiceImpl.java

@@ -12,6 +12,9 @@ import com.template.services.SmartDataClassService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import java.sql.SQLIntegrityConstraintViolationException;
 
 /**
  * <p>
@@ -27,14 +30,14 @@ public class SmartDataClassServiceImpl extends ServiceImpl<SmartDataClassMapper,
     private SmartDataClassMapper smartDataClassMapper;
 
     @Override
-    public int insertSmartDataClass(SmartDataClass sa) {
-        int result = smartDataClassMapper.insert(sa);
+    public int insertSmartDataClass(SmartDataClass smartDataClass) {
+        int result = smartDataClassMapper.insert(smartDataClass);
         return result;
     }
 
     @Override
-    public int updateSmartDataClass(SmartDataClass sa) {
-        int result = smartDataClassMapper.updateById(sa);
+    public int updateSmartDataClass(SmartDataClass smartDataClass) {
+        int result = smartDataClassMapper.updateById(smartDataClass);
         return result;
     }
 
@@ -42,7 +45,7 @@ public class SmartDataClassServiceImpl extends ServiceImpl<SmartDataClassMapper,
     public PageUtils<SmartDataClass> queryPageSmartDataClasss(int currentPage, int pageCount, String name) {
         Page<SmartDataClass> page = new Page<>(currentPage, pageCount);
         QueryWrapper<SmartDataClass> queryWrapper = new QueryWrapper<>();
-        //queryWrapper.like(StringUtils.hasText(name), "name", name);
+        queryWrapper.like(StringUtils.hasText(name), "ds_cls_name", name);
         IPage<SmartDataClass> result = smartDataClassMapper.selectPage(page,queryWrapper);
         return new PageUtils<>(result);
     }