|
@@ -1,9 +1,22 @@
|
|
|
package com.jkcredit.sysnews.resource.web.navigationBar;
|
|
|
|
|
|
+import com.jkcredit.sysnews.model.dto.navigationBar.NavigationBarDto;
|
|
|
import com.jkcredit.sysnews.resource.base.WebResource;
|
|
|
+import com.jkcredit.sysnews.resource.web.navigationBar.fb.NavigationBarAddFB;
|
|
|
+import com.jkcredit.sysnews.service.navigationBar.NavigationBarService;
|
|
|
+import com.jkcredit.sysnews.spi.lang.exception.ServiceException;
|
|
|
+import com.jkcredit.sysnews.spi.web.data.ResponseData;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* @description:
|
|
|
* @author: xusonglin
|
|
@@ -13,4 +26,26 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
@Slf4j
|
|
|
@RestController
|
|
|
public class NavigationBarResource extends WebResource {
|
|
|
+ @Autowired
|
|
|
+ NavigationBarService navigationBarService;
|
|
|
+
|
|
|
+ @PostMapping("/menu")
|
|
|
+ @PreAuthorize("hasPermission('menu','edit')")
|
|
|
+ @ApiOperation(value = "新增菜单栏")
|
|
|
+ public ResponseData saveNavigationBar(@RequestBody List<NavigationBarAddFB> fbList) {
|
|
|
+ try {
|
|
|
+ // todo 导航首页展示顺序是否需要 需要和前端讨论
|
|
|
+ List<NavigationBarDto> navigationBarDtoList = new ArrayList<>();
|
|
|
+ for (NavigationBarAddFB fb : fbList) {
|
|
|
+ validate(fb);
|
|
|
+ NavigationBarDto navigationBarDto = mapper.map(fb, NavigationBarDto.class);
|
|
|
+ navigationBarDtoList.add(navigationBarDto);
|
|
|
+ }
|
|
|
+ navigationBarService.saveNavigationBar(navigationBarDtoList);
|
|
|
+ return ResponseData.success("新增菜单栏成功");
|
|
|
+ } catch (ServiceException e) {
|
|
|
+ log.error(e.getMessage());
|
|
|
+ return ResponseData.failed("新增菜单栏失败,失败原因:" + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|