整合springboot+mybatisplus+mysql+swagger,开发后端接口

一、版本

1. springboot:2.7.8

2. mybatisplus:3.5.3.1

3. mysql:8.0

4. swagger:3.0

二、建立数据表(省略表结构)

三、新建maven工程及springboot项目

1. 完成后的项目目录:

2. maven工程的pom文件引入依赖:

点击查看代码
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>javaTest</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>18</maven.compiler.source>
        <maven.compiler.target>18</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.8</version>
        <relativePath/>
    </parent>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.5.3.1</version>
        </dependency>
        <!-- mybatis-plus代码自动生成器依赖-->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-generator</artifactId>
            <version>3.5.3.1</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-boot-starter</artifactId>
            <version>3.0.0</version>
        </dependency>
        <!--mysql-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.30</version>
        </dependency>
        <!--lombok用来简化实体类-->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j2</artifactId>
        </dependency>
        <!--解决代码生成报错-->
        <dependency>
            <groupId>org.apache.velocity</groupId>
            <artifactId>velocity-engine-core</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>5.3.9</version>
        </dependency>
    </dependencies>
</project>

3. 通过mybatisplus的代码生成器生成controller,entity,service,mapper等模块代码:

点击查看代码
package com.kye.generator;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.fill.Column;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Generator {
    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:mysql://IP:端口/数据库库名?server-timezone=Asia?useUnicode=true&characterEncoding=utf8", "账号", "密码")
                // 全局配置
                .globalConfig((scanner, builder) -> builder.author("faith") //作者
                .enableSwagger()// 开启 swagger 模式
                .outputDir("D:\\code\\javaCode\\javaTest\\src\\main\\java"))//生成的包所在目录
                // 包配置
                .packageConfig((scanner, builder) -> builder.parent("com.kye"))
                // 策略配置
                .strategyConfig((scanner, builder) -> builder.addInclude(getTables(scanner.apply("请输入表名,多个英文逗号分隔?所有输入 all:")))
                        .controllerBuilder().enableRestStyle().enableHyphenStyle()
                        .entityBuilder().enableLombok().addTableFills(
                                new Column("create_time", FieldFill.INSERT)
                        ).build())
                /*
                    模板引擎配置,默认 Velocity 可选模板引擎 Beetl 或 Freemarker
                   .templateEngine(new BeetlTemplateEngine())
                   .templateEngine(new FreemarkerTemplateEngine())
                 */
                .execute();
    }
    protected static List<String> getTables(String tables) {
        return "all".equals(tables) ? Collections.emptyList() : Arrays.asList(tables.split(","));
    }
}

4. 配置application.yaml文件

点击查看代码
server:
  port: 8080
spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://10.83.132.4:3306/vts_thirdparty?server-timezone=Asia?Shanghai&useUnicode=true&charterEncoding=utf-8
    username: app_admin_vts
    password: AtsB@2020Eky
  mvc:
    path match:
      matching-strategy: ant_path_matcher #swagger3.0配置
mybatis-plus:
  mapper-locations: classpath*:/mapper/*Mapper.xml
  type-aliases-package: com.king.mispronunciation.model
  configuration:
    #驼峰命名规则
    map-underscore-to-camel-case: true
    logImpl: org.apache.ibatis.logging.stdout.StdOutImpl # 使用标准输出流作为日志输出
logging:
  level:
    root: info

5. 通过以上步骤,已经完全生成了controller,entity,service,mapper等模块的代码

5.1.对于mapper模块的代码基本不用修改,因为mapper的接口是直接操作数据库的
5.2. 对于service模块的代码,可以自己写实现逻辑,例:
点击查看代码
package com.kye.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kye.entity.ThirdMbIdRelation;
import com.kye.mapper.ThirdMbIdRelationMapper;
import com.kye.common.Result;
import com.kye.service.IThirdMbIdRelationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author faith
 * @since 2023-11-28
 */
@Service
public class ThirdMbIdRelationServiceImpl extends ServiceImpl<ThirdMbIdRelationMapper, ThirdMbIdRelation> implements IThirdMbIdRelationService {

    @Autowired
    private ThirdMbIdRelationMapper thirdMbIdRelationMapper;

