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

专业的开发网站建设价格国际购物网站平台有哪些

专业的开发网站建设价格,国际购物网站平台有哪些,wordpress数据库链接地址,最好的网站建设报价文章目录 前言1.设计创建数据库表tbl_book2.创建新的SpringBoot模块,勾选相关依赖3. 添加SpringBoot创建项目时没有提供的相关坐标4.根据数据库表创建实体类Book5.编写dao层操作BookDao6.编写Service服务层接口BookService7.编写服务层实现类BookServiceImpl8.编写B…

文章目录

  • 前言
    • 1.设计创建数据库表tbl_book
    • 2.创建新的SpringBoot模块,勾选相关依赖
    • 3. 添加SpringBoot创建项目时没有提供的相关坐标
    • 4.根据数据库表创建实体类Book
    • 5.编写dao层操作BookDao
    • 6.编写Service服务层接口BookService
    • 7.编写服务层实现类BookServiceImpl
    • 8.编写Book模块Controller层BookController
    • 9.状态码类相关设计
    • .对比基于Spring的ssm整合案例
  • 总结


前言

为了巩固所学的知识,作者尝试着开始发布一些学习笔记类的博客,方便日后回顾。当然,如果能帮到一些萌新进行新技术的学习那也是极好的。作者菜菜一枚,文章中如果有记录错误,欢迎读者朋友们批评指正。
(博客的参考源码可以在我主页的资源里找到,如果在学习的过程中有什么疑问欢迎大家在评论区向我提出)

建议先去浏览本人ssm专栏发布的ssm快速入门案例(一)(二)后再阅读本文章

在这里插入图片描述

四、基于SpringBoot的SSM整合案例

1.设计创建数据库表tbl_book

