diff --git a/src/main/java/com/jjyu/controller/Activity.java b/src/main/java/com/jjyu/controller/Activity.java new file mode 100644 index 0000000000000000000000000000000000000000..96fa5618e55be617a6b4cf8486d1188175e56c75 --- /dev/null +++ b/src/main/java/com/jjyu/controller/Activity.java @@ -0,0 +1,39 @@ +package com.example.ljl.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.example.ljl.entity.Restaurant; +import com.example.ljl.service.RestaurantService; +import io.swagger.annotations.Api; +import org..beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +@Api(tags = "02.餐厅管理模块") +@RestController +@CrossOrigin(origins = "*") //实现跨域* +@RequestMapping(value = "/restaurant",method = {RequestMethod.GET,RequestMethod.POST,RequestMethod.DELETE,RequestMethod.OPTIONS}) +public class RestaurantController { + @Autowired + private RestaurantService restaurantService; + + @GetMapping("/address") + public ResponseEntity> getRestaurantsByAddress(@RequestParam String address){ + address = "二食堂三楼"; + List restaurants=restaurantService.findRestaurantByAddress(address); + return restaurants!=null && !restaurants.isEmpty() + ? ResponseEntity.ok(restaurants) + :ResponseEntity.notFound().build(); + } + + @GetMapping("/list") + public List list(){return restaurantService.getAllRestaurants();} + + @GetMapping("/pagelist") + public ResponseEntity> listRestaurants( + @RequestParam(defaultValue = "1") int page, + @RequestParam(defaultValue = "10") int size){ + IPage restaurantIPage = restaurantService.getRestaurantWithPagination(page,size); + return ResponseEntity.ok(restaurantIPage); + } +} \ No newline at end of file diff --git a/src/main/java/com/jjyu/entity/Activity.java b/src/main/java/com/jjyu/entity/Activity.java new file mode 100644 index 0000000000000000000000000000000000000000..19cc0e4f13b5127446bcfed2a6e59ad4138d6b8d --- /dev/null +++ b/src/main/java/com/jjyu/entity/Activity.java @@ -0,0 +1,11 @@ +package com.example.ljl.entity; + +import lombok.Data; + +@Data +public class Activity { + private Integer id; + private String title; + private String description; + private String location; +} \ No newline at end of file diff --git a/src/main/java/com/jjyu/service/ActivityService.java b/src/main/java/com/jjyu/service/ActivityService.java new file mode 100644 index 0000000000000000000000000000000000000000..23cab3064e3978de3f70d83ce2a2664e511a474a --- /dev/null +++ b/src/main/java/com/jjyu/service/ActivityService.java @@ -0,0 +1,12 @@ +package com.example.ljl.service; + +import com.example.ljl.entity.Activity; +import java.util.List; + +public interface ActivityService { + List findAll(); + List findByLocation(String location); + int insert(Activity activity); + int updateByLocation(Activity activity); + int deleteByLocation(String location); +} \ No newline at end of file diff --git a/src/main/java/com/jjyu/service/ActivityserviceMPL.java b/src/main/java/com/jjyu/service/ActivityserviceMPL.java new file mode 100644 index 0000000000000000000000000000000000000000..90ef3d57d4ce927e97423dbb93a03f3575ac20f3 --- /dev/null +++ b/src/main/java/com/jjyu/service/ActivityserviceMPL.java @@ -0,0 +1,41 @@ +package com.example.ljl.service.Impl; + +import com.example.ljl.entity.Activity; +import com.example.ljl.mapper.ActivityMapper; +import com.example.ljl.service.ActivityService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class ActivityServiceImpl implements ActivityService { + + @Autowired + private ActivityMapper activityMapper; + + @Override + public List findAll() { + return activityMapper.findAll(); + } + + @Override + public List findByLocation(String location) { + return activityMapper.findByLocation(location); + } + + @Override + public int insert(Activity activity) { + return activityMapper.insert(activity); + } + + @Override + public int updateByLocation(Activity activity) { + return activityMapper.updateByLocation(activity); + } + + @Override + public int deleteByLocation(String location) { + return activityMapper.deleteByLocation(location); + } +} \ No newline at end of file