Today, two values of activity id and user id need to be transmitted from the front end to the back end, and the back end receives these two parameters and processes the corresponding values in the database according to the two parameters
The commonly used delete function has only one parameter, so the first time I use two parameters, I don’t know how to write the format. After trying several times, I finally know:
@ResponseBody
@GetMapping("/line/{aId}/{uId}")
public Result getUser(@PathVariable("aId") int aId, @PathVariable("uId") String uId){
SignInForm signInForm =signInFormService.getByAIdAndUId(aId,uId);
if(signInForm!=null){//存在
result.setSuccess("查询成功!",gson.toJson(signInForm));
}else{//不存在
result.setSuccess("没有找到相关数据!",null);
}
return result;
}
Full code:
- mapper layer
@Select("select * from signinform where aId = #{aId} and uId = #{uId}")
SignInForm selectByAIdAndUId(int aId, String uId);
- service interface
SignInForm getByAIdAndUId(int aId, String uId);
- serviceImpl class
public SignInForm getByAIdAndUId(int aId,String uId) {
return this.getBaseMapper().selectByAIdAndUId(aId,uId);
}
- AS front end (
DatabaseUtil.selectLineById("sign","line",aId,uId);