    public Result getMbId(String id) {
        QueryWrapper<ThirdMbIdRelation> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("id","demand_order_code","mb_id").eq("id",id);
        List<Map<String, Object>> selectMaps = thirdMbIdRelationMapper.selectMaps(queryWrapper);
        return Result.success(selectMaps);

    }


}
5.3.controller模块的代码配置接口访问的路径,注意方法上一定要有访问的路径
点击查看代码
package com.kye.controller;

import com.kye.common.Result;
import com.kye.entity.ThirdMbIdRelation;
import com.kye.mapper.ThirdMbIdRelationMapper;
import com.kye.service.IThirdMbIdRelationService;
import io.swagger.annotations.Api;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.SQLOutput;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author faith
 * @since 2023-11-28
 */
@RestController
@RequestMapping("/third-mb-id-relation")
@Api(tags = "通过订单编码查询货拉拉id") //swagger注解,解释controller功能
public class ThirdMbIdRelationController {

    private final IThirdMbIdRelationService thirdMbIdRelationService;

    public ThirdMbIdRelationController(IThirdMbIdRelationService thirdMbIdRelationService) {
        this.thirdMbIdRelationService = thirdMbIdRelationService;
    }

    @GetMapping("/{id}")
    public Result getInfo(@PathVariable String id){
        Result mbId = thirdMbIdRelationService.getMbId(id);
        System.out.println(mbId);
        return mbId;
    }
}

6. 通过以上步骤,一个完整的接口已经开发完毕,但是通常在开发中需要接口的返回值统一格式,因此编写Result类封装接口统一返回格式

点击查看代码
package com.kye.common;

import lombok.Data;

import java.io.Serializable;

@Data
public class Result {
    private Integer code;
    private String msg;
    private Object data;

    //响应成功,默认msg
    public static Result success(Object data) {
        Result result = new Result();
        result.setCode(200);
        result.setMsg("操作成功");
        result.setData(data);
        return result;
    }
    //响应成功,自定义msg
    public static Result success(String msg,Object data){
        Result result = new Result();
        result.setCode(200);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }
    //响应失败
    public static Result fail(String msg){
        Result result = new Result();
        result.setCode(-1);
        result.setMsg(msg);
        result.setData(null);
        return result;
    }
    //响应失败,传入对象
    public static Result fail(String msg,Object data){
        Result result = new Result();
        result.setCode(-2);
        result.setData(data);
        result.setMsg(msg);
        return result;
    }
}

7.接口开发完毕,调试接口,通过集成swagger3.0统一调试,配置swagger后便可正常,访问swagger:http://localhost:8080/swagger-ui/

点击查看代码
package com.kye.common;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

//1. 配置类
@Configuration
//2. 开启swagger支持
//@EnableSwagger2
@EnableOpenApi//swagger3.0依赖 可以不写
public class SwaggerConfig {
    /**
     * 3、自动创建Docket文档摘要对象
     */
    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.OAS_30) // 选择swagger的版本,这里若选的3.0则要用OAS_30
                // 配置文档信息:swagger文档的标题、版本、描述
                .apiInfo(this.apiInfo())
                .select()
                // 配置要生成swagger文档的扫描的目录包
                .apis(RequestHandlerSelectors.basePackage("com.kye"))
                // 对指定路径下的任意类生成文档
                .paths(PathSelectors.any())
                // 创建对象
                .build();
    }
    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                // 指定文档标题 (在swagger页面会显示)
                .title("SpringBoot接口文件")
                // 指定文档的版本
                .version("1.0")
                // 文档描述
                .description("API描述").build();
    }
}

原文参考:https://www.cnblogs.com/helex/p/16493421.html

