|
|
@@ -0,0 +1,113 @@
|
|
|
+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.cultural.tourism.OrganizationInfo;
|
|
|
+import com.zhiqiyun.open.core.models.user.OauthInfo;
|
|
|
+import com.zhiqiyun.open.core.service.OauthService;
|
|
|
+import com.zhiqiyun.open.core.service.OrganizationInfoService;
|
|
|
+import com.zhiqiyun.open.core.service.SequenceService;
|
|
|
+import com.zhiqiyun.open.mvc.Result;
|
|
|
+import com.zhiqiyun.open.mvc.params.cultural.tourism.QueryOrganizationInfoParam;
|
|
|
+import com.zhiqiyun.open.mvc.params.cultural.tourism.SaveOrganizationInfoParam;
|
|
|
+import com.zhiqiyun.open.utils.DateUtil;
|
|
|
+import com.zhiqiyun.open.utils.ServletContext;
|
|
|
+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("/cultural/tourism/organization")
|
|
|
+public class OrganizationController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OrganizationInfoService organizationInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SequenceService sequenceService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OauthService oauthService;
|
|
|
+
|
|
|
+ @Permission(value = "cultural.tourism.organization.find", tags = "查询文旅机构")
|
|
|
+ @PostMapping("/findPage")
|
|
|
+ public Result findPage(@RequestBody QueryOrganizationInfoParam param) {
|
|
|
+
|
|
|
+ QueryWrapper<OrganizationInfo> wrapper = new QueryWrapper<>();
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(param.getName())) {
|
|
|
+ wrapper.like("name", param.getName());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(param.getSocialCode())) {
|
|
|
+ wrapper.like("social_code", param.getSocialCode());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(param.getLegalPersonName())) {
|
|
|
+ wrapper.like("legal_person_name", param.getLegalPersonName());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(param.getContacts())) {
|
|
|
+ wrapper.like("contacts", param.getContacts());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(param.getContactNumber())) {
|
|
|
+ wrapper.like("contact_number", param.getContactNumber());
|
|
|
+ }
|
|
|
+ Page<OrganizationInfo> page = param.getPage();
|
|
|
+ page.addOrder(OrderItem.desc("id"));
|
|
|
+
|
|
|
+ Page<OrganizationInfo> resultData = this.organizationInfoService.page(page, wrapper);
|
|
|
+
|
|
|
+ return Result.instance(Result.Code.SUCCESS).setData(resultData);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Permission(value = "cultural.tourism.organization.add", tags = "新建文旅机构")
|
|
|
+ @PostMapping("/save")
|
|
|
+ public Result save(@Valid @RequestBody SaveOrganizationInfoParam param) throws Exception {
|
|
|
+
|
|
|
+ OrganizationInfo entity = new OrganizationInfo();
|
|
|
+ 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.organizationInfoService.save(entity);
|
|
|
+
|
|
|
+ return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Permission(value = "cultural.tourism.organization.edit", tags = "更新文旅机构")
|
|
|
+ @PostMapping("/updateById")
|
|
|
+ public Result updateById(Long id, @Valid @RequestBody SaveOrganizationInfoParam param) {
|
|
|
+ OrganizationInfo entity = new OrganizationInfo();
|
|
|
+ BeanUtils.copyProperties(param, entity);
|
|
|
+
|
|
|
+ OauthInfo oauthInfo = this.oauthService.getAuth(ServletContext.getAccessToken());
|
|
|
+ entity.setUpdatedBy(oauthInfo.getId());
|
|
|
+ entity.setUpdatedTime(DateUtil.current());
|
|
|
+ entity.setId(id);
|
|
|
+
|
|
|
+ this.organizationInfoService.updateById(entity);
|
|
|
+
|
|
|
+ return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Permission(value = "cultural.tourism.organization.delete", tags = "删除文旅机构")
|
|
|
+ @PostMapping("/deleteByIds")
|
|
|
+ public Result deleteByIds(@RequestBody List<Long> ids) {
|
|
|
+ this.organizationInfoService.removeByIds(ids);
|
|
|
+ return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
+ }
|
|
|
+}
|