|
|
@@ -1,44 +1,102 @@
|
|
|
package com.zhiqiyun.open.mvc.manager.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
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.enmus.YN;
|
|
|
import com.zhiqiyun.open.core.models.app.AppKeyInfo;
|
|
|
import com.zhiqiyun.open.core.models.bz.VenueInfo;
|
|
|
+import com.zhiqiyun.open.core.service.SequenceService;
|
|
|
import com.zhiqiyun.open.core.service.VenueInfoService;
|
|
|
import com.zhiqiyun.open.mvc.Result;
|
|
|
-import com.zhiqiyun.open.mvc.manager.params.QueryAppKeyInfoParams;
|
|
|
import com.zhiqiyun.open.mvc.manager.params.QueryVenueInfoParams;
|
|
|
+import com.zhiqiyun.open.mvc.manager.params.SaveVenueInfoParams;
|
|
|
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;
|
|
|
+import java.util.function.Consumer;
|
|
|
+
|
|
|
@RestController
|
|
|
@RequestMapping("/bz/base/venue")
|
|
|
public class VenueInfoController {
|
|
|
|
|
|
- @Autowired
|
|
|
- private VenueInfoService venueInfoService;
|
|
|
+ @Autowired
|
|
|
+ private VenueInfoService venueInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SequenceService sequenceService;
|
|
|
+
|
|
|
+ @Permission(value = "bz.base.venue.find", tags = "查询场馆")
|
|
|
+ @PostMapping("/findPage")
|
|
|
+ public Result findPage(@RequestBody QueryVenueInfoParams params) {
|
|
|
+
|
|
|
+ QueryWrapper<VenueInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(params.getContactNumber())) {
|
|
|
+ queryWrapper.like("contact_number", params.getContactNumber());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(params.getKeyword())) {
|
|
|
+ queryWrapper.and(true, new Consumer<QueryWrapper<VenueInfo>>() {
|
|
|
+ @Override
|
|
|
+ public void accept(QueryWrapper<VenueInfo> venueInfoQueryWrapper) {
|
|
|
+ venueInfoQueryWrapper.like("name", params.getKeyword());
|
|
|
+ venueInfoQueryWrapper.or();
|
|
|
+ venueInfoQueryWrapper.like("brief", params.getKeyword());
|
|
|
+ venueInfoQueryWrapper.or();
|
|
|
+ venueInfoQueryWrapper.like("address", params.getKeyword());
|
|
|
+ venueInfoQueryWrapper.or();
|
|
|
+ venueInfoQueryWrapper.like("contacts", params.getKeyword());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ Page<VenueInfo> page = params.getPage();
|
|
|
+ page.addOrder(OrderItem.desc("id"));
|
|
|
+
|
|
|
+ Page<VenueInfo> resultData = this.venueInfoService.page(page, queryWrapper);
|
|
|
+
|
|
|
+ return Result.instance(Result.Code.SUCCESS).setData(resultData);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Permission(value = "bz.base.venue.add", tags = "保存场馆")
|
|
|
+ @PostMapping("/save")
|
|
|
+ public Result save(@Valid @RequestBody SaveVenueInfoParams params) {
|
|
|
+
|
|
|
+ VenueInfo venueInfo = new VenueInfo();
|
|
|
+ BeanUtils.copyProperties(params, venueInfo);
|
|
|
+ venueInfo.setId(this.sequenceService.nextId());
|
|
|
+ this.venueInfoService.save(venueInfo);
|
|
|
+
|
|
|
+ return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
+ }
|
|
|
|
|
|
- @Permission(value = "bz.base.venue.find", tags = "查询")
|
|
|
- @PostMapping("/findPage")
|
|
|
- public Result findPage(@RequestBody QueryVenueInfoParams params) {
|
|
|
+ @Permission(value = "bz.base.venue.edit", tags = "编辑场馆")
|
|
|
+ @PostMapping("/updateById")
|
|
|
+ public Result updateById(Long id, @Valid @RequestBody SaveVenueInfoParams params) {
|
|
|
|
|
|
- QueryWrapper<VenueInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+ VenueInfo venueInfo = new VenueInfo();
|
|
|
+ BeanUtils.copyProperties(params, venueInfo);
|
|
|
+ venueInfo.setId(id);
|
|
|
|
|
|
- if (StringUtils.isNotBlank(params.getContactNumber())) {
|
|
|
- queryWrapper.like("contact_number", params.getContactNumber());
|
|
|
- }
|
|
|
+ this.venueInfoService.updateById(venueInfo);
|
|
|
|
|
|
- Page<VenueInfo> page = params.getPage();
|
|
|
- page.addOrder(OrderItem.desc("id"));
|
|
|
+ return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
+ }
|
|
|
|
|
|
- Page<VenueInfo> resultData = this.venueInfoService.page(page, queryWrapper);
|
|
|
|
|
|
- return Result.instance(Result.Code.SUCCESS).setData(resultData);
|
|
|
- }
|
|
|
+ @Permission(value = "bz.base.venue.delete", tags = "删除场馆")
|
|
|
+ @PostMapping("/deleteByIds")
|
|
|
+ public Result deleteByIds(@RequestBody List<Long> ids) {
|
|
|
+ this.venueInfoService.removeByIds(ids);
|
|
|
+ return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
+ }
|
|
|
}
|