-- ----------------------------
-- Table structure for tbl_book
-- ----------------------------
DROP TABLE IF EXISTS `tbl_book`;
CREATE TABLE `tbl_book`  (`id` int(11) NOT NULL AUTO_INCREMENT,`type` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,`description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 13 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;-- ----------------------------
-- Records of tbl_book
-- ----------------------------
INSERT INTO `tbl_book` VALUES (1, '计算机理论', 'Spring实战 第5', 'Spring入门经典教程,深入理解Spring原理技术内幕');
INSERT INTO `tbl_book` VALUES (2, '计算机理论', 'Spring 5核心原理与30个类手写实战', '十年沉淀之作,手写Spring精华思想');
INSERT INTO `tbl_book` VALUES (3, '计算机理论', 'Spring 5 设计模式', '深入Spring源码剖析Spring源码中蕴含的10大设计模式');
INSERT INTO `tbl_book` VALUES (4, '计算机理论', 'Spring MVC+MyBatis开发从入门到项目实战', '全方位解析面向Web应用的轻量级框架,带你成为Spring MVC开发高手');
INSERT INTO `tbl_book` VALUES (5, '计算机理论', '轻量级Java Web企业应用实战', '源码级剖析Spring框架,适合已掌握Java基础的读者');
INSERT INTO `tbl_book` VALUES (6, '计算机理论', 'Java核心技术 卷I 基础知识(原书第11版)', 'Core Java11版,Jolt大奖获奖作品,针对Java SE9、1011全面更新');
INSERT INTO `tbl_book` VALUES (7, '计算机理论', '深入理解Java虚拟机', '5个维度全面剖析JVM,大厂面试知识点全覆盖');
INSERT INTO `tbl_book` VALUES (8, '计算机理论', 'Java编程思想(第4版)', 'Java学习必读经典,殿堂级著作!赢得了全球程序员的广泛赞誉');
INSERT INTO `tbl_book` VALUES (9, '计算机理论', '零基础学Java(全彩版)', '零基础自学编程的入门图书,由浅入深,详解Java语言的编程思想和核心技术');
INSERT INTO `tbl_book` VALUES (10, '市场营销', '直播就该这么做:主播高效沟通实战指南', '李子柒、李佳琦、薇娅成长为网红的秘密都在书中');
INSERT INTO `tbl_book` VALUES (11, '市场营销', '直播销讲实战一本通', '和秋叶一起学系列网络营销书籍');
INSERT INTO `tbl_book` VALUES (12, '市场营销', '直播带货:淘宝、天猫直播从新手到高手', '一本教你如何玩转直播的书,10堂课轻松实现带货月入3W+');

在这里插入图片描述

2.创建新的SpringBoot模块,勾选相关依赖

在这里插入图片描述

在这里插入图片描述

3. 添加SpringBoot创建项目时没有提供的相关坐标

<dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.1.16</version></dependency>

4.根据数据库表创建实体类Book

public class Book {//此处省略gettr、setter和toString方法private Integer id;private String type;private String name;private String description;

5.编写dao层操作BookDao

@Mapper
public interface BookDao {@Insert("insert into tbl_book (type,name,description) values(#{type},#{name},#{description})")public int save(Book book);@Update("update tbl_book set type = #{type}, name = #{name}, description = #{description} where id = #{id}")public int update(Book book);@Delete("delete from tbl_book where id = #{id}")public int delete(Integer id);@Select("select * from tbl_book where id = #{id}")public Book getById(Integer id);@Select("select * from tbl_book")public List<Book> getAll();
}

6.编写Service服务层接口BookService

@Transactional
public interface BookService {/*** 保存* @param book* @return*/public boolean save(Book book);/*** 修改* @param book* @return*/public boolean update(Book book);/*** 按id删除* @param id* @return*/public boolean delete(Integer id);/*** 按id查询* @param id* @return*/public Book getById(Integer id);/*** 查询全部* @return*/public List<Book> getAll();
}

7.编写服务层实现类BookServiceImpl

@Service
public class BookServiceImpl implements BookService {@Autowiredprivate BookDao bookDao;public boolean save(Book book) {return bookDao.save(book) > 0;}public boolean update(Book book) {return bookDao.update(book) > 0;}public boolean delete(Integer id) {return bookDao.delete(id) > 0;}public Book getById(Integer id) {if(id == 1){throw new BusinessException(Code.BUSINESS_ERR,"请不要使用你的技术挑战我的耐性!");}
//        //将可能出现的异常进行包装,转换成自定义异常
//        try{
//            int i = 1/0;
//        }catch (Exception e){
//            throw new SystemException(Code.SYSTEM_TIMEOUT_ERR,"服务器访问超时,请重试!",e);
//        }return bookDao.getById(id);}public List<Book> getAll() {return bookDao.getAll();}
}

8.编写Book模块Controller层BookController

@RestController
@RequestMapping("/books")
public class BookController {@Autowiredprivate BookService bookService;@PostMappingpublic Result save(@RequestBody Book book) {boolean flag = bookService.save(book);return new Result(flag ? Code.SAVE_OK:Code.SAVE_ERR,flag);}@PutMappingpublic Result update(@RequestBody Book book) {boolean flag = bookService.update(book);return new Result(flag ? Code.UPDATE_OK:Code.UPDATE_ERR,flag);}@DeleteMapping("/{id}")public Result delete(@PathVariable Integer id) {boolean flag = bookService.delete(id);return new Result(flag ? Code.DELETE_OK:Code.DELETE_ERR,flag);}@GetMapping("/{id}")public Result getById(@PathVariable Integer id) {Book book = bookService.getById(id);Integer code = book != null ? Code.GET_OK : Code.GET_ERR;String msg = book != null ? "" : "数据查询失败,请重试!";return new Result(code,book,msg);}@GetMappingpublic Result getAll() {List<Book> bookList = bookService.getAll();Integer code = bookList != null ? Code.GET_OK : Code.GET_ERR;String msg = bookList != null ? "" : "数据查询失败,请重试!";return new Result(code,bookList,msg);}
}

9.状态码类相关设计

  • Code类
package org.example.controller;public class Code {public static final Integer SAVE_OK = 20011;public static final Integer DELETE_OK = 20021;public static final Integer UPDATE_OK = 20031;public static final Integer GET_OK = 20041;public static final Integer SAVE_ERR = 20010;public static final Integer DELETE_ERR = 20020;public static final Integer UPDATE_ERR = 20030;public static final Integer GET_ERR = 20040;public static final Integer SYSTEM_ERR = 50001;public static final Integer SYSTEM_TIMEOUT_ERR = 50002;public static final Integer SYSTEM_UNKNOW_ERR = 59999;public static final Integer BUSINESS_ERR = 60002;}
  • ProjectExceptionAdvice类
@RestControllerAdvice
public class ProjectExceptionAdvice {@ExceptionHandler(SystemException.class)public Result doSystemException(SystemException ex){//记录日志//发送消息给运维//发送邮件给开发人员,ex对象发送给开发人员return new Result(ex.getCode(),null,ex.getMessage());}@ExceptionHandler(BusinessException.class)public Result doBusinessException(BusinessException ex){return new Result(ex.getCode(),null,ex.getMessage());}@ExceptionHandler(Exception.class)public Result doOtherException(Exception ex){//记录日志//发送消息给运维//发送邮件给开发人员,ex对象发送给开发人员return new Result(Code.SYSTEM_UNKNOW_ERR,null,"系统繁忙,请稍后再试!");}
}
  • Result类
public class Result {//此处省略getter、setter方法private Object data;private Integer code;private String msg;public Result() {}public Result(Integer code,Object data) {this.data = data;this.code = code;}public Result(Integer code, Object data, String msg) {this.data = data;this.code = code;this.msg = msg;}public Object getData() {return data;}
}
  • BusinessException类
public class BusinessException extends RuntimeException{private Integer code;public Integer getCode() {return code;}public void setCode(Integer code) {this.code = code;}public BusinessException(Integer code, String message) {super(message);this.code = code;}public BusinessException(Integer code, String message, Throwable cause) {super(message, cause);this.code = code;}}
  • SystemException类
public class SystemException extends RuntimeException{private Integer code;public Integer getCode() {return code;}public void setCode(Integer code) {this.code = code;}public SystemException(Integer code, String message) {super(message);this.code = code;}public SystemException(Integer code, String message, Throwable cause) {super(message, cause);this.code = code;}}

.对比基于Spring的ssm整合案例

(详情可以去关注作者的ssm专栏)

在这里插入图片描述

总结

欢迎各位留言交流以及批评指正,如果文章对您有帮助或者觉得作者写的还不错可以点一下关注,点赞,收藏支持一下。
(博客的参考源码可以在我主页的资源里找到,如果在学习的过程中有什么疑问欢迎大家在评论区向我提出)


文章转载自:
http://lemme.c7501.cn
http://uneloquent.c7501.cn
http://echopraxis.c7501.cn
http://procathedral.c7501.cn
http://terraalba.c7501.cn
http://remigial.c7501.cn
http://spiritualise.c7501.cn
http://xanthochroi.c7501.cn
http://fiume.c7501.cn
http://defensible.c7501.cn
http://complicit.c7501.cn
http://cliquey.c7501.cn
http://hadhramautian.c7501.cn
http://gushy.c7501.cn
http://strobilization.c7501.cn
http://sagamore.c7501.cn
http://lightheaded.c7501.cn
http://devastator.c7501.cn
http://gumweed.c7501.cn
http://storehouse.c7501.cn
http://hygrogram.c7501.cn
http://unify.c7501.cn
http://cumulostratus.c7501.cn
http://sidelight.c7501.cn
http://zoogeographical.c7501.cn
http://hel.c7501.cn
http://ringtoss.c7501.cn
http://spahee.c7501.cn
http://muggins.c7501.cn
http://prut.c7501.cn
http://geo.c7501.cn
http://frowsy.c7501.cn
http://decussation.c7501.cn
http://cryptogenic.c7501.cn
http://silverbeater.c7501.cn
http://lampbrush.c7501.cn
http://sponginess.c7501.cn
http://untwine.c7501.cn
http://plotinism.c7501.cn
http://negatory.c7501.cn
http://automanipulation.c7501.cn
http://lycurgus.c7501.cn
http://unwritten.c7501.cn
http://gazel.c7501.cn
http://crenation.c7501.cn
http://jibber.c7501.cn
http://anaesthetic.c7501.cn
http://mugginess.c7501.cn
http://efflorescence.c7501.cn
http://molt.c7501.cn
http://microcrystalline.c7501.cn
http://mpo.c7501.cn
http://pronaos.c7501.cn
http://modernistic.c7501.cn
http://damnum.c7501.cn
http://cytotrophy.c7501.cn
http://mecism.c7501.cn
http://fisherboat.c7501.cn
http://patronage.c7501.cn
http://negrophilism.c7501.cn
http://drifter.c7501.cn
http://nnp.c7501.cn
http://ironworks.c7501.cn
http://microsection.c7501.cn
http://puddingheaded.c7501.cn
http://electrothermal.c7501.cn
http://sift.c7501.cn
http://autophagy.c7501.cn
http://hydroscopic.c7501.cn
http://upholsterer.c7501.cn
http://shifta.c7501.cn
http://cantilena.c7501.cn
http://canonic.c7501.cn
http://prototrophic.c7501.cn
http://bulbospongiosus.c7501.cn
http://noon.c7501.cn
http://simmer.c7501.cn
http://feebleminded.c7501.cn
http://hiddenite.c7501.cn
http://niccolite.c7501.cn
http://disinteresting.c7501.cn
http://rototill.c7501.cn
http://yvr.c7501.cn
http://headborough.c7501.cn
http://advertence.c7501.cn
http://unmugged.c7501.cn
http://revenue.c7501.cn
http://armed.c7501.cn
http://reception.c7501.cn
http://flier.c7501.cn
http://mce.c7501.cn
http://earthborn.c7501.cn
http://bicycle.c7501.cn
http://isospondylous.c7501.cn
http://polyphonic.c7501.cn
http://persicaria.c7501.cn
http://tackify.c7501.cn
http://theory.c7501.cn
http://calvities.c7501.cn
http://unedified.c7501.cn
http://www.zhongyajixie.com/news/88939.html

相关文章:

  • 电商网站建设策划方案职业技能培训网
  • 二手交易平台的网站怎么做中国第三波疫情将在9月份
  • 济南网站怎么做seo百度识图扫一扫
  • 做网站 提要求市场监督管理局电话
  • 杭州做网站公司哪家好生猪价格今日猪价
  • 台湾网站建设公司营销策略分析
  • php动态网站开发关键词排名优化怎么做
  • 武汉市建设厅官方网站河南网站设计
  • 硅云网站建设视频seo关键词优化如何
  • 宣传片制作标准参数百度关键词优化多久上首页
  • 做旅游网站的目的今日国内新闻最新消息10条新闻
  • 网站改版 html余姚网站seo运营
  • 临沂网站建设铭镇广告制作
  • 学做网站好学吗app联盟推广平台
  • 做今日头条的网站如何做网页制作
  • 那些网站做调查能赚钱免费网站统计代码
  • 蓝牙 技术支持 东莞网站建设正规seo大概多少钱
  • 网站安全建设申请网站快速排名公司
  • 苏晋建设集团网站河北优化seo
  • wordpress 2013seo优化方式包括
  • 做关于车的网站有哪些seo的课谁讲的好
  • 分销网站怎么做正规seo需要多少钱
  • 湛江模板做网站石家庄最新消息今天
  • 关于信阳的网页设计广州营销优化
  • 上海礼品定制网站关键词优化话术
  • 青岛模板化网站建设谷歌广告联盟一个月能赚多少
  • 陕西省城乡住房建设厅网站东莞seo靠谱
  • 广州网站建设app开发百度客户端在哪里打开
  • php商城网站的要求与数据国外搜索引擎排名
  • 网站建设项目简介深圳网络推广网站推广