| New file |
| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.BaseModel; |
| | | import com.ruoyi.common.core.domain.BasePage; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.model.TAssistedDining; |
| | | import com.ruoyi.system.model.THelpNeeds; |
| | | import com.ruoyi.system.model.TPartyBuilding; |
| | | import com.ruoyi.system.query.AssistedDiningListQuery; |
| | | import com.ruoyi.system.service.TAssistedDiningService; |
| | | import com.ruoyi.system.service.THelpNeedsService; |
| | | import com.ruoyi.system.service.TPartyBuildingService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/pension") |
| | | @Api(tags = "养老服务") |
| | | public class PensionController { |
| | | |
| | | private final TAssistedDiningService tAssistedDiningService; |
| | | private final THelpNeedsService tHelpNeedsService; |
| | | private final TokenService tokenService; |
| | | |
| | | public PensionController(TAssistedDiningService tAssistedDiningService, THelpNeedsService tHelpNeedsService, TokenService tokenService) { |
| | | this.tAssistedDiningService = tAssistedDiningService; |
| | | this.tHelpNeedsService = tHelpNeedsService; |
| | | this.tokenService = tokenService; |
| | | } |
| | | |
| | | |
| | | @PostMapping("/getAssistedDiningList") |
| | | @ApiOperation(value = "养老服务--助餐",response = TAssistedDining.class) |
| | | public R<PageInfo<TAssistedDining>> getAssistedDiningList(@RequestBody AssistedDiningListQuery query) { |
| | | PageInfo<TAssistedDining> pageInfo = tAssistedDiningService.pageList(query); |
| | | return R.ok(pageInfo); |
| | | } |
| | | |
| | | @PostMapping("/getAssistedDiningDetail/{id}") |
| | | @ApiOperation(value = "养老服务--助餐详情") |
| | | public R<TAssistedDining> getAssistedDiningDetail(@PathVariable String id) { |
| | | TAssistedDining tAssistedDining = tAssistedDiningService.getById(id); |
| | | return R.ok(tAssistedDining); |
| | | } |
| | | |
| | | |
| | | |
| | | @PostMapping("/getHelpNeedsList") |
| | | @ApiOperation(value = "养老服务--助需",response = TPartyBuilding.class) |
| | | public R<Page<THelpNeeds>> getHelpNeedsList(@RequestBody BasePage basePage) { |
| | | String userId = tokenService.getLoginUserApplet().getUserId(); |
| | | Page<THelpNeeds> page = new Page<>(basePage.getPageNum(), basePage.getPageSize()); |
| | | Page<THelpNeeds> helpNeedsPage = tHelpNeedsService.page(page, Wrappers.<THelpNeeds>lambdaQuery().eq(THelpNeeds::getAppUserId, userId).orderByDesc(BaseModel::getCreateTime)); |
| | | return R.ok(helpNeedsPage); |
| | | } |
| | | |
| | | @PostMapping("/addHelpNeeds") |
| | | @ApiOperation(value = "养老服务--添加助需") |
| | | public R<String> addHelpNeeds(@RequestBody THelpNeeds tHelpNeeds) { |
| | | String userId = tokenService.getLoginUserApplet().getUserId(); |
| | | tHelpNeeds.setAppUserId(userId); |
| | | boolean save = tHelpNeedsService.save(tHelpNeeds); |
| | | if (save) { |
| | | return R.ok("添加成功"); |
| | | } |
| | | return R.fail("添加失败"); |
| | | } |
| | | } |