Commit a1f205b4 by huluobin

获取部门 序列化

parent bdf1b53e
package com.blt.other.module.auth.controller; package com.blt.other.module.auth.controller;
import com.blt.other.module.auth.service.GetDeparmentListService;
import com.blt.other.module.auth.vo.DeparmentMsg;
import com.blt.other.common.util.AxiosUtil; import com.blt.other.common.util.AxiosUtil;
import com.blt.other.module.auth.service.GetDeparmentListService;
import com.blt.other.module.auth.vo.DepartmentMsg;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -19,7 +19,7 @@ public class DeparmentController { ...@@ -19,7 +19,7 @@ public class DeparmentController {
private GetDeparmentListService getDeparmentListService; private GetDeparmentListService getDeparmentListService;
@PostMapping("/getDeparmentByName") @PostMapping("/getDeparmentByName")
public DeparmentMsg getDeparmentByName(HttpServletResponse response, HttpServletRequest request) { public DepartmentMsg getDeparmentByName(HttpServletResponse response, HttpServletRequest request) {
AxiosUtil.setCors(response, request); AxiosUtil.setCors(response, request);
String deparmentName = request.getParameter("deparmentName"); String deparmentName = request.getParameter("deparmentName");
return getDeparmentListService.getDeparment(deparmentName); return getDeparmentListService.getDeparment(deparmentName);
......
package com.blt.other.module.auth.service; package com.blt.other.module.auth.service;
import com.blt.other.module.auth.vo.DeparmentMsg; import com.blt.other.module.auth.vo.DepartmentMsg;
import java.util.List; import java.util.List;
public interface GetDeparmentListService { public interface GetDeparmentListService {
List<DeparmentMsg> getList(); List<DepartmentMsg> getList();
DeparmentMsg getDeparment(String deparmentName); DepartmentMsg getDeparment(String deparmentName);
} }
package com.blt.other.module.auth.service.impl; package com.blt.other.module.auth.service.impl;
import com.bailuntec.common.JsonUtilByFsJson;
import com.blt.other.module.auth.service.GetDeparmentListService; import com.blt.other.module.auth.service.GetDeparmentListService;
import com.blt.other.module.auth.vo.DeparmentMsg; import com.blt.other.module.auth.vo.DepartmentMsg;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import java.io.IOException;
import java.util.Collection;
import java.util.List; import java.util.List;
@Service @Service
...@@ -28,29 +24,18 @@ public class GetDeparmentListServiceImpl implements GetDeparmentListService { ...@@ -28,29 +24,18 @@ public class GetDeparmentListServiceImpl implements GetDeparmentListService {
private String getDeparmentListApi; private String getDeparmentListApi;
@Override @Override
public List<DeparmentMsg> getList() { public List<DepartmentMsg> getList() {
ResponseEntity<String> forEntity = restTemplate.getForEntity(getDeparmentListApi,String.class); String response = restTemplate.getForEntity(getDeparmentListApi, String.class).getBody();
if(forEntity.getStatusCodeValue() == 200){ return JsonUtilByFsJson.jsonToList(response, DepartmentMsg.class);
String strBody = forEntity.getBody();
ObjectMapper mapper = new ObjectMapper();
JavaType javaType = mapper.getTypeFactory().constructParametricType(Collection.class,DeparmentMsg.class);
try {
assert strBody != null;
return mapper.readValue(strBody,javaType);
} catch (IOException e) {
logger.error("GetDeparmentListServiceImpl",e);
}
}
return null;
} }
@Override @Override
public DeparmentMsg getDeparment(String deparmentName) { public DepartmentMsg getDeparment(String deparmentName) {
List<DeparmentMsg> list = getList(); List<DepartmentMsg> list = getList();
if (null != list && list.size() >= 1){ if (null != list && list.size() >= 1) {
for (DeparmentMsg deparmentMsg: list){ for (DepartmentMsg departmentMsg : list) {
if (null != deparmentName && (deparmentName.toLowerCase()).equals((deparmentMsg.getName()).toLowerCase())){ if (null != deparmentName && (deparmentName.toLowerCase()).equals((departmentMsg.getName()).toLowerCase())) {
return deparmentMsg; return departmentMsg;
} }
} }
} }
......
package com.blt.other.module.auth.vo;
public class DeparmentMsg {
private Integer companyId;
private String name;
private String code;
private Integer parentId;
private Integer sort;
private String manageUser1;
private String manageUser2;
private Integer id;
public Integer getCompanyId() {
return companyId;
}
public void setCompanyId(Integer companyId) {
this.companyId = companyId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Integer getParentId() {
return parentId;
}
public void setParentId(Integer parentId) {
this.parentId = parentId;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public String getManageUser1() {
return manageUser1;
}
public void setManageUser1(String manageUser1) {
this.manageUser1 = manageUser1;
}
public String getManageUser2() {
return manageUser2;
}
public void setManageUser2(String manageUser2) {
this.manageUser2 = manageUser2;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
@Override
public String toString() {
return "DeparmentMsg{" +
"companyId=" + companyId +
", name='" + name + '\'' +
", code='" + code + '\'' +
", parentId=" + parentId +
", sort=" + sort +
", manageUser1='" + manageUser1 + '\'' +
", manageUser2='" + manageUser2 + '\'' +
", id=" + id +
'}';
}
}
package com.blt.other.module.auth.vo;
import lombok.Data;
@Data
public class DepartmentMsg {
private Integer companyId;
private String name;
private String code;
private Integer parentId;
private Integer sort;
private String manageUser1;
private String manageUser2;
private Integer id;
private Integer departmentId;
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
cd /home/ubuntu/data/other/dc-cost-system/bailuntec-cost-core cd /home/ubuntu/data/other/dc-cost-system/bailuntec-cost-core
git pull git pull
# 拉取开发分支代码 # 拉取开发分支代码
git checkout cost-check-flow git checkout cost-check-flow-master
#打包 #打包
mvn clean package -Dmaven.test.skip=true -Dmaven.compile.fork=true mvn clean package -Dmaven.test.skip=true -Dmaven.compile.fork=true
# kill测试进程 # kill测试进程
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment