1
0
Эх сурвалжийг харах

fixed 员工信息编辑接口优化

fushengqian 2 долоо хоног өмнө
parent
commit
c9bdf01320

+ 40 - 0
fuint-application/src/main/java/com/fuint/common/param/StaffParam.java

@@ -0,0 +1,40 @@
+package com.fuint.common.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import java.io.Serializable;
+
+/**
+ * 订单列表请求参数
+ *
+ * Created by FSQ
+ * CopyRight https://www.fuint.cn
+ */
+@Data
+public class StaffParam extends PageParam implements Serializable {
+
+    @ApiModelProperty(value="ID", name="id")
+    private Integer id;
+
+    @ApiModelProperty(value="商户ID", name="merchantId")
+    private Integer merchantId;
+
+    @ApiModelProperty(value="店铺ID", name="storeId")
+    private Integer storeId;
+
+    @ApiModelProperty(value="类别", name="category")
+    private Integer category;
+
+    @ApiModelProperty(value="手机号", name="mobile")
+    private String mobile;
+
+    @ApiModelProperty(value="真实姓名", name="realName")
+    private String realName;
+
+    @ApiModelProperty(value="备注信息", name="description")
+    private String description;
+
+    @ApiModelProperty(value="审核状态", name="auditedStatus")
+    private String auditedStatus;
+
+}

+ 12 - 20
fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendStaffController.java

@@ -5,6 +5,7 @@ import com.fuint.common.dto.AccountInfo;
 import com.fuint.common.dto.ParamDto;
 import com.fuint.common.enums.StaffCategoryEnum;
 import com.fuint.common.enums.StatusEnum;
+import com.fuint.common.param.StaffParam;
 import com.fuint.common.service.StaffService;
 import com.fuint.common.util.CommonUtil;
 import com.fuint.common.util.PhoneFormatCheckUtils;
@@ -21,9 +22,7 @@ import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
-
 import javax.servlet.http.HttpServletRequest;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -134,15 +133,8 @@ public class BackendStaffController extends BaseController {
     @RequestMapping(value = "/save", method = RequestMethod.POST)
     @CrossOrigin
     @PreAuthorize("@pms.hasPermission('staff:list')")
-    public ResponseObject saveHandler(HttpServletRequest request, @RequestBody Map<String, Object> params) throws BusinessCheckException {
+    public ResponseObject saveHandler(HttpServletRequest request, @RequestBody StaffParam staffParam) throws BusinessCheckException {
         String token = request.getHeader("Access-Token");
-        String id = params.get("id") == null ? "0" : params.get("id").toString();
-        String storeId = params.get("storeId") == null ? "0" : params.get("storeId").toString();
-        String category = params.get("category") == null ? "0" : params.get("category").toString();
-        String mobile = params.get("mobile") == null ? "" : CommonUtil.replaceXSS(params.get("mobile").toString());
-        String realName = params.get("realName") == null ? "" : CommonUtil.replaceXSS(params.get("realName").toString());
-        String description = params.get("description") == null ? "" : CommonUtil.replaceXSS(params.get("description").toString());
-        String status = params.get("auditedStatus") == null ? StatusEnum.FORBIDDEN.getKey() : CommonUtil.replaceXSS(params.get("auditedStatus").toString());
 
         AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
 
@@ -151,24 +143,24 @@ public class BackendStaffController extends BaseController {
         }
 
         MtStaff mtStaff = new MtStaff();
-        if (StringUtil.isNotEmpty(id)) {
-            mtStaff = staffService.queryStaffById(Integer.parseInt(id));
+        if (staffParam.getId() != null) {
+            mtStaff = staffService.queryStaffById(staffParam.getId());
         }
 
-        if (mtStaff == null && StringUtil.isNotEmpty(id)) {
+        if (mtStaff == null && staffParam.getId() == null) {
             return getFailureResult(201, "员工信息不存在");
         }
         if (accountInfo.getMerchantId() != null && accountInfo.getMerchantId() > 0) {
             mtStaff.setMerchantId(accountInfo.getMerchantId());
         }
-        mtStaff.setStoreId(Integer.parseInt(storeId));
-        mtStaff.setRealName(realName);
-        if (PhoneFormatCheckUtils.isChinaPhoneLegal(mobile)) {
-            mtStaff.setMobile(mobile);
+        mtStaff.setStoreId(staffParam.getStoreId());
+        mtStaff.setRealName(staffParam.getRealName());
+        if (PhoneFormatCheckUtils.isChinaPhoneLegal(staffParam.getMobile())) {
+            mtStaff.setMobile(staffParam.getMobile());
         }
-        mtStaff.setAuditedStatus(status);
-        mtStaff.setDescription(description);
-        mtStaff.setCategory(Integer.parseInt(category));
+        mtStaff.setAuditedStatus(staffParam.getAuditedStatus() == null ? StatusEnum.FORBIDDEN.getKey() : staffParam.getAuditedStatus());
+        mtStaff.setDescription(staffParam.getDescription());
+        mtStaff.setCategory(staffParam.getCategory());
 
         if (StringUtil.isEmpty(mtStaff.getMobile())) {
             return getFailureResult(201, "手机号码不能为空");