|
|
@@ -0,0 +1,95 @@
|
|
|
+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.TouristInfo;
|
|
|
+import com.zhiqiyun.open.core.service.SequenceService;
|
|
|
+import com.zhiqiyun.open.core.service.TouristInfoService;
|
|
|
+import com.zhiqiyun.open.mvc.Result;
|
|
|
+import com.zhiqiyun.open.mvc.params.QueryTouristInfoParams;
|
|
|
+import com.zhiqiyun.open.mvc.params.SaveTouristInfoParams;
|
|
|
+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/tourist")
|
|
|
+public class TouristInfoController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TouristInfoService touristInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SequenceService sequenceService;
|
|
|
+
|
|
|
+ @Permission(value = "bz.base.tourist.find", tags = "查询场馆")
|
|
|
+ @PostMapping("/findPage")
|
|
|
+ public Result findPage(@RequestBody QueryTouristInfoParams params) {
|
|
|
+
|
|
|
+ QueryWrapper<TouristInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(params.getContactNumber())) {
|
|
|
+ queryWrapper.like("contact_number", params.getContactNumber());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(params.getKeyword())) {
|
|
|
+ queryWrapper.and(true, wrapper -> {
|
|
|
+ wrapper.like("name", params.getKeyword());
|
|
|
+ wrapper.or();
|
|
|
+ wrapper.like("brief", params.getKeyword());
|
|
|
+ wrapper.or();
|
|
|
+ wrapper.like("address", params.getKeyword());
|
|
|
+ wrapper.or();
|
|
|
+ wrapper.like("contacts", params.getKeyword());
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ Page<TouristInfo> page = params.getPage();
|
|
|
+ page.addOrder(OrderItem.desc("id"));
|
|
|
+
|
|
|
+ Page<TouristInfo> resultData = this.touristInfoService.page(page, queryWrapper);
|
|
|
+
|
|
|
+ return Result.instance(Result.Code.SUCCESS).setData(resultData);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Permission(value = "bz.base.tourist.add", tags = "保存场馆")
|
|
|
+ @PostMapping("/save")
|
|
|
+ public Result save(@Valid @RequestBody SaveTouristInfoParams params) {
|
|
|
+
|
|
|
+ TouristInfo touristInfo = new TouristInfo();
|
|
|
+ BeanUtils.copyProperties(params, touristInfo);
|
|
|
+ touristInfo.setId(this.sequenceService.nextId());
|
|
|
+ this.touristInfoService.save(touristInfo);
|
|
|
+
|
|
|
+ return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Permission(value = "bz.base.tourist.edit", tags = "编辑场馆")
|
|
|
+ @PostMapping("/updateById")
|
|
|
+ public Result updateById(Long id, @Valid @RequestBody SaveTouristInfoParams params) {
|
|
|
+
|
|
|
+ TouristInfo touristInfo = new TouristInfo();
|
|
|
+ BeanUtils.copyProperties(params, touristInfo);
|
|
|
+ touristInfo.setId(id);
|
|
|
+
|
|
|
+ this.touristInfoService.updateById(touristInfo);
|
|
|
+
|
|
|
+ return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Permission(value = "bz.base.tourist.delete", tags = "删除场馆")
|
|
|
+ @PostMapping("/deleteByIds")
|
|
|
+ public Result deleteByIds(@RequestBody List<Long> ids) {
|
|
|
+ this.touristInfoService.removeByIds(ids);
|
|
|
+ return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
+ }
|
|
|
+}
|