|
|
@@ -0,0 +1,105 @@
|
|
|
+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.OpenWebsite;
|
|
|
+import com.zhiqiyun.open.core.models.user.OauthInfo;
|
|
|
+import com.zhiqiyun.open.core.service.OauthService;
|
|
|
+import com.zhiqiyun.open.core.service.OpenWebsiteService;
|
|
|
+import com.zhiqiyun.open.core.service.SequenceService;
|
|
|
+import com.zhiqiyun.open.mvc.Result;
|
|
|
+import com.zhiqiyun.open.mvc.params.QueryOpenWebsiteParam;
|
|
|
+import com.zhiqiyun.open.mvc.params.SaveOpenWebsiteParam;
|
|
|
+import com.zhiqiyun.open.utils.DateUtil;
|
|
|
+import com.zhiqiyun.open.utils.ServletContext;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+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;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@RestController
|
|
|
+@RequestMapping("/openWebsite")
|
|
|
+public class OpenWebsiteController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OpenWebsiteService openWebsiteService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SequenceService sequenceService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OauthService oauthService;
|
|
|
+
|
|
|
+ @Permission(value = "open.website.find", tags = "查询文旅数据开放网站")
|
|
|
+ @PostMapping("/findPage")
|
|
|
+ public Result findPage(@RequestBody QueryOpenWebsiteParam param) {
|
|
|
+
|
|
|
+ QueryWrapper<OpenWebsite> wrapper = new QueryWrapper<>();
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(param.getTitle())) {
|
|
|
+ wrapper.like("title", param.getTitle());
|
|
|
+ }
|
|
|
+ Page<OpenWebsite> page = param.getPage();
|
|
|
+ page.addOrder(OrderItem.desc("id"));
|
|
|
+
|
|
|
+ Page<OpenWebsite> resultData = this.openWebsiteService.page(page, wrapper);
|
|
|
+
|
|
|
+ return Result.instance(Result.Code.SUCCESS).setData(resultData);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Permission(value = "open.website.add", tags = "新建文旅数据开放网站")
|
|
|
+ @PostMapping("/save")
|
|
|
+ public Result save(@Valid @RequestBody SaveOpenWebsiteParam param) throws Exception {
|
|
|
+
|
|
|
+ OpenWebsite entity = new OpenWebsite();
|
|
|
+ BeanUtils.copyProperties(param, entity);
|
|
|
+
|
|
|
+ OauthInfo oauthInfo = this.oauthService.getAuth(ServletContext.getAccessToken());
|
|
|
+
|
|
|
+ entity.setCreatedTime(DateUtil.current());
|
|
|
+ entity.setCreatedBy(oauthInfo.getId());
|
|
|
+
|
|
|
+ entity.setUpdatedTime(DateUtil.current());
|
|
|
+ entity.setUpdatedBy(oauthInfo.getId());
|
|
|
+ entity.setId(this.sequenceService.nextId());
|
|
|
+
|
|
|
+ this.openWebsiteService.save(entity);
|
|
|
+
|
|
|
+ return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Permission(value = "open.website.edit", tags = "更新文旅数据开放网站")
|
|
|
+ @PostMapping("/updateById")
|
|
|
+ public Result updateById(Long id, @Valid @RequestBody SaveOpenWebsiteParam param) {
|
|
|
+ OpenWebsite entity = new OpenWebsite();
|
|
|
+ BeanUtils.copyProperties(param, entity);
|
|
|
+
|
|
|
+ OauthInfo oauthInfo = this.oauthService.getAuth(ServletContext.getAccessToken());
|
|
|
+
|
|
|
+ entity.setUpdatedBy(oauthInfo.getId());
|
|
|
+ entity.setUpdatedTime(DateUtil.current());
|
|
|
+ entity.setId(id);
|
|
|
+
|
|
|
+ this.openWebsiteService.updateById(entity);
|
|
|
+
|
|
|
+ return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Permission(value = "open.website.delete", tags = "删除文旅数据开放网站")
|
|
|
+ @PostMapping("/deleteByIds")
|
|
|
+ public Result deleteByIds(@RequestBody List<Long> ids) {
|
|
|
+ this.openWebsiteService.removeByIds(ids);
|
|
|
+ return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|