当前位置: 首页 > news >正文

深圳高水平网站制作老司机们用的关键词有哪些

深圳高水平网站制作,老司机们用的关键词有哪些,廊坊视频剪辑培训机构,哪个旅游网站做的最好1.1 自动展示所有信息 需求描述: 进入新闻首页portal/findAllType, 自动返回所有栏目名称和id 接口描述 url地址:portal/findAllTypes 请求方式:get 请求参数:无 响应数据: 成功 {"code":"200","mes…

1.1 自动展示所有信息

  1. 需求描述: 进入新闻首页portal/findAllType, 自动返回所有栏目名称和id
    在这里插入图片描述

  2. 接口描述

    url地址:portal/findAllTypes

    请求方式:get

    请求参数:无

    响应数据:

    成功

{"code":"200","message":"OK""data":{[{"tid":"1","tname":"新闻"},{"tid":"2","tname":"体育"},{"tid":"3","tname":"娱乐"},{"tid":"4","tname":"科技"},{"tid":"5","tname":"其他"}]}
}
  1. 代码编写
    PortalController :
package com.sunsplanter.controller;import com.sunsplanter.service.TypeService;
import com.sunsplanter.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
@RequestMapping("portal")
public class PortalController {@Autowiredprivate TypeService typeService;@GetMapping("findAllType")public Result findAllTypes(){Result result = typeService.findAllTypes();return result;}
}

TypeService:

package com.sunsplanter.service;import com.sunsplanter.pojo.Type;
import com.baomidou.mybatisplus.extension.service.IService;
import com.sunsplanter.utils.Result;public interface TypeService extends IService<Type>{Result findAllTypes();
}

TypeServiceImpl:

package com.sunsplanter.service.impl;import com.sunsplanter.utils.Result;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sunsplanter.mapper.TypeMapper;
import com.sunsplanter.pojo.Type;
import com.sunsplanter.service.TypeService;
@Service
public class TypeServiceImpl extends ServiceImpl<TypeMapper, Type> implements TypeService{@Autowiredprivate TypeMapper typeMapper;@Overridepublic Result findAllTypes() {//不传条件构造器,即查询全部List<Type> types = typeMapper.selectList(null);return Result.ok(types);}
}

达到的效果是,不需要任何参数, 只要访问portal/findAllType, 就返回news_type表中的所有数据(version和is_deleted除外, 因为已在实体类中注解为版本和逻辑删除)

1.2 - 查询头条详情

  1. 需求描述

在这里插入图片描述
- 用户点击"查看全文"时,向服务端发送新闻id
- 后端根据新闻id查询完整新闻文章信息并返回
- 后端要同时让新闻的浏览量+1

  1. 接口描述

url地址:portal/showHeadlineDetail

请求方式:post

请求参数: Param传参hid

响应数据:

成功则

{"code":"200","message":"success","data":{"headline":{"hid":"1",                     // 新闻id "title":"马斯克宣布 ... ...",   // 新闻标题"article":"... ..."            // 新闻正文"type":"1",                    // 新闻所属类别编号"typeName":"科技",             // 新闻所属类别"pageViews":"40",              // 新闻浏览量"pastHours":"3" ,              // 发布时间已过小时数"publisher":"1" ,              // 发布用户ID"author":"张三"                 // 新闻作者}}
}
  1. 代码实现
    1. controller
      @Overridepublic Result showHeadlineDetail(Integer hid) {/**注意响应的数据是双层嵌套,即data包裹headline,headline包含查询到的属性参数* 先用一个名为dataMap的Map以键值对的形式存储返回的属性参数* 再将名为data的Map是为一个值,搭配上名为headline的键* 存储进一个名为headlineMap的Map中,最终将Map作为参数传入Result,返回Result*/Map dataMap = headlineMapper.queryDetailMap(hid);Map headlineMap = new HashMap<>();headlineMap.put("headline",dataMap);/*乐观锁修改阅读量+1*上面已经通过hid查到了所有信息,包括当时的版本号,假设是2* 将2直接赋值到新建的headline的Version中* 在最后一句update中,MP会帮我们检查,如果此时该条记录的版本号仍为2,* 则说明这段时间没有人修改过这条记录,可以正常修改*/Headline headline = new Headline();headline.setHid(hid);headline.setPageViews((Integer) headlineMap.get("pageViews")+1); //阅读量+1headline.setVersion((Integer) headlineMap.get("version")); //设置版本headlineMapper.updateById(headline);return Result.ok(headlineMap);}
  1. HeadlineMapper.java接口
/*** 分页查询头条详情* @param hid* @return*/
Map selectDetailMap(Integer hid);
      mapperxml:
<!--    Map selectDetailMap(Integer hid);
查询目标(三表拼接):"hid":"1",                     // 新闻id "title":"马斯克宣布 ... ...",   // 新闻标题"article":"... ..."            // 新闻正文"type":"1",                    // 新闻所属类别编号"typeName":"科技",             // 新闻所属类别"pageViews":"40",              // 新闻浏览量"pastHours":"3" ,              // 发布时间已过小时数"publisher":"1" ,              // 发布用户ID"author":"张三"                 // 新闻作者-->/*
left join news_type t on h.type = t.tid: 这是一个左连接,将 "news_headline" 表与 "news_type" 表连接。
它的条件是 "news_headline" 表的 "type" 字段与 "news_type" 表的 "tid" 字段相匹配。
news_type中tid匹配的行会右拼接在headline表中left join news_user u on h.publisher = u.uid: 这也是一个左连接,将 "news_headline" 表与 "news_user" 表连接。
连接条件是 "news_headline" 表的 "publisher" 字段与 "news_user" 表的 "uid" 字段相匹配。
news_user中tid匹配的行会右拼接在headline表中(headline先拼type,再拼user)左连接确保左表保留所有信息,右表仅提取符合条件的元素匹配左表
*/
<select id="selectDetailMap" resultType="map">select hid,title,article,type, h.version ,tname typeName ,page_views pageViews,TIMESTAMPDIFF(HOUR,create_time,NOW()) pastHours,publisher,nick_name author from news_headline hleft join news_type t on h.type = t.tidleft join news_user u  on h.publisher = u.uidwhere hid = #{hid}
</select>
http://www.hkea.cn/news/11043/

相关文章:

  • ps切片怎么做网站百度竞价排名广告定价
  • 网站目录字典独立站搭建要多少钱
  • 做网站应该学什么专业百度推广运营
  • 网站搭建哪家比较好互联网营销师培训班
  • 濮阳市城乡一体化示范区范围搜索引擎优化排名优化培训
  • 用模板做企业网站汽车推广软文
  • 不同网站的主机和域名互联网营销是做什么的
  • 兰溪市住房和城乡建设局网站软文怎么写比较吸引人
  • 广告传媒公司网站吉林网站seo
  • 网站设计公司西安网站建设推广专家
  • 建筑公司办理资质需要什么条件东莞搜索优化十年乐云seo
  • 淘宝网站设计价格成人电脑基础培训班
  • 福建网站开发定制促销策略的四种方式
  • 做网站公司怎么样英文seo外链发布工具
  • 微网站模板开发优化网站排名公司
  • 南宁网站建设技术支持百度搜索广告价格
  • 怎样建外贸网站电销精准客户资源
  • 可信网站标识如何建立网上销售平台
  • 怎么制作网站logo网站怎么做
  • 博物馆网站 微信 微博 建设企业官网建站
  • 网站建设费算什么费用温岭网络推广
  • 施工企业质量管理体系认证有效期衡水seo营销
  • 浙江网站建设平台百度精简版网页入口
  • 郑州专业做网站的百度免费推广平台
  • wordpress作者页面广东百度seo关键词排名
  • 手机资讯网站源码站长之家查询域名
  • 江苏省昆山市网站制作网络公司有哪些
  • php在网站开发中的作用搜索引擎平台有哪些软件
  • wap手机网站建设制作开发百度关键字推广费用
  • 河南企起网站建设成都私人做网站建设