|
@@ -1,11 +1,16 @@
|
|
|
package org.fouram.controller;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.fouram.core.base.controller.BaseController;
|
|
|
+import org.fouram.core.util.ParamUtil;
|
|
|
import org.fouram.core.util.ResultUtil;
|
|
|
import org.fouram.dto.input.FindUsersDTO;
|
|
|
import org.fouram.dto.input.SapReportAuthDTO.SapReportAuthDeleteDTO;
|
|
|
import org.fouram.dto.input.SapReportAuthDTO.SapReportAuthSaveDTO;
|
|
|
import org.fouram.dto.input.SapReportAuthDTO.SapReportAuthSelectListDTO;
|
|
|
+import org.fouram.entity.SapReportAuth;
|
|
|
import org.fouram.service.SapCheckReportService;
|
|
|
import org.fouram.service.SapOrgService;
|
|
|
import org.fouram.service.SapReportAuthService;
|
|
@@ -13,9 +18,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestHeader;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
|
@Controller
|
|
@@ -38,7 +46,11 @@ public class SapReportController extends BaseController {
|
|
|
|
|
|
@PostMapping(value = "/saveReportAuth", produces = "application/json;charset=utf-8")
|
|
|
@ResponseBody
|
|
|
- public Object saveReportAuth(@RequestBody SapReportAuthSaveDTO dto) throws Exception {
|
|
|
+ public Object saveReportAuth(@RequestBody SapReportAuthSaveDTO dto, @RequestHeader("userId") String userId)
|
|
|
+ throws Exception {
|
|
|
+ ParamUtil.isBlank(userId, "header参数userId不可以为空");
|
|
|
+ ParamUtil.isBlank(dto.getSapOrgIds(), "参数sapOrgIds不可以为空");
|
|
|
+ dto.setWxUserId(userId);
|
|
|
service.save(dto);
|
|
|
return ResultUtil.success();
|
|
|
}
|
|
@@ -52,13 +64,26 @@ public class SapReportController extends BaseController {
|
|
|
@PostMapping(value = "/deleteReportAuth", produces = "application/json;charset=utf-8")
|
|
|
@ResponseBody
|
|
|
public Object deleteReportAuth(@RequestBody SapReportAuthDeleteDTO dto) throws Exception {
|
|
|
+ ParamUtil.isNull(dto.getId(), "参数id不可以为空");
|
|
|
service.deleteById(dto.getId());
|
|
|
return ResultUtil.success();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@PostMapping(value = "/selectUserReportList", produces = "application/json;charset=utf-8")
|
|
|
@ResponseBody
|
|
|
- public Object selectUserReportList(@RequestBody FindUsersDTO dto) throws Exception {
|
|
|
+ public Object selectUserReportList(@RequestBody FindUsersDTO dto, @RequestHeader("userId") String userId)
|
|
|
+ throws Exception {
|
|
|
+ ParamUtil.isBlank(userId, "header参数userId不可以为空");
|
|
|
+ ParamUtil.isNull(dto.getPageSize(), "参数pageSize不可以为空");
|
|
|
+ ParamUtil.isNull(dto.getPageNumber(), "参数pageNumber不可以为空");
|
|
|
+ if(StringUtils.isBlank(dto.getDepartId())) {
|
|
|
+ List<SapReportAuth> auths = service.selectListByWxUserId(userId);
|
|
|
+ List<String> departIds = Lists.newArrayList();
|
|
|
+ for(SapReportAuth auth : auths) {
|
|
|
+ departIds.add(auth.getSapOrgId());
|
|
|
+ }
|
|
|
+ dto.setDepartIds(departIds);
|
|
|
+ }
|
|
|
return ResultUtil.success(reportService.findUserReports(dto), null);
|
|
|
}
|
|
|
}
|