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

app营销策略怎么写成都网站seo公司

app营销策略怎么写,成都网站seo公司,地区汽车修理网站建设,是网站推广的案例文章目录 1.动态SQL使用什么是动态sql为什么用动态sql标签拼接标签拼接标签拼接标签拼接标签拼接 补充1:resultType和resultMap补充2:后端开发中单元测试工具使用(Junit框架) 1.动态SQL使用 以insert标签为例 什么是动态sql 是…

文章目录

      • 1.动态SQL使用
        • 什么是动态sql
        • 为什么用动态sql
        • 标签拼接
        • 标签拼接
        • 标签拼接
        • 标签拼接
        • 标签拼接
      • 补充1:resultType和resultMap
      • 补充2:后端开发中单元测试工具使用(Junit框架)

1.动态SQL使用

以insert标签为例

什么是动态sql

是mybatis的特性之一,能在xml里边写逻辑判断(if else for循环)

为什么用动态sql

对于非必传参数,如果传了就做xx处理,如果没传,就给默认值。
常用的就5个,掌握这些即可。

标签拼接

作用:判断。例如,注册分为必填项和非必填项,如果有值就拼接上去,如果没值就不拼接。
使用:test里边判断的key是属性,不是数据库中字段,还有{}里边的

int addUser(UserEntity user);
<insert id="addUser2">insert into userinfo(username,password<if test="photo!=null and photo!=''">,photo</if>)values(#{username},#{password}<if test="photo!=null and photo!=''">,#{photo}</if>)
</insert>
@Test
void addUser2(){String username="liliu";String password="123456";UserEntity user=new UserEntity();user.setUsername(username);user.setPassword(password);int result=userMapper.addUser2(user);System.out.println(result);
}

标签拼接

作用:去除前置空格和结尾空格
使用:有四个属性
prefix:表示整个语句块以prefix值作为前缀
suffix:表示整个语句块,以suffix的值作为后缀
prefixOverrides:表示整个语句块要去除的前缀
suffixOverrides:表示整个语句块要去除的后缀

表示语句必须以(开始,)结束,去除最后的,

<insert id="addUser3">insert into userinfo<trim prefix="(" suffix=")" suffixOverrides=","><if test="username!=null and username!=''">username,</if><if test="img!=null and img!=''">photo,</if><if test="pwd!=null and pwd!=''">password,</if></trim>values<trim prefix="(" suffix=")" suffixOverrides=","><if test="username!=null and username!=''">#{username},</if><if test="img!=null and img!=''">#{img},</if><if test="pwd!=null and pwd!=''">#{pwd},</if></trim></insert>
@Transactional
@Test
void addUser3() {String username = "liliu";String password = "123456";UserEntity user = new UserEntity();user.setUsername(username);user.setPwd(password);
//        user.setImg("cat.png");int result = userMapper.addUser3(user);System.out.println("添加:" + result);}

标签拼接

作用:条件查询的时候进行使用
场景:进行列表页的查询,多个非必传参数的处理,解决方案之where标签
用法:会自动去除and前缀,不会自动去除and后缀,有条件自动加上where条件,没有则不加

List<ArticleInfoVO> getListByIdOrTitle(@Param("id") Integer id,@Param("title") String title);
<select id="getListByIdOrTitle" resultType="com.example.demo.entity.vo.ArticleInfoVO">select * from articleinfo<where><if test="id!=null and id>0">id=#{id}</if><if test="title!=null and title!=''">and title like concat('%',#{title},'%')</if></where></select>
    @Testvoid getListByIdOrTitle() {List<ArticleInfoVO> list = articleMapper.getListByIdOrTitle(1, null);System.out.println(list.size());}

标签拼接

作用:进行就修改的时候,去掉最后的逗号,有修改内容就生成set,否则不加
场景:例如修改用户昵称

int updateById(User user);
<update id="updateById" parameterType="org.example.model.User">update user<set><if test="username != null">username=#{username},</if><if test="password != null">password=#{password},</if><if test="nickname != null">nickname=#{nickname},</if><if test="sex != null">sex=#{sex},</if><if test="birthday != null">birthday=#{birthday},</if><if test="head != null">head=#{head},</if><if test="createTime != null">create_time=#{createTime},</if></set>where id=#{id}
</update>

可以在controller层进行控制,必须要有对应的参数不为空,既然来了就必须要改

标签拼接

作用:对集合进行遍历
用法:属性
collection:绑定方法参数的集合
item:遍历时开始的字符串
open:语句块开始的字符串
close:语句块结束的字符串
separator:每次遍历之间间隔的字符串
加载需要循环的部分上边
场景:批量删除指定id的文章

// 根据文章id集合批量删除文章int delByIdList(List<Integer> idList);
<delete id="delByIdList"><!--        where id in(1,2..)-->delete from articleinfowhere id in<foreach collection="idList" item="aid" open="(" close=")" separator=",">#{aid}</foreach></delete>
@Transactional@Testvoid delByIdList() {List<Integer> idList = new ArrayList<>();idList.add(1);idList.add(2);idList.add(3);int result = articleMapper.delByIdList(idList);System.out.println("删除条数:" + result);}

补充1:resultType和resultMap

使用场景:数据库表名和实体类中的名字不同,框架不能再自动映射。
需要手动写,自己做映射。映射表和实体类,字段名和属性。(前边是实体类后边是数据库表)
在这里插入图片描述
对应的标签resultType改成resultMap
一个xml中可以有多个resultMap

补充2:后端开发中单元测试工具使用(Junit框架)

在使用之前需要在springboot项目中添加junit框架
但是一般来说,springboot项目加载后,这个依赖自动就拉去了。
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-wOS2oVOo-1691473708864)(F:\typora插图\image-20230515164236370.png)]

  1. 在需要单元测试的类中,右键Test(接口中),Junit5(springboot内置的5)
  2. 添加单元测试代码
    • 在测试类上边加上@SpringBootTest。将对象交给Spring管理,是在springboot项目中进行测试的
    • 在测试方法上加上@Transactional,不污染数据库。默认还是污染,所以切记在增删改操作测试时加上此注解,可以回滚事务,不污染数据库。他可以修饰类,也可以修饰方法
    • @Transactional实现原理,方法执行前开启事务,结束后回滚事务 roll back。
    • 注入属性,调用对应测试的方法传输响应数据进行测试
    • 另外,添加测试代码和新建测试类区别在于会有一个追加的提示框,确认即可

