liupeng 4 years ago
parent
commit
aee65b23f7

+ 10 - 10
code/sapparent/sapcms/src/main/java/org/fouram/controller/SapReportController.java

@@ -12,8 +12,8 @@ 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;
+import org.fouram.service.WxDepartService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -32,16 +32,16 @@ import io.swagger.annotations.Api;
 public class SapReportController extends BaseController {
 
 	@Autowired
-	private SapOrgService sapOrgService;
-	@Autowired
 	private SapReportAuthService service;
 	@Autowired
+	private WxDepartService wxDepartService;
+	@Autowired
 	private SapCheckReportService reportService;
 
-	@PostMapping(value = "/selectFirstOrgList", produces = "application/json;charset=utf-8")
+	@PostMapping(value = "/selectFirstDepartList", produces = "application/json;charset=utf-8")
 	@ResponseBody
-	public Object selectFirstOrgList() throws Exception {
-		return ResultUtil.success(sapOrgService.selectFirstOrgList(), null);
+	public Object selectFirstDepartList() throws Exception {
+		return ResultUtil.success(wxDepartService.selectFirstDepartList(), null);
 	}
 
 	@PostMapping(value = "/saveReportAuth", produces = "application/json;charset=utf-8")
@@ -49,7 +49,7 @@ public class SapReportController extends BaseController {
 	public Object saveReportAuth(@RequestBody SapReportAuthSaveDTO dto, @RequestHeader("userId") String userId)
 			throws Exception {
 		ParamUtil.isBlank(userId, "header参数userId不可以为空");
-		ParamUtil.isBlank(dto.getSapOrgIds(), "参数sapOrgIds不可以为空");
+		ParamUtil.isBlank(dto.getWxDepartIds(), "参数wxDepartIds不可以为空");
 		dto.setWxUserId(userId);
 		service.save(dto);
 		return ResultUtil.success();
@@ -58,7 +58,7 @@ public class SapReportController extends BaseController {
 	@PostMapping(value = "/selectReportAuthList", produces = "application/json;charset=utf-8")
 	@ResponseBody
 	public Object selectReportAuthList(@RequestBody SapReportAuthSelectListDTO dto) throws Exception {
-		return ResultUtil.success(service.selectList(dto), "保存成功");
+		return ResultUtil.success(service.selectList(dto), null);
 	}
 
 	@PostMapping(value = "/deleteReportAuth", produces = "application/json;charset=utf-8")
@@ -78,9 +78,9 @@ public class SapReportController extends BaseController {
 		ParamUtil.isNull(dto.getPageNumber(), "参数pageNumber不可以为空");
 		if(StringUtils.isBlank(dto.getDepartId())) {
 			List<SapReportAuth> auths = service.selectListByWxUserId(userId);
-			List<String> departIds = Lists.newArrayList();
+			List<Long> departIds = Lists.newArrayList();
 			for(SapReportAuth auth : auths) {
-				departIds.add(auth.getSapOrgId());
+				departIds.add(auth.getWxDepartId());
 			}
 			dto.setDepartIds(departIds);
 		}

+ 7 - 1
code/sapparent/sapservice/src/main/java/org/fouram/core/base/exception/GiantInvalidArgumentException.java

@@ -1,7 +1,13 @@
 package org.fouram.core.base.exception;
 
+/**
+ * 非法参数异常
+ * @author Liup
+ *
+ */
 public class GiantInvalidArgumentException extends RuntimeException {
-	private static final long serialVersionUID = -1605515531880249974L;
+
+	private static final long serialVersionUID = 1L;
 
 	public GiantInvalidArgumentException() {
 	}

+ 1 - 1
code/sapparent/sapservice/src/main/java/org/fouram/dto/input/FindUsersDTO.java

@@ -21,7 +21,7 @@ public class FindUsersDTO implements Serializable {
 	private String startDate;
 	private String endDate;
 	private String departId;
-	private List<String> departIds;
+	private List<Long> departIds;
 	private String name;
 	private String status;
 	private String loginWxUserId;

+ 1 - 1
code/sapparent/sapservice/src/main/java/org/fouram/dto/input/SapReportAuthDTO.java

@@ -20,7 +20,7 @@ public class SapReportAuthDTO implements Serializable {
 	public static class SapReportAuthSaveDTO implements Serializable {
 		private static final long serialVersionUID = 1L;
 		private String wxUserId;
-		private String sapOrgIds;
+		private String wxDepartIds;
 	}
 	
 	@Data

+ 2 - 2
code/sapparent/sapservice/src/main/java/org/fouram/entity/SapReportAuth.java

@@ -19,9 +19,9 @@ public class SapReportAuth implements Serializable {
 
 	private Long id;
 	private String wxUserId;
-	private String sapOrgId;
+	private Long wxDepartId;
 	
 	// 非表字段
 	private String wxUserName;
-	private String sapOrgName;
+	private String wxDepartName;
 }

+ 6 - 6
code/sapparent/sapservice/src/main/java/org/fouram/mapper/SapReportAuthMapper.xml

@@ -2,15 +2,15 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="SapReportAuthMapper">
 	<insert id="save">
-		insert into sap_report_auth(wxUserId,sapOrgId) values (#{wxUserId},#{sapOrgId})
+		insert into sap_report_auth(wxUserId,wxDepartId) values (#{wxUserId},#{wxDepartId})
 	</insert>
 	
 	<select id="selectList" resultType="SapReportAuth">
-		select a.*, b.name as wxUserName, c.sapName as sapOrgName 
-		from sap_report_auth a, wx_user b, sap_org c
-		where a.wxUserId = b.userId and a.wxOrgId = c.id
-		<if test="name != null and name != ''">
-			and b.name like CONCAT(CONCAT('%', #{name}),'%')
+		select a.*, b.name as wxUserName, c.name as wxDepartName 
+		from sap_report_auth a, wx_user b, wx_depart c
+		where a.wxUserId = b.userId and a.wxDepartId = c.id
+		<if test="wxName != null and wxName != ''">
+			and b.name like CONCAT(CONCAT('%', #{wxName}),'%')
 		</if>
 	</select>
 	

+ 7 - 4
code/sapparent/sapservice/src/main/java/org/fouram/mapper/WxDepartMapper.xml

@@ -9,15 +9,18 @@
 	<update id="update">
 		update wx_depart 
 		set name=#{name},parentId=#{parentId},orderBy=#{order}
-		where id=#{id}
-		
+		where id = #{id}
 	</update>
 	
 	<select id="selectById" resultType="WxDepart">
-		select * from wx_depart where id=#{id}
+		select * from wx_depart where id = #{id}
 	</select>
 	
 	<select id="selectChildrenByParentId" resultType="WxDepart">
-		select * from wx_depart where parentId=#{id}
+		select * from wx_depart where parentId = #{id}
+	</select>
+	
+	<select id="selectFirstDepartList" resultType="WxDepart">
+		select * from wx_depart where parentId = 1
 	</select>
 </mapper>

+ 3 - 3
code/sapparent/sapservice/src/main/java/org/fouram/service/SapReportAuthService.java

@@ -15,9 +15,9 @@ import org.springframework.transaction.annotation.Transactional;
 public class SapReportAuthService extends BaseService {
 
 	public void save(SapReportAuthSaveDTO dto) throws Exception {
-		List<String> sapOrgIdList = SplitUtil.split(dto.getSapOrgIds(), ",");
-		for (String sapOrgId : sapOrgIdList) {
-			SapReportAuth entity = SapReportAuth.builder().wxUserId(dto.getWxUserId()).sapOrgId(sapOrgId).build();
+		List<Long> wxDepartIds = SplitUtil.splitToLong(dto.getWxDepartIds(), ",");
+		for (Long wxDepartId : wxDepartIds) {
+			SapReportAuth entity = SapReportAuth.builder().wxUserId(dto.getWxUserId()).wxDepartId(wxDepartId).build();
 			save("SapReportAuthMapper.save", entity);
 		}
 	}

+ 5 - 0
code/sapparent/sapservice/src/main/java/org/fouram/service/WxDepartService.java

@@ -64,4 +64,9 @@ public class WxDepartService extends BaseService {
 		}
 		return TreeUtil.buildTreeSimple(result);
 	}
+
+	@SuppressWarnings("unchecked")
+	public List<WxDepart> selectFirstDepartList() throws Exception {
+		return (List<WxDepart>) findList("WxDepartMapper.selectFirstDepartList", null);
+	}
 }