Browse Source

标签检索

zhoutg 6 years ago
parent
commit
7f126f14ef

+ 1 - 0
icssman-service/src/main/java/com/diagbot/config/ResourceServerConfigurer.java

@@ -29,6 +29,7 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
                 .antMatchers("/file/upload").permitAll()
                 .antMatchers("/introduceInfo/saveIntroduce").permitAll()
                 .antMatchers("/questionInfo/delete").permitAll()
+                .antMatchers("/questionInfo/index").permitAll()
                 .antMatchers("/**").authenticated();
         //        .antMatchers("/**").permitAll();
     }

+ 1 - 0
icssman-service/src/main/java/com/diagbot/config/security/UrlAccessDecisionManager.java

@@ -92,6 +92,7 @@ public class UrlAccessDecisionManager implements AccessDecisionManager {
                 || matchers("/file/upload", request)
                 || matchers("introduceInfo/saveIntroduce", request)
                 || matchers("/questionInfo/delete", request)
+                || matchers("/questionInfo/index", request)
                 || matchers("/", request)) {
             return true;
         }

+ 18 - 0
icssman-service/src/main/java/com/diagbot/dto/QuestionIndexDTO.java

@@ -0,0 +1,18 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2018/11/29 15:09
+ */
+@Getter
+@Setter
+public class QuestionIndexDTO {
+    private String tagName;
+    private Integer sexType;
+    private Integer age;
+    private Integer type;
+}

+ 20 - 0
icssman-service/src/main/java/com/diagbot/facade/QuestionInfoFacade.java

@@ -1,5 +1,7 @@
 package com.diagbot.facade;
 
+import com.diagbot.dto.QuestionIndexDTO;
+import com.diagbot.entity.QuestionInfo;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.service.impl.QuestionInfoServiceImpl;
 import com.diagbot.util.DateUtil;
@@ -9,6 +11,7 @@ import org.springframework.stereotype.Component;
 
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -58,4 +61,21 @@ public class QuestionInfoFacade extends QuestionInfoServiceImpl {
         moduleDetailFacade.deleteByQuestionIdFac(paramMap);
         return true;
     }
+
+
+    /**
+     * 检索
+     *
+     * @param questionIndexDTO
+     * @return
+     */
+    public List<QuestionInfo> indexFac(QuestionIndexDTO questionIndexDTO) {
+        Map<String, Object> paramMap = new HashMap<>();
+        paramMap.put("isDeleted", IsDeleteEnum.N.getKey());
+        paramMap.put("age", questionIndexDTO.getAge());
+        paramMap.put("sexType", questionIndexDTO.getSexType());
+        paramMap.put("tagName", questionIndexDTO.getTagName());
+        paramMap.put("type", questionIndexDTO.getType());
+        return this.index(paramMap);
+    }
 }

+ 4 - 1
icssman-service/src/main/java/com/diagbot/mapper/QuestionInfoMapper.java

@@ -1,8 +1,9 @@
 package com.diagbot.mapper;
 
-import com.diagbot.entity.QuestionInfo;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.diagbot.entity.QuestionInfo;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -16,4 +17,6 @@ import java.util.Map;
 public interface QuestionInfoMapper extends BaseMapper<QuestionInfo> {
 
     public void deleteByIds(Map map);
+
+    public List<QuestionInfo> index(Map map);
 }

+ 12 - 1
icssman-service/src/main/java/com/diagbot/service/QuestionInfoService.java

@@ -1,8 +1,9 @@
 package com.diagbot.service;
 
-import com.diagbot.entity.QuestionInfo;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.diagbot.entity.QuestionInfo;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -22,4 +23,14 @@ public interface QuestionInfoService extends IService<QuestionInfo> {
      * @return
      */
     public void deleteByIds(Map map);
+
+
+    /**
+     * 检索
+     *
+     * @param map
+     * @return
+     */
+    public List<QuestionInfo> index(Map map);
+
 }

+ 6 - 0
icssman-service/src/main/java/com/diagbot/service/impl/QuestionInfoServiceImpl.java

@@ -6,6 +6,7 @@ import com.diagbot.service.QuestionInfoService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -23,4 +24,9 @@ public class QuestionInfoServiceImpl extends ServiceImpl<QuestionInfoMapper, Que
     public void deleteByIds(Map map) {
         baseMapper.deleteByIds(map);
     }
+
+    @Override
+    public List<QuestionInfo> index(Map map) {
+        return baseMapper.index(map);
+    }
 }

+ 8 - 3
icssman-service/src/main/java/com/diagbot/web/QuestionInfoController.java

@@ -2,16 +2,21 @@ package com.diagbot.web;
 
 
 import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.QuestionIndexDTO;
 import com.diagbot.dto.RespDTO;
+import com.diagbot.entity.QuestionInfo;
 import com.diagbot.facade.QuestionInfoFacade;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+
 /**
  * <p>
  * 标签基础表 前端控制器
@@ -43,9 +48,9 @@ public class QuestionInfoController {
             notes = "")
     @PostMapping("/index")
     @SysLogger("index")
-    public RespDTO<Boolean> index() {
-
-        return RespDTO.onSuc(true);
+    public RespDTO<List<QuestionInfo>> index(@RequestBody QuestionIndexDTO questionIndexDTO) {
+        List<QuestionInfo> data = questionInfoFacade.indexFac(questionIndexDTO);
+        return RespDTO.onSuc(data);
     }
 
 

+ 38 - 0
icssman-service/src/main/resources/mapper/QuestionInfoMapper.xml

@@ -41,4 +41,42 @@
             #{id}
         </foreach>
     </delete>
+
+    <select id="index" parameterType="java.util.Map" resultType="com.diagbot.entity.QuestionInfo">
+        select * from `icss_question_info`
+        where is_deleted = 'N'
+        <if test="tagName != null and tagName != ''">
+            and tag_name = #{tagName}
+        </if>
+        <if test="sexType != null and sexType != ''">
+            and sex_type in (3, #{sexType})
+        </if>
+        <if test="age != null and age != ''">
+            <![CDATA[ and age_begin <= #{age} ]]>
+            <![CDATA[ and age_end >= #{age} ]]>
+        </if>
+        <if test="type != null and type != ''">
+            and type = #{type}
+        </if>
+
+        union
+
+        select * from `icss_question_info`
+        where is_deleted = 'N'
+        <if test="tagName != null and tagName != ''">
+            and tag_name like concat("%", #{tagName}, "%")
+        </if>
+        <if test="sexType != null and sexType != ''">
+            and sex_type in (3, #{sexType})
+        </if>
+        <if test="age != null and age != ''">
+            <![CDATA[ and age_begin <= #{age} ]]>
+            <![CDATA[ and age_end >= #{age} ]]>
+        </if>
+        <if test="type != null and type != ''">
+            and type = #{type}
+        </if>
+
+
+    </select>
 </mapper>