|
@@ -0,0 +1,135 @@
|
|
|
+package com.platform.rest.controller.custom;
|
|
|
+
|
|
|
+import com.platform.common.bean.AbstractPageResultBean;
|
|
|
+import com.platform.common.util.BeanConverterUtil;
|
|
|
+import com.platform.common.util.R;
|
|
|
+import com.platform.common.validation.group.AddGroup;
|
|
|
+import com.platform.common.validation.group.UpdateGroup;
|
|
|
+import com.platform.dao.dto.custom.CustomRelationDTO;
|
|
|
+import com.platform.dao.entity.custom.CustomRelation;
|
|
|
+import com.platform.dao.util.ExcelUtil;
|
|
|
+import com.platform.dao.vo.export.custom.ExportCustomRelationVO;
|
|
|
+import com.platform.dao.vo.query.custom.CustomRelationVO;
|
|
|
+import com.platform.rest.log.annotation.SysLog;
|
|
|
+import com.platform.service.custom.CustomRelationService;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description 默认关联 控制器
|
|
|
+ * @Author lsq
|
|
|
+ * @Date 2024-08-06 15:54:26
|
|
|
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@AllArgsConstructor
|
|
|
+@RequestMapping("/custom/relation")
|
|
|
+public class CustomRelationController {
|
|
|
+
|
|
|
+ private final CustomRelationService customRelationService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id查询单条记录
|
|
|
+ *
|
|
|
+ * @param id 主键
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @GetMapping("/{id}")
|
|
|
+ public R<CustomRelation> getById(@PathVariable("id") String id) {
|
|
|
+ return new R<>(customRelationService.getModelById(id));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增记录
|
|
|
+ *
|
|
|
+ * @param customRelationDTO 默认关联DTO
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @SysLog("新增默认关联")
|
|
|
+ @PostMapping
|
|
|
+ public R save(@Validated({AddGroup.class}) @RequestBody CustomRelationDTO customRelationDTO) {
|
|
|
+ return new R<>(customRelationService.saveModelByDTO(customRelationDTO));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改记录
|
|
|
+ *
|
|
|
+ * @param customRelationDTO 默认关联DTO
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @SysLog("修改默认关联")
|
|
|
+ @PutMapping("/{id}")
|
|
|
+ public R update(@PathVariable("id") String id, @Validated({UpdateGroup.class}) @RequestBody CustomRelationDTO customRelationDTO) {
|
|
|
+ customRelationService.modModelByDTO(customRelationDTO);
|
|
|
+ return new R<>();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过id删除一条记录
|
|
|
+ *
|
|
|
+ * @param id 主键
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @SysLog("删除默认关联")
|
|
|
+ @DeleteMapping("/{id}")
|
|
|
+ public R removeById(@PathVariable String id) {
|
|
|
+ customRelationService.deleteByPrimaryKey(id);
|
|
|
+ return new R<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量记录
|
|
|
+ *
|
|
|
+ * @param ids 主键
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @SysLog("批量删除默认关联")
|
|
|
+ @DeleteMapping("")
|
|
|
+ public R removeIds(@RequestBody List<String> ids) {
|
|
|
+ customRelationService.batchDelete(ids);
|
|
|
+ return new R<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取分页
|
|
|
+ *
|
|
|
+ * @param pageNum 当前页码
|
|
|
+ * @param pageSize 每页条数
|
|
|
+ * @param customRelationDTO 默认关联DTO
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @GetMapping("/page")
|
|
|
+ public R<AbstractPageResultBean<CustomRelationVO>> query(CustomRelationDTO customRelationDTO, @RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "20") int pageSize) {
|
|
|
+ return new R<>(customRelationService.selectPageList(customRelationDTO, pageNum, pageSize));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取列表
|
|
|
+ *
|
|
|
+ * @param customRelationDTO 默认关联DTO
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @GetMapping("")
|
|
|
+ public R query(CustomRelationDTO customRelationDTO) {
|
|
|
+ return new R<>(customRelationService.getModelListByDTO(customRelationDTO));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 默认关联导出
|
|
|
+ *
|
|
|
+ * @param customRelationDTO 默认关联DTO
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @GetMapping("/export")
|
|
|
+ @SysLog("默认关联导出")
|
|
|
+ public void export(HttpServletResponse response, CustomRelationDTO customRelationDTO) {
|
|
|
+ List<CustomRelation> list = customRelationService.getModelListByDTO(customRelationDTO);
|
|
|
+ ExcelUtil.exportResponseDict(response, ExportCustomRelationVO.class, BeanConverterUtil.copyListProperties(list, ExportCustomRelationVO.class), "默认关联");
|
|
|
+ }
|
|
|
+
|
|
|
+}
|