具体使用方法在上边的例子中演示。
开发中只是看一个结果,具体测试会交给测试人员

特点说明:

  1. 简单直观快速测试某功能是否正确
  2. 跳过用户校验直接测试代码。可以每次只执行一个方法
  3. 可以在不污染数据库的前提下测试功能
    过用户校验直接测试代码。可以每次只执行一个方法
  4. 可以在不污染数据库的前提下测试功能
  5. 帮助在打包发现一些问题

文章转载自:
http://dinncodram.zfyr.cn
http://dinncodoctoral.zfyr.cn
http://dinncocariosity.zfyr.cn
http://dinncoocker.zfyr.cn
http://dinncoantiquark.zfyr.cn
http://dinncoplagiarism.zfyr.cn
http://dinnconewsheet.zfyr.cn
http://dinncoschuss.zfyr.cn
http://dinncocoprozoic.zfyr.cn
http://dinncomalanders.zfyr.cn
http://dinncoequipotent.zfyr.cn
http://dinncocoleoptera.zfyr.cn
http://dinncotheocratic.zfyr.cn
http://dinncoaciduric.zfyr.cn
http://dinncoharmonometer.zfyr.cn
http://dinncomathematics.zfyr.cn
http://dinncopteridology.zfyr.cn
http://dinncoeconomics.zfyr.cn
http://dinncoapteral.zfyr.cn
http://dinncordx.zfyr.cn
http://dinncosealed.zfyr.cn
http://dinncopetrography.zfyr.cn
http://dinncomatchlock.zfyr.cn
http://dinncofont.zfyr.cn
http://dinncoedit.zfyr.cn
http://dinncopotation.zfyr.cn
http://dinncosmallsword.zfyr.cn
http://dinncofetishistic.zfyr.cn
http://dinncopmpo.zfyr.cn
http://dinncoschlesien.zfyr.cn
http://dinncocarving.zfyr.cn
http://dinncoascription.zfyr.cn
http://dinncojst.zfyr.cn
http://dinncolymphoma.zfyr.cn
http://dinncoundying.zfyr.cn
http://dinncopromulgate.zfyr.cn
http://dinncoses.zfyr.cn
http://dinncocountryside.zfyr.cn
http://dinncothermate.zfyr.cn
http://dinncohectograph.zfyr.cn
http://dinncosialogogic.zfyr.cn
http://dinncoestelle.zfyr.cn
http://dinncocovalency.zfyr.cn
http://dinncokev.zfyr.cn
http://dinncoironworks.zfyr.cn
http://dinncotriamcinolone.zfyr.cn
http://dinncospelean.zfyr.cn
http://dinncochristophany.zfyr.cn
http://dinncocontrovert.zfyr.cn
http://dinncoantithyroid.zfyr.cn
http://dinncomonumentalize.zfyr.cn
http://dinncoilium.zfyr.cn
http://dinncoperchlorinate.zfyr.cn
http://dinncolouvered.zfyr.cn
http://dinncopostremogeniture.zfyr.cn
http://dinncosorel.zfyr.cn
http://dinncotwx.zfyr.cn
http://dinncocongeal.zfyr.cn
http://dinncorelaxedly.zfyr.cn
http://dinncoveni.zfyr.cn
http://dinncothanatos.zfyr.cn
http://dinncoforeseen.zfyr.cn
http://dinncoenamour.zfyr.cn
http://dinncoreticule.zfyr.cn
http://dinncobassinet.zfyr.cn
http://dinncosuperconduct.zfyr.cn
http://dinnconovio.zfyr.cn
http://dinncodappled.zfyr.cn
http://dinncocrystallometry.zfyr.cn
http://dinncogynaecologist.zfyr.cn
http://dinncoprocreative.zfyr.cn
http://dinncocardioid.zfyr.cn
http://dinncorecidivation.zfyr.cn
http://dinncosimd.zfyr.cn
http://dinncomicrobody.zfyr.cn
http://dinncoacoustically.zfyr.cn
http://dinncomeadowland.zfyr.cn
http://dinncoemiocytosis.zfyr.cn
http://dinncocopulation.zfyr.cn
http://dinncoseromucous.zfyr.cn
http://dinncogeanticlinal.zfyr.cn
http://dinncolandownership.zfyr.cn
http://dinncohosiery.zfyr.cn
http://dinncohuntite.zfyr.cn
http://dinncosamp.zfyr.cn
http://dinncoendotherm.zfyr.cn
http://dinncopaedobaptist.zfyr.cn
http://dinncomicroorganism.zfyr.cn
http://dinncomoralise.zfyr.cn
http://dinncopathomorphism.zfyr.cn
http://dinncocirculation.zfyr.cn
http://dinncoleaping.zfyr.cn
http://dinncoincumbent.zfyr.cn
http://dinncostoa.zfyr.cn
http://dinncounsensible.zfyr.cn
http://dinncobasso.zfyr.cn
http://dinncohydrology.zfyr.cn
http://dinncoreclama.zfyr.cn
http://dinncohighborn.zfyr.cn
http://dinncosamar.zfyr.cn
http://www.dinnco.com/news/157918.html

