From efdb99f8cecc4afb592afad79c761081d5d5cf22 Mon Sep 17 00:00:00 2001
From: lee <4766465@qq.com>
Date: Wed, 18 Dec 2024 13:27:00 +0800
Subject: [PATCH] init

---
 yami-shop-api/src/main/java/com/yami/shop/api/controller/AgentController.java |  100 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 100 insertions(+), 0 deletions(-)

diff --git a/yami-shop-api/src/main/java/com/yami/shop/api/controller/AgentController.java b/yami-shop-api/src/main/java/com/yami/shop/api/controller/AgentController.java
new file mode 100644
index 0000000..3962de7
--- /dev/null
+++ b/yami-shop-api/src/main/java/com/yami/shop/api/controller/AgentController.java
@@ -0,0 +1,100 @@
+package com.yami.shop.api.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.yami.shop.bean.model.Agent;
+import com.yami.shop.common.annotation.SysLog;
+import com.yami.shop.common.response.ServerResponseEntity;
+import com.yami.shop.common.util.PageParam;
+import com.yami.shop.service.AgentService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.AllArgsConstructor;
+import org.springdoc.api.annotations.ParameterObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import java.util.List;
+
+@RestController
+@AllArgsConstructor
+@RequestMapping("/p/agent")
+@Tag(name = "代理商接口")
+public class AgentController {
+    @Autowired
+    private AgentService agentService;
+
+    /**
+     * 查询代理商列表
+     */
+    @GetMapping("/getAgentList")
+    @Operation(summary = "查询代理商列表" , description = "查询代理商列表")
+    public ServerResponseEntity<List<Agent>> getAgentList(){
+        return ServerResponseEntity.success(agentService.list());
+    }
+
+    /**
+     * 分页查询
+     * @param page 分页对象
+     * @param agent
+     * @return 分页数据
+     */
+    @GetMapping("/page" )
+    @Operation(summary = "分页查询" , description = "分页查询")
+    public ServerResponseEntity<IPage<Agent>> getPurchaseProdPage(PageParam<Agent> page, @ParameterObject Agent agent) {
+        return ServerResponseEntity.success(agentService.page(page, new LambdaQueryWrapper<Agent>()));
+    }
+
+
+    /**
+     * 通过id查询
+     * @param agentId id
+     * @return 单个数据
+     */
+    @GetMapping("/info/{agentId}" )
+    @Operation(summary = "通过id查询" , description = "通过id查询")
+    public ServerResponseEntity<Agent> getById(@PathVariable("agentId") Long agentId) {
+        return ServerResponseEntity.success(agentService.getById(agentId));
+    }
+
+    /**
+     * 新增
+     * @param agent
+     * @return 是否新增成功
+     */
+    @SysLog("新增" )
+    @PostMapping
+    @PreAuthorize("@pms.hasPermission('api:agent:save')" )
+    @Operation(summary = "新增" , description = "新增")
+    public ServerResponseEntity<Boolean> save(@RequestBody @Valid Agent agent) {
+        return ServerResponseEntity.success(agentService.save(agent));
+    }
+
+    /**
+     * 修改
+     * @param agent
+     * @return 是否修改成功
+     */
+    @SysLog("修改" )
+    @PutMapping
+    @PreAuthorize("@pms.hasPermission('api:agent:update')" )
+    @Operation(summary = "修改" , description = "修改")
+    public ServerResponseEntity<Boolean> updateById(@RequestBody @Valid Agent agent) {
+        return ServerResponseEntity.success(agentService.updateById(agent));
+    }
+
+    /**
+     * 通过id删除
+     * @param agentId id
+     * @return 是否删除成功
+     */
+    @SysLog("删除" )
+    @DeleteMapping("/{agentId}" )
+    @PreAuthorize("@pms.hasPermission('api:agent:delete')" )
+    @Operation(summary = "通过id删除" , description = "通过id删除")
+    public ServerResponseEntity<Boolean> removeById(@PathVariable Long agentId) {
+        return ServerResponseEntity.success(agentService.removeById(agentId));
+    }
+}

--
Gitblit v1.9.3