|
@@ -0,0 +1,130 @@
|
|
|
|
|
+package shop.alien.store.controller;
|
|
|
|
|
+
|
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
|
+import io.swagger.annotations.ApiSort;
|
|
|
|
|
+import io.swagger.annotations.ApiOperationSupport;
|
|
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.web.bind.annotation.CrossOrigin;
|
|
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
+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.RequestParam;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
+import shop.alien.entity.result.R;
|
|
|
|
|
+import shop.alien.entity.store.CommonExpression;
|
|
|
|
|
+import shop.alien.store.service.CommonExpressionService;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 门店常用语管理 前端控制器
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author system
|
|
|
|
|
+ * @since 2026-03-26
|
|
|
|
|
+ */
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+@Api(tags = {"门店常用语管理"})
|
|
|
|
|
+@ApiSort(16)
|
|
|
|
|
+@CrossOrigin
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/store/commonExpression")
|
|
|
|
|
+@RequiredArgsConstructor
|
|
|
|
|
+public class CommonExpressionController {
|
|
|
|
|
+
|
|
|
|
|
+ private final CommonExpressionService commonExpressionService;
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
|
|
+ @ApiOperation("查询门店常用语列表")
|
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
|
+ @ApiImplicitParam(name = "storeId", value = "门店ID", dataType = "Integer", paramType = "query", required = true)
|
|
|
|
|
+ })
|
|
|
|
|
+ @GetMapping("/list")
|
|
|
|
|
+ public R<List<CommonExpression>> list(@RequestParam Integer storeId) {
|
|
|
|
|
+ log.info("CommonExpressionController.list?storeId={}", storeId);
|
|
|
|
|
+ if (storeId == null) {
|
|
|
|
|
+ return R.fail("门店ID不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ return R.data(commonExpressionService.listByStoreId(storeId));
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("查询门店常用语列表失败", e);
|
|
|
|
|
+ return R.fail("查询失败:" + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
|
|
+ @ApiOperation("查询门店常用语详情")
|
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
|
+ @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Integer", paramType = "query", required = true)
|
|
|
|
|
+ })
|
|
|
|
|
+ @GetMapping("/detail")
|
|
|
|
|
+ public R<CommonExpression> detail(@RequestParam Integer id) {
|
|
|
|
|
+ log.info("CommonExpressionController.detail?id={}", id);
|
|
|
|
|
+ if (id == null) {
|
|
|
|
|
+ return R.fail("主键ID不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ CommonExpression detail = commonExpressionService.getById(id);
|
|
|
|
|
+ if (detail == null) {
|
|
|
|
|
+ return R.fail("常用语不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ return R.data(detail);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("查询门店常用语详情失败", e);
|
|
|
|
|
+ return R.fail("查询失败:" + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
|
|
+ @ApiOperation("新增门店常用语")
|
|
|
|
|
+ @PostMapping("/add")
|
|
|
|
|
+ public R<String> add(@RequestBody CommonExpression commonExpression) {
|
|
|
|
|
+ log.info("CommonExpressionController.add?commonExpression={}", commonExpression);
|
|
|
|
|
+ try {
|
|
|
|
|
+ boolean result = commonExpressionService.addCommonExpression(commonExpression);
|
|
|
|
|
+ return result ? R.success("新增成功") : R.fail("新增失败");
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("新增门店常用语失败", e);
|
|
|
|
|
+ return R.fail(e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperationSupport(order = 4)
|
|
|
|
|
+ @ApiOperation("更新门店常用语")
|
|
|
|
|
+ @PostMapping("/update")
|
|
|
|
|
+ public R<String> update(@RequestBody CommonExpression commonExpression) {
|
|
|
|
|
+ log.info("CommonExpressionController.update?commonExpression={}", commonExpression);
|
|
|
|
|
+ try {
|
|
|
|
|
+ boolean result = commonExpressionService.updateCommonExpression(commonExpression);
|
|
|
|
|
+ return result ? R.success("更新成功") : R.fail("更新失败");
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("更新门店常用语失败", e);
|
|
|
|
|
+ return R.fail(e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperationSupport(order = 5)
|
|
|
|
|
+ @ApiOperation("删除门店常用语")
|
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
|
+ @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Integer", paramType = "query", required = true)
|
|
|
|
|
+ })
|
|
|
|
|
+ @PostMapping("/delete")
|
|
|
|
|
+ public R<String> delete(@RequestParam Integer id) {
|
|
|
|
|
+ log.info("CommonExpressionController.delete?id={}", id);
|
|
|
|
|
+ if (id == null) {
|
|
|
|
|
+ return R.fail("主键ID不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ boolean result = commonExpressionService.deleteCommonExpression(id);
|
|
|
|
|
+ return result ? R.success("删除成功") : R.fail("删除失败");
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("删除门店常用语失败", e);
|
|
|
|
|
+ return R.fail(e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|