diff --git a/ghy-admin/pom.xml b/ghy-admin/pom.xml index ad5ca01f..07cc6251 100644 --- a/ghy-admin/pom.xml +++ b/ghy-admin/pom.xml @@ -143,6 +143,10 @@ spring-test test + + com.ghy + ghy-shop + diff --git a/ghy-admin/src/main/java/com/ghy/web/controller/ShopController.java b/ghy-admin/src/main/java/com/ghy/web/controller/ShopController.java index 1f848e8a..cde2f668 100644 --- a/ghy-admin/src/main/java/com/ghy/web/controller/ShopController.java +++ b/ghy-admin/src/main/java/com/ghy/web/controller/ShopController.java @@ -1,9 +1,11 @@ package com.ghy.web.controller; +import com.ghy.common.core.controller.BaseController; import com.ghy.shop.domain.Shop; import com.ghy.shop.service.ShopService; +import com.ghy.common.core.domain.AjaxResult; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import java.util.List; @@ -12,38 +14,34 @@ import java.util.List; */ @RestController @RequestMapping("/shop") -public class ShopController { +public class ShopController extends BaseController { @Autowired private ShopService shopService; @PostMapping("/add") - public ResponseEntity addShop(@RequestBody Shop shop) { - Shop result = shopService.addShop(shop); - return ResponseEntity.ok(result); + public AjaxResult addShop(@RequestBody Shop shop) { + return toAjax(shopService.addShop(shop)); } @GetMapping("/list") - public ResponseEntity> listShops() { - return ResponseEntity.ok(shopService.listShops()); + public AjaxResult listShops() { + List list = shopService.listShops(); + return AjaxResult.success(list); } @GetMapping("/{id}") - public ResponseEntity getShop(@PathVariable Long id) { + public AjaxResult getShop(@PathVariable Long id) { Shop shop = shopService.getShop(id); - if (shop == null) return ResponseEntity.notFound().build(); - return ResponseEntity.ok(shop); + return shop != null ? AjaxResult.success(shop) : AjaxResult.error("未找到店铺"); } @PostMapping("/update") - public ResponseEntity updateShop(@RequestBody Shop shop) { - Shop result = shopService.updateShop(shop); - if (result == null) return ResponseEntity.notFound().build(); - return ResponseEntity.ok(result); + public AjaxResult updateShop(@RequestBody Shop shop) { + return toAjax(shopService.updateShop(shop)); } - @DeleteMapping("/delete/{id}") - public ResponseEntity deleteShop(@PathVariable Long id) { - shopService.deleteShop(id); - return ResponseEntity.ok().build(); + @PostMapping("/delete/{id}") + public AjaxResult deleteShop(@PathVariable Long id) { + return toAjax(shopService.deleteShop(id)); } } \ No newline at end of file diff --git a/ghy-framework/src/main/java/com/ghy/framework/config/ShiroConfig.java b/ghy-framework/src/main/java/com/ghy/framework/config/ShiroConfig.java index cb71d0ac..d918505f 100644 --- a/ghy-framework/src/main/java/com/ghy/framework/config/ShiroConfig.java +++ b/ghy-framework/src/main/java/com/ghy/framework/config/ShiroConfig.java @@ -283,6 +283,7 @@ public class ShiroConfig filterChainDefinitionMap.put("/special/skill/**", "anon"); filterChainDefinitionMap.put("/customer/**", "anon"); filterChainDefinitionMap.put("/goods/**", "anon"); + filterChainDefinitionMap.put("/shop/**", "anon"); filterChainDefinitionMap.put("/financial/**", "anon"); filterChainDefinitionMap.put("/tool/**", "anon"); filterChainDefinitionMap.put("/adapay/**", "anon"); diff --git a/ghy-shop/pom.xml b/ghy-shop/pom.xml index 2a579084..e87b30bc 100644 --- a/ghy-shop/pom.xml +++ b/ghy-shop/pom.xml @@ -30,6 +30,12 @@ lombok true + + org.mybatis + mybatis + 3.5.9 + compile + diff --git a/ghy-shop/src/main/java/com/ghy/shop/domain/Shop.java b/ghy-shop/src/main/java/com/ghy/shop/domain/Shop.java index e9311f94..0ce647a0 100644 --- a/ghy-shop/src/main/java/com/ghy/shop/domain/Shop.java +++ b/ghy-shop/src/main/java/com/ghy/shop/domain/Shop.java @@ -1,7 +1,5 @@ package com.ghy.shop.domain; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import java.io.Serializable; @@ -9,9 +7,7 @@ import java.io.Serializable; * 店铺信息实体类 */ @Data -@TableName("shop") public class Shop implements Serializable { - @TableId private Long shopId; // 店铺ID private String shopName; // 店铺名称 private String imageUrl; // 店铺图片