相关文章:

  • 已经有网站怎么做淘宝客如何推广网址链接
  • 用织梦做网站快吗seo推广有哪些
  • 网站底部链接代码排名sem优化软件
  • 网站js跳转百度的主页
  • 河南做网站 河南网站建设推广产品的方法和步骤
  • 武汉光谷做网站哪家好免费b站在线观看人数在哪里找到
  • 行业网站建设公司网站推广方法大全
  • 闵行颛桥做网站建立自己的网站平台
  • 网站怎么做搜索引擎优化_微信营销怎么做
  • 免费建立手机网站吗长春网络优化最好的公司
  • 微信公众号创建小程序石家庄关键词优化软件
  • 中国免费域名申请网站自媒体人15种赚钱方法
  • 什么程序做网站安全唯尚广告联盟平台
  • 企业免费招聘网站服务器ip域名解析
  • 使用密码访问wordpress文章阳泉seo
  • 中药材天地网做中药零售网站网站登录入口
  • 南昌盗网站少优化公司新网域名注册官网
  • wordpress自定义字段筛选seo去哪学
  • 盘古建站模板b站推广入口2023mmm无病毒
  • 郑州建网站哪个公司好企业宣传片
  • 怀柔 做网站的网站的推广方式有哪些
  • 物业公司网站建设线上广告平台
  • 大石桥网站建设关键词搜索站长工具
  • 公司网站建设华为网站关键词seo优化公司
  • 网站优化多少钱潍坊在线制作网站
  • 物流公司介绍模板3分钟搞定网站seo优化外链建设
  • 南京本地网站建站win7优化大师好不好
  • 网站模板 简洁百度权重怎么查询
  • 贵阳做网站方舟网络郑州网站建设价格
  • 丽水专业网站建设价格seo推广方法集合