posted @ 2023-12-03 12:16  竹狼  阅读(186)  评论(0编辑  收藏  举报
<style id="ceshicss"> @media (max-width: 767px){ #set_btn_box {width: 100vw;left: 0;right: 0;bottom: 0;background: hsla(0,0%,100%,.6);height: 49px;display: flex;justify-content: space-between;align-items: center;padding: 12px 40px;border-top: 1px solid #e8e8e8;box-sizing: border-box;} .set_btn {margin-top: 0;} .set_btn.fly_top.fadeIn.animated {position: absolute;right: 10px;bottom: 60px;} .container{bottom:50px}} #mainContent{width:90%} </style> <link href="https://blog-static.cnblogs.com/files/miluluyo/tippy.min.css" rel="stylesheet"> <script src="https://unpkg.com/@popperjs/core@2.4.2/dist/umd/popper.min.js"></script> <script src="https://blog-static.cnblogs.com/files/miluluyo/tippy.js"></script> <link rel='stylesheet' href='https://cdn.bootcss.com/animate.css/3.7.2/animate.min.css'> <script src="https://at.alicdn.com/t/font_1825850_klax1ao4o6.js"></script> <script src="https://blog-static.cnblogs.com/files/miluluyo/three.min.js"></script> <script src='https://blog-static.cnblogs.com/files/miluluyo/star.js'></script> <link rel="stylesheet" href="https://blog-static.cnblogs.com/files/miluluyo/OwO.min.css" /> <script src="https://blog-static.cnblogs.com/files/miluluyo/OwO2.min.js"></script> <script src="https://blog-static.cnblogs.com/files/miluluyo/cute-cnblogs2.js"></script> <script src="https://blog-static.cnblogs.com/files/miluluyo/monitoring2.js"></script> <script> miluframe({ Youself:'https://www.cnblogs.com/faith007/', /*个人的博客园链接*/ /*博客园导航信息*/ custom:[{ name:'首页', link:'https://www.cnblogs.com/faith007/', istarget:false },{ name:'联系', link:'https://msg.cnblogs.com/send/%E7%AB%B9%E7%8B%BC', istarget:true },{ name:'留言板', link:'https://www.cnblogs.com/faith007/p/11578505.html', istarget:false },{ name:'相册', link:'https://www.cnblogs.com/faith007/gallery.html', istarget:false },{ name:'管理', link:'https://i.cnblogs.com/', istarget:true }], /*向别人展示自己的友链信息*/ resume:{ "name":"竹狼", "link":"https://www.cnblogs.com/faith007/", "headurl":"https://files-cdn.cnblogs.com/files/blogs/436273/VCG211321527184.bmp", "introduction":"大道至简,知易行难。" }], /*友链表格头信息,这个可以忽略*/ details:[{ field: 'name', literal: '昵称', },{ field: 'introduction', literal: '标语', },{ field: 'url', literal: '链接地址', },{ field: 'headurl', literal: '头像地址', }], /*浏览器顶部小图标*/ logoimg:'https://images.cnblogs.com/cnblogs_com/miluluyo/1765646/o_200519070633f12.png', /*文章页面标题前的图标,此处图标有扩展,下面会提到图标*/ cuteicon:['icon-caomei','icon-boluo','icon-huolongguo','icon-chengzi','icon-hamigua','icon-lizhi','icon-mangguo','icon-liulian','icon-lizi','icon-lanmei','icon-longyan','icon-shanzhu','icon-pingguo','icon-mihoutao','icon-niuyouguo','icon-xigua','icon-putao','icon-xiangjiao','icon-ningmeng','icon-yingtao','icon-taozi','icon-shiliu','icon-ximei','icon-shizi'], /*赞赏,若true则显示此按钮,false则不显示*/ isGratuity:false, /*赞赏按钮焦点显示赞赏内容,内容可自行更改*/ gratuity:'<div class="popper_box"><p><b>要请我喝奶茶吗 (づ。◕ᴗᴗ◕。)づ</b> </p><div class="popper_box_con"><div class="popper_box_con_li"><img src="https://images.cnblogs.com/cnblogs_com/miluluyo/1765646/o_200521053817wx.png" alt="">微信扫码</div><div class="popper_box_con_li"><img src="https://images.cnblogs.com/cnblogs_com/miluluyo/1765646/o_200521053827zfb.png" >支付宝扫码</div></div><p><b>留下一句你觉得很励志与美的话给我吧~</b>&nbsp;&nbsp;<b><a href="https://www.cnblogs.com/miluluyo/p/12930946.html">GO</a></b></div>' }) </script> <!-- 点赞 --> <canvas width="1777" height="841" style="position: fixed; left: 0px; top: 0px; z-index: 2147483647; pointer-events: none;"></canvas><script src="https://blog-static.cnblogs.com/files/miluluyo/mouse-click.js"></script> <!-- 以下内容是否添加你随意 --> <script> /*在文章页面添加古诗词*/ $("#navigator").after('<div class="poem-wrap"><div class="poem-border poem-left"></div><div class="poem-border poem-right"></div><h1>念两句诗</h1><div id="poem_sentence"></div><div id="poem_info"></div></div>') </script> <script src="https://sdk.jinrishici.com/v2/browser/jinrishici.js" charset="utf-8"></script> <script type="text/javascript"> jinrishici.load(function(result) { var sentence = document.querySelector("#poem_sentence") var info = document.querySelector("#poem_info") sentence.innerHTML = result.data.content info.innerHTML = '【' + result.data.origin.dynasty + '】' + result.data.origin.author + '《' + result.data.origin.title + '》' }); </script> <script type="text/javascript"> /* 鼠标特效,我觉得太花哨了就注释了,喜欢的自己打开注释就可以 */ /*var a_idx = 0; jQuery(document).ready(function($) { $("body").click(function(e) { var a = new Array("❤去活出你自己。❤","❤今天的好计划胜过明天的完美计划。❤","❤不要轻言放弃,否则对不起自己。❤","❤紧要关头不放弃,绝望就会变成希望。❤","❤如果不能改变结果,那就完善过程。❤","❤好好活就是干有意义的事,有意义的事就是好好活!❤","❤你真正是谁并不重要,重要的是你的所做所为。❤","❤你不想为你的信仰冒一下险吗?难道想等你老了,再后悔莫及吗?❤","❤有些鸟儿是关不住的,它的每一根羽毛都闪耀着自由的光辉。❤","❤决定我们成为什么样人的,不是我们的能力,而是我们的选择。❤","❤掉在水里你不会淹死,呆在水里你才会淹死,你只有游,不停的往前游。❤","❤有些路,只能一个人走。❤","❤希望你眼眸有星辰,心中有山海。❤","❤从此以梦为马,不负韶华。❤","❤人的成就和差异决定于其业余时间。❤","❤佛不要你皈依,佛要你欢喜。❤","❤ダーリンのこと 大好きだよ❤","❤小猫在午睡时,地球在转。❤","❤我,混世大魔王,申请做你的小熊软糖。❤","❤决定好啦,要暗暗努力。❤","❤呐,做人呢最紧要开心。❤","❤好想邀请你一起去云朵上打呼噜呀。❤","❤永远年轻,永远热泪盈眶。❤","❤我生来平庸,也生来骄傲。❤","❤我走得很慢,但我从不后退。❤","❤人间不正经生活手册。❤","❤我是可爱的小姑娘,你是可爱。❤","❤数学里,有个温柔霸道的词,有且仅有。❤","❤吧唧一口,吃掉难过。❤","❤你头发乱了哦。❤","❤健康可爱,没有眼袋。❤","❤日月星辰之外,你是第四种难得。❤","❤你是否成为了了不起的成年人?❤","❤大家都是第一次做人。❤","❤何事喧哗?!❤","❤人间有味是清欢。❤","❤你笑起来真像好天气。❤","❤风填词半句,雪斟酒一壶。❤","❤除了自渡,他人爱莫能助。❤","❤昨日种种,皆成今我。❤","❤一梦入混沌 明月撞星辰❤","❤保持独立 适当拥有❤","❤谢谢你出现 这一生我很喜欢❤","❤做自己就好了 我会喜欢你的❤","❤太严肃的话,是没办法在人间寻欢作乐的❤","❤愿你余生可随遇而安,步步慢。❤","❤黄瓜在于拍,人生在于嗨❤","❤奇变偶不变,符号看象限。❤","❤从来如此,便对么?❤","❤今天我这儿的太阳,正好适合晒钙 你呢❤","❤未来可期,万事胜意。❤","❤星光不问赶路人 时光不负有心人❤","❤我当然不会试图摘月,我要月亮奔我而来❤","❤女生要修炼成的五样东西: 扬在脸上的自信,长在心底的善良, 融进血里的骨气,刻进命里的坚强,深到骨子里的教养❤","❤燕去燕归,沧海桑田。纵此生不见,平安惟愿❤","❤我想认识你 趁风不注意❤","❤我一直想从你的窗子里看月亮❤","❤长大应该是变温柔,对全世界都温柔。❤","❤别在深夜做任何决定❤","❤山中何事,松花酿酒,春水煎茶。❤","❤桃李春风一杯酒,江湖夜雨十年灯。❤","❤欲买桂花同载酒,终不似,少年游。❤"); var le = Math.ceil(Math.random()*a.length); var $i = $("<span></span>").text(a[le]);/*a[a_idx]*/ /*a_idx = (a_idx + 1) % a.length; var x = e.pageX, y = e.pageY; $i.css({ "z-index": 999999999999999999999999999999999999999999999999999999999999999999999, "top": y - 20, "left": x, "position": "absolute", "font-weight": "bold", "color": "rgb("+~~(255*Math.random())+","+~~(255*Math.random())+","+~~(255*Math.random())+")" }); $("body").append($i); $i.animate({ "top": y - 180, "opacity": 0 }, 2000, function() { $i.remove(); }); }); });*/ </script> <!--音乐,只在PC端宽度>1000px时显示--> <!-- <link rel="stylesheet" href="https://blog-static.cnblogs.com/files/miluluyo/APlayer.min.css"> <div id="player" class="aplayer aplayer-withlist aplayer-fixed" data-id="3116636104" data-server="netease" data-type="playlist" data-order="random" data-fixed="true" data-listfolded="true" data-theme="#2D8CF0"></div> <script src="https://blog-static.cnblogs.com/files/miluluyo/APlayer.min.js"></script> <script src="https://blog-static.cnblogs.com/files/miluluyo/Meting.min.js"></script> --> <!--猫,只在PC端显示,移动端不加载了,因为会卡顿页面--> <!-- <script src="https://eqcn.ajz.miesnfu.com/wp-content/plugins/wp-3d-pony/live2dw/lib/L2Dwidget.min.js"></script> <script> var mobile_flag = isMobile(); if(mobile_flag){ //console.info("移动端") }else{ //console.info("PC端") L2Dwidget.init({ "model": { "jsonPath": "https://unpkg.com/live2d-widget-model-hijiki/assets/hijiki.model.json", "scale": 1 }, "display": { "position": "left", "width": 100, "height": 200, "hOffset": 70, "vOffset": 0 }, "mobile": { "show": true, "scale": 0.5 }, "react": { "opacityDefault": 0.7, "opacityOnHover": 0.2 } }); window.onload = function(){ $("#live2dcanvas").attr("style","position: fixed; opacity: 0.7; left: 70px; bottom: 0px; z-index: 1; pointer-events: none;") } } </script> --> <script> <script language="javascript" type="text/javascript"> // 生成目录索引列表 // ref: http://www.cnblogs.com/wangqiguo/p/4355032.html // modified by: zzq function GenerateContentList() { var mainContent = $('#cnblogs_post_body'); var h3_list = $('#cnblogs_post_body h3');//如果你的章节标题不是h2,只需要将这里的h2换掉即可 if(mainContent.length < 1) return; if(h3_list.length>0) { var content = '<a name="_labelTop"></a>'; content += '<div id="navCategory" style="color:#152e97;">'; content += '<p style="font-size:18px;"><b>目录</b></p>'; content += '<ul>'; for(var i=0; i<h3_list.length; i++) { var go_to_top = '<div style="text-align: right;"><a href="#_labelTop" style="color:#f68a33">回到顶部</a><a name="_label' + i + '"></a></div>'; $(h3_list[i]).before(go_to_top); var h4_list = $(h3_list[i]).nextAll("h4"); var li3_content = ''; for(var j=0; j<h4_list.length; j++) { var tmp = $(h4_list[j]).prevAll('h3').first(); if(!tmp.is(h3_list[i])) break; var li3_anchor = '<a name="_label' + i + '_' + j + '"></a>'; $(h4_list[j]).before(li3_anchor); li3_content += '<li><a href="#_label' + i + '_' + j + '">' + $(h4_list[j]).text() + '</a></li>'; } var li3_content = ''; if(li3_content.length > 0) li3_content = '<li><a href="#_label' + i + '">' + $(h3_list[i]).text() + '</a><ul>' + li3_content + '</ul></li>'; else li3_content = '<li><a href="#_label' + i + '">' + $(h3_list[i]).text() + '</a></li>'; content += li3_content; } content += '</ul>'; content += '</div><p>&nbsp;</p>'; content += '<hr style="height:1px;border:none;border-top:1px dashed #0066CC;"/>'; if($('#cnblogs_post_body').length != 0 ) { $($('#cnblogs_post_body')[0]).prepend(content); } } } GenerateContentList(); </script>