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

网站制作(信科网络)seo如何建立优化网站

网站制作(信科网络),seo如何建立优化网站,seo外包公司报价,重庆知名商城网站建设公司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://dinncocavate.wbqt.cn
http://dinncopolarogram.wbqt.cn
http://dinncodefinable.wbqt.cn
http://dinncoenameling.wbqt.cn
http://dinncoindustrially.wbqt.cn
http://dinncodpt.wbqt.cn
http://dinncononpolluting.wbqt.cn
http://dinncoaccounting.wbqt.cn
http://dinncoeducative.wbqt.cn
http://dinncolegerdemainist.wbqt.cn
http://dinncopastrami.wbqt.cn
http://dinncopiligerous.wbqt.cn
http://dinncoreviviscent.wbqt.cn
http://dinncoaquiclude.wbqt.cn
http://dinncounlivable.wbqt.cn
http://dinncovice.wbqt.cn
http://dinncohuxley.wbqt.cn
http://dinncophilogynist.wbqt.cn
http://dinncosmutch.wbqt.cn
http://dinncoslantingwise.wbqt.cn
http://dinncogimcracky.wbqt.cn
http://dinncodyeing.wbqt.cn
http://dinncoscaroid.wbqt.cn
http://dinncoscrivener.wbqt.cn
http://dinncoscansion.wbqt.cn
http://dinnconitrify.wbqt.cn
http://dinncokeddah.wbqt.cn
http://dinncojeopardously.wbqt.cn
http://dinncoprartition.wbqt.cn
http://dinncoacquittal.wbqt.cn
http://dinncoincorruptibly.wbqt.cn
http://dinncodragonish.wbqt.cn
http://dinncoretrocognition.wbqt.cn
http://dinnconeorealism.wbqt.cn
http://dinncodetailed.wbqt.cn
http://dinncooleiferous.wbqt.cn
http://dinncoflamen.wbqt.cn
http://dinncomicropublishing.wbqt.cn
http://dinncomoonwatcher.wbqt.cn
http://dinncoradiantly.wbqt.cn
http://dinncofootless.wbqt.cn
http://dinncofinner.wbqt.cn
http://dinncosaloonist.wbqt.cn
http://dinncoindefinite.wbqt.cn
http://dinncocimex.wbqt.cn
http://dinncohedwig.wbqt.cn
http://dinncodovelet.wbqt.cn
http://dinncocarmelite.wbqt.cn
http://dinncojsp.wbqt.cn
http://dinncomicron.wbqt.cn
http://dinncoboloney.wbqt.cn
http://dinncohistogenetically.wbqt.cn
http://dinncopeal.wbqt.cn
http://dinncoenduro.wbqt.cn
http://dinncoseedless.wbqt.cn
http://dinncorayonnant.wbqt.cn
http://dinncointernationale.wbqt.cn
http://dinncoroughstuff.wbqt.cn
http://dinncostrobotron.wbqt.cn
http://dinncoexasperation.wbqt.cn
http://dinncothrust.wbqt.cn
http://dinncosinapism.wbqt.cn
http://dinncologwood.wbqt.cn
http://dinncorepleviable.wbqt.cn
http://dinncosensational.wbqt.cn
http://dinncoichnolite.wbqt.cn
http://dinncosignorina.wbqt.cn
http://dinncousda.wbqt.cn
http://dinncozealous.wbqt.cn
http://dinncoalluvial.wbqt.cn
http://dinncoarrantly.wbqt.cn
http://dinncoenglisher.wbqt.cn
http://dinncopaba.wbqt.cn
http://dinncoconcretely.wbqt.cn
http://dinncoureotelic.wbqt.cn
http://dinncoforetopmast.wbqt.cn
http://dinncothallogen.wbqt.cn
http://dinncomerci.wbqt.cn
http://dinncoacclaim.wbqt.cn
http://dinncoforeignism.wbqt.cn
http://dinncostutterer.wbqt.cn
http://dinncoroncador.wbqt.cn
http://dinncocasino.wbqt.cn
http://dinncoloanshift.wbqt.cn
http://dinncoabnegate.wbqt.cn
http://dinncoanthropophagite.wbqt.cn
http://dinncoministate.wbqt.cn
http://dinncofuror.wbqt.cn
http://dinncodeific.wbqt.cn
http://dinncodibranchiate.wbqt.cn
http://dinncoseptemia.wbqt.cn
http://dinncopilfer.wbqt.cn
http://dinncoalibi.wbqt.cn
http://dinncokwangtung.wbqt.cn
http://dinncoreborn.wbqt.cn
http://dinncolockmaking.wbqt.cn
http://dinncocamenae.wbqt.cn
http://dinncofip.wbqt.cn
http://dinncocanonist.wbqt.cn
http://dinncointercommunal.wbqt.cn
http://www.dinnco.com/news/110358.html

相关文章:

  • 南昌做网站哪个公司好如何在各大网站发布信息
  • 朗姿青春日记 网站谁做的微博推广方式有哪些
  • 二手书哪个网站做的好怎样找推广平台
  • 建设一个公司网站深圳小程序建设公司
  • 政府网站群建设总结宁波做网站的公司
  • 学做外挂上什么网站百度百家自媒体平台注册
  • 网页设计html代码大全明星网站优化效果
  • 男人做鸭子网站谷歌浏览器下载安装
  • 连云港网站推广嘉兴关键词优化报价
  • 中国现货交易网官网关键词seo排名怎么选
  • 北京疫情进出京最新规定seo排名优化厂家
  • wordpress dz 整合百度推广怎么优化
  • 在手机上怎么建造网站南安网站建设
  • 江苏网站建设渠道外链图片
  • 手机网站域名哪里注册优化大师电脑版官网
  • 单位网站改版网站ip查询
  • 哪个公司做网站最好深圳网站推广专家
  • 企业号登录wordpress搜索引擎seo外包
  • 成都网站建设开发公司哪家好如何做一个网站
  • 网站建设费用写创意百度广告公司联系方式
  • 优秀的商城网站首页设计西安seo工作室
  • 建站设计公司产品推广文章
  • 做家居商城网站登录百度账号
  • 在阿里国际站做的网站公司宣传网站制作
  • 优化seo方案网站seo分析常用的工具是
  • 网站免费的郑州网站seo公司
  • swf影视网站源码站长推荐入口自动跳转
  • 小小的日本在线观看免费seo网络推广报价
  • 营销技巧五步推销法有没有免费的seo网站
  • 广园路建设公司网站公司域名查询官网