|
|
@@ -0,0 +1,98 @@
|
|
|
+package com.zhiqiyun.open.mvc.manager.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.SceneryInfo;
|
|
|
+import com.zhiqiyun.open.core.service.SceneryInfoService;
|
|
|
+import com.zhiqiyun.open.core.service.SequenceService;
|
|
|
+import com.zhiqiyun.open.mvc.Result;
|
|
|
+import com.zhiqiyun.open.mvc.manager.params.QuerySceneryInfoParams;
|
|
|
+import com.zhiqiyun.open.mvc.manager.params.SaveSceneryInfoParams;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+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/base/scenery")
|
|
|
+public class SceneryInfoController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SceneryInfoService sceneryInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SequenceService sequenceService;
|
|
|
+
|
|
|
+ @Permission(value = "bz.base.scenery.find", tags = "查询场馆")
|
|
|
+ @PostMapping("/findPage")
|
|
|
+ public Result findPage(@RequestBody QuerySceneryInfoParams params) {
|
|
|
+
|
|
|
+ QueryWrapper<SceneryInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(params.getContactNumber())) {
|
|
|
+ queryWrapper.like("contact_number", params.getContactNumber());
|
|
|
+ }
|
|
|
+ if (params.getGrade() != null) {
|
|
|
+ queryWrapper.like("grade", params.getGrade());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(params.getKeyword())) {
|
|
|
+ queryWrapper.and(true, sceneryInfoQueryWrapper -> {
|
|
|
+ sceneryInfoQueryWrapper.like("name", params.getKeyword());
|
|
|
+ sceneryInfoQueryWrapper.or();
|
|
|
+ sceneryInfoQueryWrapper.like("brief", params.getKeyword());
|
|
|
+ sceneryInfoQueryWrapper.or();
|
|
|
+ sceneryInfoQueryWrapper.like("address", params.getKeyword());
|
|
|
+ sceneryInfoQueryWrapper.or();
|
|
|
+ sceneryInfoQueryWrapper.like("contacts", params.getKeyword());
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ Page<SceneryInfo> page = params.getPage();
|
|
|
+ page.addOrder(OrderItem.desc("id"));
|
|
|
+
|
|
|
+ Page<SceneryInfo> resultData = this.sceneryInfoService.page(page, queryWrapper);
|
|
|
+
|
|
|
+ return Result.instance(Result.Code.SUCCESS).setData(resultData);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Permission(value = "bz.base.scenery.add", tags = "保存场馆")
|
|
|
+ @PostMapping("/save")
|
|
|
+ public Result save(@Valid @RequestBody SaveSceneryInfoParams params) {
|
|
|
+
|
|
|
+ SceneryInfo sceneryInfo = new SceneryInfo();
|
|
|
+ BeanUtils.copyProperties(params, sceneryInfo);
|
|
|
+ sceneryInfo.setId(this.sequenceService.nextId());
|
|
|
+ this.sceneryInfoService.save(sceneryInfo);
|
|
|
+
|
|
|
+ return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Permission(value = "bz.base.scenery.edit", tags = "编辑场馆")
|
|
|
+ @PostMapping("/updateById")
|
|
|
+ public Result updateById(Long id, @Valid @RequestBody SaveSceneryInfoParams params) {
|
|
|
+
|
|
|
+ SceneryInfo sceneryInfo = new SceneryInfo();
|
|
|
+ BeanUtils.copyProperties(params, sceneryInfo);
|
|
|
+ sceneryInfo.setId(id);
|
|
|
+
|
|
|
+ this.sceneryInfoService.updateById(sceneryInfo);
|
|
|
+
|
|
|
+ return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Permission(value = "bz.base.scenery.delete", tags = "删除场馆")
|
|
|
+ @PostMapping("/deleteByIds")
|
|
|
+ public Result deleteByIds(@RequestBody List<Long> ids) {
|
|
|
+ this.sceneryInfoService.removeByIds(ids);
|
|
|
+ return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
+ }
|
|
|
+}
|