|
|
@@ -0,0 +1,147 @@
|
|
|
+package org.jeecg.modules.rooms.controller;
|
|
|
+
|
|
|
+
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.jeecg.common.Enum.ResultCode;
|
|
|
+import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
+import org.jeecg.common.system.base.controller.JeecgController;
|
|
|
+import org.jeecg.modules.rooms.DTO.CesHourRoomRuleModifyDto;
|
|
|
+import org.jeecg.modules.rooms.DTO.CesHousePriceSchemeDto;
|
|
|
+import org.jeecg.modules.rooms.DTO.CesHousePriceSchemeSearchDto;
|
|
|
+import org.jeecg.modules.rooms.entity.CesHousePriceScheme;
|
|
|
+import org.jeecg.modules.rooms.service.CesHousePriceSchemeServiceImpl;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 房价方案 前端控制器
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author Claude
|
|
|
+ * @since 2023-03-09
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/rooms/cesHousePriceScheme")
|
|
|
+@Api(tags = "ces_house_price_scheme")
|
|
|
+@Slf4j
|
|
|
+public class CesHousePriceSchemeController extends JeecgController<CesHousePriceScheme, CesHousePriceSchemeServiceImpl> {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ CesHousePriceSchemeServiceImpl cesHousePriceSchemeService;
|
|
|
+
|
|
|
+ @ApiOperation(value="房价方案查询", notes="房价方案查询")
|
|
|
+ @GetMapping(value = "/list")
|
|
|
+ public Result list(CesHousePriceSchemeSearchDto dto){
|
|
|
+ if (ObjectUtils.isEmpty(dto)){
|
|
|
+ return Result.error(ResultCode.PARAM_MISS);
|
|
|
+ }
|
|
|
+ if (0>=dto.getPageNo()){
|
|
|
+ return Result.error("页数不能小于等于0");
|
|
|
+ }
|
|
|
+ if (0>=dto.getPageSize()){
|
|
|
+ return Result.error("页码尺寸不能小于等于0");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(dto.getHotelId())){
|
|
|
+ return Result.error(ResultCode.PARAM_MISS);
|
|
|
+ }
|
|
|
+ try{
|
|
|
+ return cesHousePriceSchemeService.list(dto);
|
|
|
+ }catch (Exception e){
|
|
|
+ return Result.error(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @AutoLog(value = "新增房价方案")
|
|
|
+ @ApiOperation(value="新增房价方案", notes="新增房价方案")
|
|
|
+ @PostMapping(value = "/save")
|
|
|
+ public Result save(@RequestBody CesHousePriceSchemeDto dto){
|
|
|
+ if (ObjectUtils.isEmpty(dto)){
|
|
|
+ return Result.error(ResultCode.PARAM_MISS);
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(dto.getPriceScheme())){
|
|
|
+ return Result.error(ResultCode.PARAM_MISS);
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(dto.getSimpleCode())){
|
|
|
+ return Result.error(ResultCode.PARAM_MISS);
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(dto.getNumber())){
|
|
|
+ return Result.error(ResultCode.PARAM_MISS);
|
|
|
+ }
|
|
|
+ if (null==dto.getGuestSource()){
|
|
|
+ return Result.error(ResultCode.PARAM_MISS);
|
|
|
+ }
|
|
|
+ if (null==dto.getGuestType()){
|
|
|
+ return Result.error(ResultCode.PARAM_MISS);
|
|
|
+ }
|
|
|
+ if (null==dto.getCheckInTime()){
|
|
|
+ return Result.error(ResultCode.PARAM_MISS);
|
|
|
+ }else{
|
|
|
+ if (1==dto.getCheckInTime().intValue()){
|
|
|
+ //如果入住时间为时间段,就要判断时间的非空
|
|
|
+ if (null==dto.getStartTime()){ return Result.error(ResultCode.PARAM_MISS); }
|
|
|
+ if (null==dto.getEndTime()){ return Result.error(ResultCode.PARAM_MISS); }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (null==dto.getValidTime()){
|
|
|
+ return Result.error(ResultCode.PARAM_MISS);
|
|
|
+ }else{
|
|
|
+ if (1==dto.getValidTime().intValue()){
|
|
|
+ //如果有效期为时间段,就要判断时间的非空
|
|
|
+ if (null==dto.getValidStartTime()){ return Result.error(ResultCode.PARAM_MISS); }
|
|
|
+ if (null==dto.getValidEndTime()){ return Result.error(ResultCode.PARAM_MISS); }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (null==dto.getOpen()||(0!=dto.getOpen().intValue()&&1!=dto.getOpen().intValue())){
|
|
|
+ return Result.error(ResultCode.PARAM_MISS);
|
|
|
+ }
|
|
|
+ if (null==dto.getSort()||1>dto.getSort().intValue()){
|
|
|
+ return Result.error("排序不能为空且不能小于1!");
|
|
|
+ }
|
|
|
+ try{
|
|
|
+ return cesHousePriceSchemeService.create(dto);
|
|
|
+ }catch (Exception e){
|
|
|
+ return Result.error(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @AutoLog(value = "删除一条房价方案")
|
|
|
+ @ApiOperation(value="删除一条房价方案", notes="删除一条房价方案")
|
|
|
+ @DeleteMapping(value = "/delete")
|
|
|
+ public Result delete(@RequestParam String id){
|
|
|
+ if(StringUtils.isBlank(id)){
|
|
|
+ return Result.error(ResultCode.PARAM_MISS,"数据ID必传!");
|
|
|
+ }
|
|
|
+ try{
|
|
|
+ return cesHousePriceSchemeService.deleteOne(id);
|
|
|
+ }catch (Exception e){
|
|
|
+ return Result.error(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @AutoLog(value = "批量删除房价方案")
|
|
|
+ @ApiOperation(value="批量删除房价方案", notes="批量删除房价方案")
|
|
|
+ @DeleteMapping(value = "/batchDelete")
|
|
|
+ public Result batchDelete(@RequestParam String idStr){
|
|
|
+ if (StringUtils.isBlank(idStr)){
|
|
|
+ return Result.error(ResultCode.PARAM_MISS,"数据IDSTR必传!");
|
|
|
+ }
|
|
|
+ try{
|
|
|
+ List<String> ids = Stream.of(idStr.split(",")).collect(Collectors.toList());
|
|
|
+ return cesHousePriceSchemeService.batchDelete(ids);
|
|
|
+ }catch (Exception e){
|
|
|
+ return Result.error(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|