|
@@ -1,8 +1,12 @@
|
|
|
package com.fuint.module.backendApi.controller;
|
|
|
|
|
|
import com.fuint.common.dto.AccountInfo;
|
|
|
+import com.fuint.common.dto.ext.CurrencyDto;
|
|
|
+import com.fuint.common.param.PageParam;
|
|
|
import com.fuint.common.util.TokenUtil;
|
|
|
+import com.fuint.common.vo.CurrencyVo;
|
|
|
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;
|
|
@@ -19,6 +23,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
@@ -41,147 +46,75 @@ public class BackendCurrencyController extends BaseController {
|
|
|
/**
|
|
|
* 货币表列表查询
|
|
|
*
|
|
|
- * @param request HttpServletRequest对象
|
|
|
* @return 货币表列表
|
|
|
*/
|
|
|
@ApiOperation(value = "货币表列表查询")
|
|
|
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
|
|
@CrossOrigin
|
|
|
@PreAuthorize("@pms.hasPermission('currency: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<MtCurrency> paginationResponse = currencyService.queryCurrencyListByPagination(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);
|
|
|
-
|
|
|
- return getSuccessResult(result);
|
|
|
+ public PageResult<CurrencyVo> list(@RequestParam(defaultValue = "") String name, PageParam pageParam) throws BusinessCheckException {
|
|
|
+ return currencyService.getCurrencyById(name,pageParam);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 更新货币表状态
|
|
|
+ * 更新货币数据
|
|
|
*
|
|
|
- * @return
|
|
|
+ * @return 结果
|
|
|
*/
|
|
|
- @ApiOperation(value = "更新货币表状态")
|
|
|
- @RequestMapping(value = "/updateStatus", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "更新货币数据")
|
|
|
+ @RequestMapping(value = "/updateCurrency", method = RequestMethod.POST)
|
|
|
@CrossOrigin
|
|
|
@PreAuthorize("@pms.hasPermission('currency: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());
|
|
|
-
|
|
|
- AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
|
|
|
- if (accountInfo == null) {
|
|
|
- return getFailureResult(1001, "请先登录");
|
|
|
- }
|
|
|
-
|
|
|
- MtCurrency mtCurrency = currencyService.queryCurrencyById(id);
|
|
|
- if (mtCurrency == null) {
|
|
|
- return getFailureResult(201);
|
|
|
- }
|
|
|
-
|
|
|
- String operator = accountInfo.getAccountName();
|
|
|
-
|
|
|
- currencyService.updateCurrency(mtCurrency);
|
|
|
-
|
|
|
- return getSuccessResult(true);
|
|
|
+ public ResponseObject updateStatus(@RequestBody CurrencyDto currencyDto) throws BusinessCheckException {
|
|
|
+ boolean success = currencyService.updateCurrency(currencyDto);
|
|
|
+ return success?getSuccessResult(true):getFailureResult(1002,"更新失败");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 保存货币表
|
|
|
- *
|
|
|
- * @param request HttpServletRequest对象
|
|
|
- * @return
|
|
|
+ * @param currencyDto 参数实体
|
|
|
+ * @return 结果
|
|
|
+ * @throws BusinessCheckException
|
|
|
*/
|
|
|
@ApiOperation(value = "保存货币表")
|
|
|
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
|
|
@CrossOrigin
|
|
|
@PreAuthorize("@pms.hasPermission('currency: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, "请先登录");
|
|
|
- }
|
|
|
-
|
|
|
- MtCurrency info = new MtCurrency();
|
|
|
-
|
|
|
-
|
|
|
- return getSuccessResult(true);
|
|
|
+ public ResponseObject saveHandler(@RequestBody CurrencyDto currencyDto) throws BusinessCheckException {
|
|
|
+ boolean success = currencyService.addCurrency(currencyDto);
|
|
|
+ return success?getSuccessResult(true):getFailureResult(1002,"保存失败");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取货币表详情
|
|
|
+ * 通过id删除货币数据
|
|
|
*
|
|
|
- * @param id
|
|
|
- * @return
|
|
|
+ * @param id id
|
|
|
+ * @return 结果
|
|
|
*/
|
|
|
- @ApiOperation(value = "获取货币表详情")
|
|
|
- @RequestMapping(value = "/info/{id}", method = RequestMethod.GET)
|
|
|
+ @ApiOperation(value = "通过id删除货币数据")
|
|
|
+ @DeleteMapping("/{id}")
|
|
|
@CrossOrigin
|
|
|
- @PreAuthorize("@pms.hasPermission('currency: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, "请先登录");
|
|
|
- }
|
|
|
-
|
|
|
- MtCurrency currencyInfo = currencyService.queryCurrencyById(Long.valueOf(id));
|
|
|
+ @PreAuthorize("@pms.hasPermission('currency:delete')")
|
|
|
+ public ResponseObject info(@PathVariable("id") Integer id) throws BusinessCheckException {
|
|
|
+ boolean success = currencyService.deleteCurrency(id);
|
|
|
+ return success?getSuccessResult(true):getFailureResult(1002,"删除失败");
|
|
|
+ }
|
|
|
|
|
|
- Map<String, Object> result = new HashMap<>();
|
|
|
- result.put("currencyInfo", currencyInfo);
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取全部的货币列表
|
|
|
+ *
|
|
|
+ * @param name 货币名称
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "获取全部的货币列表")
|
|
|
+ @DeleteMapping("/allList")
|
|
|
+ @CrossOrigin
|
|
|
+ @PreAuthorize("@pms.hasPermission('currency:allList')")
|
|
|
+ public ResponseObject allList(@RequestParam(value = "name",defaultValue = "") String name) throws BusinessCheckException {
|
|
|
+ List<CurrencyVo> result = currencyService.allList(name);
|
|
|
return getSuccessResult(result);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|