Selaa lähdekoodia

uniapp资讯接口

qinhouyu 1 vuosi sitten
vanhempi
commit
fdc16d088e

+ 10 - 11
ruoyi-admin/src/main/java/com/ruoyi/web/controller/information/InformationController.java

@@ -38,7 +38,7 @@ public class InformationController extends BaseController
     /**
      * 查询资讯列表
      */
-    @PreAuthorize("@ss.hasPermi('jnb:information:list')")
+//    @PreAuthorize("@ss.hasPermi('jnb:information:list')")
     @GetMapping("/list")
     public TableDataInfo list(Information information)
     {
@@ -51,19 +51,18 @@ public class InformationController extends BaseController
     /**
      * 查询前三条-小程序
      */
-    @PreAuthorize("@ss.hasPermi('jnb:information:query')")
+//    @PreAuthorize("@ss.hasPermi('jnb:information:query')")
     @GetMapping("/listWx")
-    public TableDataInfo listWx(Information information)
+    public AjaxResult listWx(Information information)
     {
-        startPage();
         List<Information> list = informationService.selectInformationListWx(information);
-        return getDataTable(list);
+        return AjaxResult.success(list);
     }
 
     /**
      * 查询文章列表包括置顶-小程序
      */
-    @PreAuthorize("@ss.hasPermi('jnb:information:query')")
+//    @PreAuthorize("@ss.hasPermi('jnb:information:query')")
     @GetMapping("/listWxs")
     public TableDataInfo listWxs(Information information)
     {
@@ -76,7 +75,7 @@ public class InformationController extends BaseController
     /**
      * 导出资讯列表
      */
-    @PreAuthorize("@ss.hasPermi('jnb:information:export')")
+//    @PreAuthorize("@ss.hasPermi('jnb:information:export')")
     @Log(title = "资讯导出", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
     public void export(HttpServletResponse response, Information information)
@@ -89,7 +88,7 @@ public class InformationController extends BaseController
     /**
      * 获取资讯详细信息
      */
-    @PreAuthorize("@ss.hasPermi('jnb:information:query')")
+//    @PreAuthorize("@ss.hasPermi('jnb:information:query')")
     @GetMapping(value = "/{id}/{type}")
     public AjaxResult getInfo(@PathVariable("id") Long id,@PathVariable("type") Integer type)
     {
@@ -99,7 +98,7 @@ public class InformationController extends BaseController
     /**
      * 新增资讯
      */
-    @PreAuthorize("@ss.hasPermi('jnb:information:add')")
+//    @PreAuthorize("@ss.hasPermi('jnb:information:add')")
     @Log(title = "新增资讯", businessType = BusinessType.INSERT)
     @PostMapping
     public AjaxResult add(@RequestBody Information information)
@@ -110,7 +109,7 @@ public class InformationController extends BaseController
     /**
      * 修改资讯
      */
-    @PreAuthorize("@ss.hasPermi('jnb:information:edit')")
+//    @PreAuthorize("@ss.hasPermi('jnb:information:edit')")
     @Log(title = "修改资讯", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@RequestBody Information information)
@@ -121,7 +120,7 @@ public class InformationController extends BaseController
     /**
      * 删除资讯
      */
-    @PreAuthorize("@ss.hasPermi('jnb:information:remove')")
+//    @PreAuthorize("@ss.hasPermi('jnb:information:remove')")
     @Log(title = "删除资讯", businessType = BusinessType.DELETE)
 	@DeleteMapping("/{ids}/{type}")
     public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("type") Integer type)

+ 7 - 0
sooka-jnb/src/main/java/com/sooka/jnb/information/domain/Information.java

@@ -8,6 +8,7 @@ import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
 
 import javax.validation.constraints.NotBlank;
+import java.util.List;
 
 /**
  * 资讯
@@ -52,5 +53,11 @@ public class Information extends BaseEntity
     private Integer type;
 
     @TableField(exist = false)
+    private String flag;
+
+    @TableField(exist = false)
+    private List<String> urls;
+
+    @TableField(exist = false)
     private String imgUrlList;
 }

+ 1 - 1
sooka-jnb/src/main/java/com/sooka/jnb/information/service/impl/InformationServiceImpl.java

@@ -54,7 +54,7 @@ public class InformationServiceImpl implements InformationService
     @Override
     public List<Information> selectInformationListWxs(Information information)
     {
-        return informationMapper.selectInformationListWx(information);
+        return informationMapper.selectInformationListWxs(information);
     }
 
 

+ 50 - 12
sooka-jnb/src/main/resources/mapper/information/InformationMapper.xml

@@ -16,10 +16,12 @@
         <result property="createBy" column="create_by"/>
         <result property="createTime" column="create_time"/>
         <result property="updateBy" column="update_by"/>
+        <result property="imgUrlList" column="imgUrlList"/>
         <result property="updateTime" column="update_time"/>
         <result property="delFlag" column="del_flag"/>
     </resultMap>
 
+
     <sql id="selectInformationVo">
         select id,
                title_name,
@@ -62,24 +64,60 @@
         order by create_time desc
     </select>
 
-    <select id="selectInformationListWxs" parameterType="Information" resultMap="InformationResult">
-        <include refid="selectInformationVo"/>
+
+    <resultMap type="Information" id="InformationResult1">
+        <id property="id" column="id"/>
+        <result property="titleName" column="title_name"/>
+        <result property="textDetails" column="text_details"/>
+        <result property="type" column="type"/>
+        <result property="isGovernment" column="is_government"/>
+        <result property="likeNum" column="like_num"/>
+        <result property="watchNum" column="watch_num"/>
+        <result property="isTop" column="is_top"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="delFlag" column="del_flag"/>
+        <collection property="urls" ofType="java.lang.String">
+            <result column="url" property="url"/>
+        </collection>
+    </resultMap>
+
+    <select id="selectInformationListWxs" parameterType="Information" resultMap="InformationResult1">
+        SELECT
+        a.id,
+        a.title_name,
+        a.text_details,
+        a.type,
+        a.create_by,
+        a.create_time,
+        a.update_by,
+        a.update_time,
+        a.del_flag,
+        a.is_government,
+        a.is_top,
+        a.like_num,
+        a.watch_num,
+        i.img_url AS url
+        FROM jnb_high_server AS a
+        LEFT JOIN jnb_high_server_img AS i ON a.id = i.server_id AND i.del_flag = 0 AND i.type = #{type}
         <where>
-            <if test="titleName != null  and titleName != ''">and title_name like concat('%', #{titleName}, '%')</if>
-            <if test="type != null and type != ''">and type = #{type}</if>
-            <if test="isGovernment != null and isGovernment != ''">and is_government = #{isGovernment}</if>
-            <if test="isTop != null and isTop != ''">and is_top = #{isTop}</if>
-            and del_flag = 0
+            <if test="titleName != null and titleName != ''">AND a.title_name LIKE CONCAT('%', #{titleName}, '%')</if>
+            <if test="type != null and type != ''">AND a.type = #{type}</if>
+            <if test="isGovernment != null and isGovernment != ''">AND a.is_government = #{isGovernment}</if>
+            <if test="isTop != null and isTop != ''">AND a.is_top = #{isTop}</if>
+            AND a.del_flag = 0
         </where>
         <choose>
-            <when test="flag == like">
-                ORDER BY like_num DESC
+            <when test="flag == 'like'">
+                ORDER BY a.like_num DESC
             </when>
-            <when test="flag == watch">
-                ORDER BY watch_num DESC
+            <when test="flag == 'watch'">
+                ORDER BY a.watch_num DESC
             </when>
             <otherwise>
-                ORDER BY create_time DESC
+                ORDER BY a.create_time DESC
             </otherwise>
         </choose>
     </select>