2022年7月12日 日志
2022年7月12日 日志
今天任务:完成p_test增删改查
下午已完成 ,
2022年7月12日早
Q1拦截器
请求接口时候没有登录,如何实现拦截器,拦截器如何测试?
p_test的数据库如图
p_test的实体类entity如图
对于controller设计和service设计如图
整正的装配,三步是,
-
xml集合了entity类和sql语句,装配到@Mapper的Mapper接口
-
@Mapper的Mapper接口写完,装配到了@Service的Service
-
@Srevice的Service装配到了@RestController
早上最后的中心放在mybatis的标签,以及@Mapper接口和entity&xml装配过程。
mybatis,mybatis-plus复习
本书第六章:与持久化有关的那些事
JavaEE开发mybatis核心配置
mybatis codeHelp 安装成功,大的要来了
练习基本功
xml主要元素
<mapper>
<cache>
<cache>
<cache-ref>
<select>
<insert>
<update>
<delete>
<sql>
<resultMap>
自己新建项目联系MyBatis元素,
记录一次成功Get请求,返回一条数据
在后端写好@GetMapping请求后,
@GetMapping("selectOne")
public Test2 selectOne(String id) {
return test2Service.selectByPrimaryKey(id);}
传入string 类型的id后会返回Test2实体类的 json数据。
由于token的存在,直接测试永远都是
<Response body is empty>
因此,可以写一个前端按钮发送Ajax,(axios)来实现测试
methods:{} 里面写方法aa(),用button调用
aa(){
const shuzi=Object.assign({
id:'0bc29ac4f2894f5b93c3933aa7831a2d'
})
selectOne(shuzi).then(res=>{
console.log(res)
})
}
< div > 里面写上
<button @click="aa">aaa</button>
这是成功界面
新建项目练习后端API开发