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

如何建设属于自己的网站网络营销案例分析ppt

如何建设属于自己的网站,网络营销案例分析ppt,网站建设7,网站建设的核心目录一、背景二、思路&方案问题1优化问题2优化三、总结四、升华一、背景 写这篇文章的目的是通过对没有复用思想接口的代码例子优化告诉大家,没有复用思想的代码不要写,用这种思维方式和习惯来指导我们写代码。 项目中有两处没有复用思想代码&#…

目录

    • 一、背景
    • 二、思路&方案
      • 问题1优化
      • 问题2优化
    • 三、总结
    • 四、升华

一、背景

写这篇文章的目的是通过对没有复用思想接口的代码例子优化告诉大家,没有复用思想的代码不要写,用这种思维方式和习惯来指导我们写代码。
项目中有两处没有复用思想代码,如下:
1、通过查看代码可以发现。接口findOnlineUesr和findAllOnlineUser两个接口的返回类型是相同的,只是一个有入参,另一个没有入参。这种情况我们可以通过一个通用的接口解决这些问题。
在这里插入图片描述
2、通过查看代码我们发现。这条动态sql里。course_id = #{course_id} 出现了多次。我们完全可以将这个功能的抽出来。而不是重复的事情做3次。
在这里插入图片描述

二、思路&方案

此番写这篇博客只为三件事:复用!!! 复用!!!还是复用!!!!

问题1优化

针对问题一。我们实现一个接口。下面将会把代码从
Controller==>IService==>ServiceImple==>mapper 。整个流程依次展示出来。
Controller

    @PostMapping("/queryCourseContent")public List<CourseContentEntity> queryCourseContent(@RequestBody CourseContentEntity courseContent){return iCourseContentService.queryCourseContent(courseContent);}

IService

  List<CourseContentEntity> queryCourseContent(CourseContentEntity courseContent);

ServiceImpl

    @Overridepublic List<CourseContentEntity> queryCourseContent(CourseContentEntity courseContent) {return courseContentMapper.queryCourseContentRecord(courseContent);}

重点!!!!!!
mapper

List<CourseContentEntity> queryCourseContentRecord(CourseContentEntity courseContentEntity);<!--    通用查询语句--><select id="queryCourseContentRecord" resultMap="courseContentMap" >SELECT id,course_assembly_id,assembly_content,create_time,created_id,created_by,update_time,updated_id,updated_byFROM  tar_course_content_infoWHEREis_delete=0<if test="id != null"> and id = #{id} </if><if test="courseAssemblyId != null">and course_assembly_id = #{courseAssemblyId}</if><if test="assemblyContent != null">and assembly_content = #{assemblyContent}</if><if test="createdBy != null">and created_by = #{createdBy}</if><if test="updatedBy != null">and updated_by = #{updatedBy}</if><if test="remark != null">and remark = #{remark}</if></select>

下面进行测试
一开始的两个接口一个是为了查询所有的信息,一个是为了查询某个具体班级的人员

1、获取所有课程
在这里插入图片描述
在这里插入图片描述
2、获取某个人创建的课程
在这里插入图片描述

可以观察到数据结构是一样的,我们改造后的接口是没有问题的。

问题2优化

优化前
仔细分析下面代码我们可以发现:它是提供了四种不同的where查询,而这四种查询都是使用 = 来做的。我们完全没有必要使用 choose、when、otherwise、标签。使用if做一个通用查询就可以

select id,user_id,user_name,questionnaire_id,activity_name,course_id,class_id,user_answer,start_time,update_time,remark,is_deletefrom`arpro_user_answer`<where><choose><when test="id !='' and id != null">and id=#{id}</when><when test="user_answer !='' and user_answer != null">user_answer=#{user_answer}and course_id = #{course_id}and class_id = #{class_id}</when><when test="questionnaire_id !='' and questionnaire_id != null">and questionnaire_id=#{questionnaire_id}and course_id = #{course_id}and class_id = #{class_id}</when><otherwise>and course_id = #{course_id}and class_id = #{class_id}and is_delete = 0</otherwise></choose></where>

优化后:

        select id,user_id,user_name,questionnaire_id,activity_name,course_id,class_id,user_answer,start_time,update_time,remark,is_deletefrom`arpro_user_answer`<where>is_delete = 0<if test="id !='' and id !=null"> and id = #{id} </if><if test="userAnswer !='' and userAnswer !=null"> and user_answer = #{userAnswer} </if><if test="courseId !='' and courseId !=null"> and course_id = #{courseId} </if><if test="classId !='' and classId !=null"> and class_id = #{classId} </if><if test="userAnswer !='' and userAnswer !=null"> and user_answer = #{userAnswer} </if></where>

三、总结

通过这种通用sql的方式。我们避免了重复的代码,降低了出错的概率。在代码的整洁度上也是明显的提高。

四、升华

大道至简,思考怎么才能用最简单的代码写出最牛的效果。

http://www.ds6.com.cn/news/36263.html

相关文章:

  • 自己给别人做网站挣钱吗网络营销推广方案有哪些
  • 中山建网站费用多少营销培训班
  • 怎么做淘宝店网站收录最近一周新闻大事摘抄2022年
  • 泉州优化seo网站关键词优化网络营销发展方案策划书
  • 做粘土网站郑州网站建设
  • 建设网站技术公司培训网络营销的机构
  • 百度网站怎么做友情链接搜狗推广登录平台
  • 怎样做内网网站整合营销什么意思
  • 电子商务网站建设与运营百度通用网址
  • 长春哪里做网站网站seo推广计划
  • 兄弟网站建设济南网络推广公司
  • 成都网站开发培训多少钱seo引擎优化服务
  • 东莞网站设计建设公司浙江疫情最新情况
  • 购买网站空间后怎么做推56论坛
  • 展览馆设计公司排名陕西网站seo
  • 百度创建网站吗培训班线上优化
  • 软件定制与开发淮北seo排名
  • 门户网站方案营销广告语
  • wordpress微信模板seo推广技术
  • 美国小卖家做deal网站网站服务器ip地址查询
  • 聊城wap网站制作河南郑州最新消息今天
  • 龙华做网站app开发公司推荐
  • 个人网站设计论文道客巴巴优化网站建设seo
  • 做网站技术服务费属于什么科目销售怎么找客户源
  • 免费做网站靠谱么win11优化大师
  • 企业网站页面南宁seo网络优化公司
  • 莆田建设企业网站快速排名优化系统
  • 白城学习做网站的学校整合营销传播策略
  • 洛阳做网站汉狮网络网络服务器
  • 买做指甲的材料在哪个网站2024年阳性什么症状