feat(手机端): 搜索模块

添加搜索记录基础代码
master
wayn 4 years ago
parent 76fdc21c7f
commit 078ea5977b

@ -1,13 +1,14 @@
package com.wayn.mobile.api.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wayn.common.base.BaseController;
import com.wayn.common.util.R;
import com.wayn.mobile.api.domain.SearchHistory;
import com.wayn.mobile.api.service.ISearchHistoryService;
import com.wayn.mobile.framework.security.util.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
* <p>
@ -28,4 +29,23 @@ public class SearchHistoryController extends BaseController {
public R list() {
return R.success().add("data", iSearchHistoryService.selectList());
}
@PostMapping
public R add(@RequestBody SearchHistory searchHistory) {
Long memberId = SecurityUtils.getUserId();
searchHistory.setUserId(memberId);
return R.result(iSearchHistoryService.save(searchHistory));
}
@DeleteMapping("{id}")
public R delete(@PathVariable Long id) {
return R.result(iSearchHistoryService.removeById(id));
}
@DeleteMapping("all")
public R delete() {
Long memberId = SecurityUtils.getUserId();
return R.result(iSearchHistoryService.remove(new QueryWrapper<SearchHistory>().eq("user_id", memberId)));
}
}

Loading…
Cancel
Save