|
@@ -1,8 +1,11 @@
|
|
|
package com.fuint.module.backendApi.controller;
|
|
|
|
|
|
import com.fuint.common.dto.AccountInfo;
|
|
|
+import com.fuint.common.dto.IngredientDto;
|
|
|
import com.fuint.common.util.TokenUtil;
|
|
|
+import com.fuint.common.vo.IngredientVo;
|
|
|
import com.fuint.framework.web.BaseController;
|
|
|
+import com.fuint.framework.web.PageResult;
|
|
|
import com.fuint.framework.web.ResponseObject;
|
|
|
import com.fuint.common.Constants;
|
|
|
import com.fuint.common.enums.StatusEnum;
|
|
@@ -48,56 +51,9 @@ public class BackendIngredientController extends BaseController {
|
|
|
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
|
|
@CrossOrigin
|
|
|
@PreAuthorize("@pms.hasPermission('ingredient:list')")
|
|
|
- public ResponseObject list(HttpServletRequest request) throws BusinessCheckException {
|
|
|
- String token = request.getHeader("Access-Token");
|
|
|
- Integer page = request.getParameter("page") == null ? Constants.PAGE_NUMBER : Integer.parseInt(request.getParameter("page"));
|
|
|
- Integer pageSize = request.getParameter("pageSize") == null ? Constants.PAGE_SIZE : Integer.parseInt(request.getParameter("pageSize"));
|
|
|
- String title = request.getParameter("title");
|
|
|
- String status = request.getParameter("status");
|
|
|
- String searchStoreId = request.getParameter("storeId");
|
|
|
-
|
|
|
- AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
|
|
|
- Long storeId;
|
|
|
- if (accountInfo == null) {
|
|
|
- return getFailureResult(1001, "请先登录");
|
|
|
- } else {
|
|
|
- storeId = accountInfo.getStoreId();
|
|
|
- }
|
|
|
-
|
|
|
- PaginationRequest paginationRequest = new PaginationRequest();
|
|
|
- paginationRequest.setCurrentPage(page);
|
|
|
- paginationRequest.setPageSize(pageSize);
|
|
|
-
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- if (accountInfo.getMerchantId() != null && accountInfo.getMerchantId() > 0) {
|
|
|
- params.put("merchantId", accountInfo.getMerchantId());
|
|
|
- }
|
|
|
- if (StringUtil.isNotEmpty(title)) {
|
|
|
- params.put("title", title);
|
|
|
- }
|
|
|
- if (StringUtil.isNotEmpty(status)) {
|
|
|
- params.put("status", status);
|
|
|
- }
|
|
|
- if (StringUtil.isNotEmpty(searchStoreId)) {
|
|
|
- params.put("storeId", searchStoreId);
|
|
|
- }
|
|
|
- if (storeId != null && storeId > 0) {
|
|
|
- params.put("storeId", storeId);
|
|
|
- }
|
|
|
- paginationRequest.setSearchParams(params);
|
|
|
- PaginationResponse<MtIngredient> paginationResponse = ingredientService.queryIngredientListByPagination(paginationRequest);
|
|
|
-
|
|
|
- Map<String, Object> paramsStore = new HashMap<>();
|
|
|
- paramsStore.put("status", StatusEnum.ENABLED.getKey());
|
|
|
- if (accountInfo.getStoreId() != null && accountInfo.getStoreId() > 0) {
|
|
|
- paramsStore.put("storeId", accountInfo.getStoreId().toString());
|
|
|
- }
|
|
|
- if (accountInfo.getMerchantId() != null && accountInfo.getMerchantId() > 0) {
|
|
|
- paramsStore.put("merchantId", accountInfo.getMerchantId());
|
|
|
- }
|
|
|
-
|
|
|
- Map<String, Object> result = new HashMap<>();
|
|
|
- result.put("paginationResponse", paginationResponse);
|
|
|
+ public ResponseObject list(HttpServletRequest request, IngredientDto ingredientDto) throws BusinessCheckException {
|
|
|
+
|
|
|
+ PageResult<IngredientDto> result = ingredientService.queryIngredientPageList(ingredientDto);
|
|
|
|
|
|
return getSuccessResult(result);
|
|
|
}
|
|
@@ -108,27 +64,28 @@ public class BackendIngredientController extends BaseController {
|
|
|
* @return
|
|
|
*/
|
|
|
@ApiOperation(value = "更新菜品配料表状态")
|
|
|
- @RequestMapping(value = "/updateStatus", method = RequestMethod.POST)
|
|
|
+ @RequestMapping(value = "/updateIngredient", method = RequestMethod.POST)
|
|
|
@CrossOrigin
|
|
|
@PreAuthorize("@pms.hasPermission('ingredient:edit')")
|
|
|
- public ResponseObject updateStatus(HttpServletRequest request, @RequestBody Map<String, Object> params) throws BusinessCheckException {
|
|
|
- String token = request.getHeader("Access-Token");
|
|
|
- String status = params.get("status") != null ? params.get("status").toString() : StatusEnum.ENABLED.getKey();
|
|
|
- Long id = params.get("id") == null ? 0 : Long.parseLong(params.get("id").toString());
|
|
|
+ public ResponseObject updateStatus(HttpServletRequest request, @RequestBody IngredientDto ingredientDto) throws BusinessCheckException {
|
|
|
|
|
|
- AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
|
|
|
- if (accountInfo == null) {
|
|
|
- return getFailureResult(1001, "请先登录");
|
|
|
- }
|
|
|
+ ingredientService.updateIngredient(ingredientDto);
|
|
|
|
|
|
- MtIngredient mtIngredient = ingredientService.queryIngredientById(id);
|
|
|
- if (mtIngredient == null) {
|
|
|
- return getFailureResult(201);
|
|
|
- }
|
|
|
+ return getSuccessResult(true);
|
|
|
+ }
|
|
|
|
|
|
- String operator = accountInfo.getAccountName();
|
|
|
+ /**
|
|
|
+ * 更删除菜品配料表
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "删除菜品配料表状态")
|
|
|
+ @RequestMapping(value = "/deleteIngredientById/{id}", method = RequestMethod.POST)
|
|
|
+ @CrossOrigin
|
|
|
+ @PreAuthorize("@pms.hasPermission('ingredient:edit')")
|
|
|
+ public ResponseObject deleteIngredientById(HttpServletRequest request, @PathVariable("id") Long id) throws BusinessCheckException {
|
|
|
|
|
|
- ingredientService.updateIngredient(mtIngredient);
|
|
|
+ ingredientService.deleteIngredientById(id);
|
|
|
|
|
|
return getSuccessResult(true);
|
|
|
}
|
|
@@ -143,19 +100,9 @@ public class BackendIngredientController extends BaseController {
|
|
|
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
|
|
@CrossOrigin
|
|
|
@PreAuthorize("@pms.hasPermission('ingredient:add')")
|
|
|
- public ResponseObject saveHandler(HttpServletRequest request, @RequestBody Map<String, Object> params) throws BusinessCheckException {
|
|
|
- String token = request.getHeader("Access-Token");
|
|
|
- String id = params.get("id") == null ? "" : params.get("id").toString();
|
|
|
- String status = params.get("status") == null ? "" : params.get("status").toString();
|
|
|
- String storeId = params.get("storeId") == null ? "0" : params.get("storeId").toString();
|
|
|
-
|
|
|
- AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
|
|
|
- if (accountInfo == null) {
|
|
|
- return getFailureResult(1001, "请先登录");
|
|
|
- }
|
|
|
-
|
|
|
- MtIngredient info = new MtIngredient();
|
|
|
+ public ResponseObject saveHandler(HttpServletRequest request, @RequestBody IngredientDto ingredientDto) throws BusinessCheckException {
|
|
|
|
|
|
+ ingredientService.addIngredient(ingredientDto);
|
|
|
|
|
|
return getSuccessResult(true);
|
|
|
}
|
|
@@ -170,17 +117,9 @@ public class BackendIngredientController extends BaseController {
|
|
|
@RequestMapping(value = "/info/{id}", method = RequestMethod.GET)
|
|
|
@CrossOrigin
|
|
|
@PreAuthorize("@pms.hasPermission('ingredient:list')")
|
|
|
- public ResponseObject info(HttpServletRequest request, @PathVariable("id") Integer id) throws BusinessCheckException {
|
|
|
- String token = request.getHeader("Access-Token");
|
|
|
- AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
|
|
|
- if (accountInfo == null) {
|
|
|
- return getFailureResult(1001, "请先登录");
|
|
|
- }
|
|
|
-
|
|
|
- MtIngredient ingredientInfo = ingredientService.queryIngredientById(Long.valueOf(id));
|
|
|
+ public ResponseObject info(HttpServletRequest request, @PathVariable("id") Long id) throws BusinessCheckException {
|
|
|
|
|
|
- Map<String, Object> result = new HashMap<>();
|
|
|
- result.put("ingredientInfo", ingredientInfo);
|
|
|
+ IngredientVo result = ingredientService.queryIngredientById(Long.valueOf(id));
|
|
|
|
|
|
return getSuccessResult(result);
|
|
|
}
|