|
|
@@ -0,0 +1,54 @@
|
|
|
+package com.etotem.cfc.controller.admin;
|
|
|
+
|
|
|
+import com.etotem.cfc.common.Result;
|
|
|
+import com.etotem.cfc.entity.VirtualGoodsConfig;
|
|
|
+import com.etotem.cfc.service.VirtualGoodsConfigService;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestAttribute;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api/admin/virtual-goods")
|
|
|
+public class VirtualGoodsConfigAdminController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private VirtualGoodsConfigService virtualGoodsConfigService;
|
|
|
+
|
|
|
+ @PostMapping("/list")
|
|
|
+ public Result<List<VirtualGoodsConfig>> list(@RequestBody(required = false) Map<String, Object> params,
|
|
|
+ @RequestAttribute("role") String role) {
|
|
|
+ if (!"admin".equals(role)) {
|
|
|
+ return Result.error("无权限");
|
|
|
+ }
|
|
|
+ String goodsType = params == null ? null : (String) params.get("goodsType");
|
|
|
+ return Result.success(virtualGoodsConfigService.list(goodsType));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/save")
|
|
|
+ public Result<Boolean> save(@RequestBody VirtualGoodsConfig config,
|
|
|
+ @RequestAttribute("role") String role) {
|
|
|
+ if (!"admin".equals(role)) {
|
|
|
+ return Result.error("无权限");
|
|
|
+ }
|
|
|
+ return Result.success(virtualGoodsConfigService.save(config));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/delete")
|
|
|
+ public Result<Boolean> delete(@RequestBody Map<String, Object> params,
|
|
|
+ @RequestAttribute("role") String role) {
|
|
|
+ if (!"admin".equals(role)) {
|
|
|
+ return Result.error("无权限");
|
|
|
+ }
|
|
|
+ Long id = params.get("id") == null ? null : Long.valueOf(params.get("id").toString());
|
|
|
+ if (id == null) {
|
|
|
+ return Result.error("参数错误");
|
|
|
+ }
|
|
|
+ return Result.success(virtualGoodsConfigService.delete(id));
|
|
|
+ }
|
|
|
+}
|