|
@@ -1,9 +1,23 @@
|
|
|
package org.jeecg.modules.rooms.controller;
|
|
package org.jeecg.modules.rooms.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
|
+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.modules.rooms.DTO.CesGoodsUnitDto;
|
|
|
|
|
+import org.jeecg.modules.rooms.DTO.CesGoodsUnitSearchDto;
|
|
|
|
|
+import org.jeecg.modules.rooms.DTO.CesRoomLayoutRemoveDto;
|
|
|
|
|
+import org.jeecg.modules.rooms.service.CesGoodsUnitServiceImpl;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
-import org.springframework.stereotype.Controller;
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.Arrays;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* <p>
|
|
* <p>
|
|
@@ -13,9 +27,111 @@ import org.springframework.stereotype.Controller;
|
|
|
* @author Claude
|
|
* @author Claude
|
|
|
* @since 2023-03-08
|
|
* @since 2023-03-08
|
|
|
*/
|
|
*/
|
|
|
-@Controller
|
|
|
|
|
|
|
+@RestController
|
|
|
@RequestMapping("/rooms/cesGoodsUnit")
|
|
@RequestMapping("/rooms/cesGoodsUnit")
|
|
|
public class CesGoodsUnitController {
|
|
public class CesGoodsUnitController {
|
|
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private CesGoodsUnitServiceImpl cesGoodsUnitService;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /***
|
|
|
|
|
+ * 查询单位
|
|
|
|
|
+ * @param dto
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @ApiOperation(value="查询单位", notes="查询单位")
|
|
|
|
|
+ @GetMapping(value = "/list")
|
|
|
|
|
+ public Result list(CesGoodsUnitSearchDto dto){
|
|
|
|
|
+ if(StringUtils.isBlank(dto.getHotelId())){
|
|
|
|
|
+ return Result.error(ResultCode.PARAM_MISS);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(dto.getPageNo().intValue() <= 0){
|
|
|
|
|
+ return Result.error("页数不能小于等于0");
|
|
|
|
|
+ }
|
|
|
|
|
+ if(dto.getPageSize().intValue() < 10){
|
|
|
|
|
+ return Result.error("分页条数不能小于10");
|
|
|
|
|
+ }
|
|
|
|
|
+ try{
|
|
|
|
|
+ return cesGoodsUnitService.list(dto);
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ return Result.error(e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @AutoLog(value = "创建单位")
|
|
|
|
|
+ @ApiOperation(value="创建单位", notes="创建单位")
|
|
|
|
|
+ @PostMapping(value = "/save")
|
|
|
|
|
+ public Result create(@RequestBody CesGoodsUnitDto dto){
|
|
|
|
|
+ if(StringUtils.isBlank(dto.getHotelId())){
|
|
|
|
|
+ return Result.error(ResultCode.PARAM_MISS);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(StringUtils.isBlank(dto.getName())){
|
|
|
|
|
+ return Result.error(ResultCode.PARAM_MISS);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(dto.getState() == null){
|
|
|
|
|
+ return Result.error(ResultCode.PARAM_MISS);
|
|
|
|
|
+ }
|
|
|
|
|
+ try{
|
|
|
|
|
+ return cesGoodsUnitService.create(dto);
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ return Result.error(e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @AutoLog(value = "修改单位")
|
|
|
|
|
+ @ApiOperation(value="修改单位", notes="修改单位")
|
|
|
|
|
+ @PutMapping(value = "/modify")
|
|
|
|
|
+ public Result modifyCesRoomLayout(@RequestBody CesGoodsUnitDto dto){
|
|
|
|
|
+ if(StringUtils.isBlank(dto.getId())){
|
|
|
|
|
+ return Result.error(ResultCode.PARAM_MISS,"数据ID 必传!");
|
|
|
|
|
+ }
|
|
|
|
|
+ if(StringUtils.isBlank(dto.getHotelId())){
|
|
|
|
|
+ return Result.error(ResultCode.PARAM_MISS);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(StringUtils.isBlank(dto.getName())){
|
|
|
|
|
+ return Result.error(ResultCode.PARAM_MISS);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(dto.getState() == null){
|
|
|
|
|
+ return Result.error(ResultCode.PARAM_MISS);
|
|
|
|
|
+ }
|
|
|
|
|
+ try{
|
|
|
|
|
+ return cesGoodsUnitService.modify(dto);
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ return Result.error(e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @AutoLog(value = "删除单位")
|
|
|
|
|
+ @ApiOperation(value="删除单位", notes="删除单位")
|
|
|
|
|
+ @DeleteMapping(value = "/remove")
|
|
|
|
|
+ public Result remove(String id){
|
|
|
|
|
+ if(StringUtils.isBlank(id)){
|
|
|
|
|
+ return Result.error(ResultCode.PARAM_MISS,"数据ID 必传!");
|
|
|
|
|
+ }
|
|
|
|
|
+ try{
|
|
|
|
|
+ return cesGoodsUnitService.delete(id);
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ return Result.error(e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @AutoLog(value = "批量删除单位")
|
|
|
|
|
+ @ApiOperation(value="批量删除单位", notes="批量删除单位")
|
|
|
|
|
+ @PostMapping(value = "/deleteBatch")
|
|
|
|
|
+ public Result deleteBatch(String idsStr){
|
|
|
|
|
+ if(StringUtils.isBlank(idsStr)){
|
|
|
|
|
+ return Result.error(ResultCode.PARAM_MISS,"数据IDStr 必传!");
|
|
|
|
|
+ }
|
|
|
|
|
+ try{
|
|
|
|
|
+ List<String> ids = Arrays.stream(idsStr.split(",")).collect(Collectors.toList());
|
|
|
|
|
+ return cesGoodsUnitService.deleteBatch(ids);
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ return Result.error(e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|