|
|
@@ -0,0 +1,98 @@
|
|
|
+package com.zhiqiyun.open.mvc.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.zhiqiyun.open.annotation.Permission;
|
|
|
+import com.zhiqiyun.open.core.models.bz.PassengerEquipment;
|
|
|
+import com.zhiqiyun.open.core.models.user.OauthInfo;
|
|
|
+import com.zhiqiyun.open.core.service.OauthService;
|
|
|
+import com.zhiqiyun.open.core.service.PassengerEquipmentService;
|
|
|
+import com.zhiqiyun.open.core.service.SequenceService;
|
|
|
+import com.zhiqiyun.open.mvc.Result;
|
|
|
+import com.zhiqiyun.open.mvc.params.bz.QueryHotelInfoParams;
|
|
|
+import com.zhiqiyun.open.mvc.params.bz.QueryPassengerEquipmentParams;
|
|
|
+import com.zhiqiyun.open.mvc.params.bz.SaveHotelInfoParams;
|
|
|
+import com.zhiqiyun.open.mvc.params.bz.SavePassengerEquipmentParams;
|
|
|
+import com.zhiqiyun.open.utils.DateUtil;
|
|
|
+import com.zhiqiyun.open.utils.ServletContext;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/bz/passenger/equipment")
|
|
|
+public class PassengerEquipmentController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PassengerEquipmentService passengerEquipmentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SequenceService sequenceService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OauthService oauthService;
|
|
|
+
|
|
|
+ @Permission(value = "bz.base.hotel.find", tags = "查询酒店")
|
|
|
+ @PostMapping("/findPage")
|
|
|
+ public Result findPage(@RequestBody QueryPassengerEquipmentParams params) {
|
|
|
+
|
|
|
+ QueryWrapper<PassengerEquipment> queryWrapper = new QueryWrapper<>();
|
|
|
+
|
|
|
+ Page<PassengerEquipment> page = params.getPage();
|
|
|
+ page.addOrder(OrderItem.desc("id"));
|
|
|
+
|
|
|
+ Page<PassengerEquipment> resultData = this.passengerEquipmentService.page(page, queryWrapper);
|
|
|
+
|
|
|
+ return Result.instance(Result.Code.SUCCESS).setData(resultData);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Permission(value = "bz.base.hotel.add", tags = "保存酒店")
|
|
|
+ @PostMapping("/save")
|
|
|
+ public Result save(@Valid @RequestBody SavePassengerEquipmentParams params) {
|
|
|
+
|
|
|
+ this.passengerEquipmentService.save(this.buildEntity(this.sequenceService.nextId(), params));
|
|
|
+
|
|
|
+ return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Permission(value = "bz.base.hotel.edit", tags = "编辑酒店")
|
|
|
+ @PostMapping("/updateById")
|
|
|
+ public Result updateById(Long id, @Valid @RequestBody SavePassengerEquipmentParams params) {
|
|
|
+
|
|
|
+ this.passengerEquipmentService.updateById(this.buildEntity(id, params));
|
|
|
+
|
|
|
+ return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private PassengerEquipment buildEntity(Long id, @Valid SavePassengerEquipmentParams params) {
|
|
|
+
|
|
|
+ PassengerEquipment entity = new PassengerEquipment();
|
|
|
+
|
|
|
+ BeanUtils.copyProperties(params, entity);
|
|
|
+
|
|
|
+ OauthInfo oauthInfo = this.oauthService.getAuth(ServletContext.getAccessToken());
|
|
|
+
|
|
|
+ entity.setCreatedTime(DateUtil.current());
|
|
|
+ entity.setUpdatedTime(DateUtil.current());
|
|
|
+ entity.setCreatedBy(oauthInfo.getId());
|
|
|
+ entity.setUpdatedBy(oauthInfo.getId());
|
|
|
+
|
|
|
+ entity.setId(id);
|
|
|
+ return entity;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Permission(value = "bz.base.hotel.delete", tags = "删除酒店")
|
|
|
+ @PostMapping("/deleteByIds")
|
|
|
+ public Result deleteByIds(@RequestBody List<Long> ids) {
|
|
|
+ this.passengerEquipmentService.removeByIds(ids);
|
|
|
+ return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
+ }
|
|
|
+}
|