Commit ba7605247ed383ffb0d329d3537af8e8c4bff1cf
1 parent
a3a092a5
1.
Showing
1 changed file
with
60 additions
and
46 deletions
src/main/java/com/bsth/server_rs/base_info/person/PersonRestService.java
| 1 | -package com.bsth.server_rs.base_info.person; | ||
| 2 | - | ||
| 3 | -import com.alibaba.fastjson.JSON; | ||
| 4 | -import com.alibaba.fastjson.TypeReference; | ||
| 5 | -import com.bsth.server_rs.base_info.dto.PersonCardDto; | ||
| 6 | -import com.bsth.server_rs.base_info.person.buffer.PersonBufferData; | ||
| 7 | -import org.apache.commons.lang3.StringEscapeUtils; | ||
| 8 | - | ||
| 9 | -import javax.ws.rs.*; | ||
| 10 | -import javax.ws.rs.core.MediaType; | ||
| 11 | -import java.util.List; | ||
| 12 | -import java.util.Map; | ||
| 13 | - | ||
| 14 | -/** | ||
| 15 | - * Created by panzhao on 2017/3/28. | ||
| 16 | - */ | ||
| 17 | -@Path("/person") | ||
| 18 | -@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) | ||
| 19 | -public class PersonRestService { | ||
| 20 | - | ||
| 21 | - @GET | ||
| 22 | - @Path("/all") | ||
| 23 | - public List<Personnel> findAll(){ | ||
| 24 | - return PersonBufferData.findAll(); | ||
| 25 | - } | ||
| 26 | - | ||
| 27 | - @GET | ||
| 28 | - @Path("/company/{companyId}") | ||
| 29 | - public List<Personnel> findByCompany(@PathParam("companyId") String companyId) { | ||
| 30 | - return companyId.equals("-9999") ? PersonBufferData.findAll() : PersonBufferData.findByCompany(companyId); | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - @GET | ||
| 34 | - @Path("/{workId}") | ||
| 35 | - public Personnel findOne(@PathParam("workId") String workId) { | ||
| 36 | - return PersonBufferData.findOne(workId); | ||
| 37 | - } | ||
| 38 | - | ||
| 39 | - @POST | ||
| 40 | - @Path("/setCards") | ||
| 41 | - public Map<String, Object> multiPostCards(String bodyStr){ | ||
| 42 | - bodyStr = StringEscapeUtils.unescapeHtml4(bodyStr); | ||
| 43 | - List<PersonCardDto> list = JSON.parseObject(bodyStr, new TypeReference<List<PersonCardDto>>() {}); | ||
| 44 | - return PersonBufferData.multiSaveCards(list); | ||
| 45 | - } | ||
| 46 | -} | 1 | +package com.bsth.server_rs.base_info.person; |
| 2 | + | ||
| 3 | +import com.alibaba.fastjson.JSON; | ||
| 4 | +import com.alibaba.fastjson.TypeReference; | ||
| 5 | +import com.bsth.server_rs.base_info.dto.PersonCardDto; | ||
| 6 | +import com.bsth.server_rs.base_info.person.buffer.PersonBufferData; | ||
| 7 | +import org.apache.commons.lang3.StringEscapeUtils; | ||
| 8 | + | ||
| 9 | +import javax.ws.rs.*; | ||
| 10 | +import javax.ws.rs.core.MediaType; | ||
| 11 | +import java.util.ArrayList; | ||
| 12 | +import java.util.List; | ||
| 13 | +import java.util.Map; | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * Created by panzhao on 2017/3/28. | ||
| 17 | + */ | ||
| 18 | +@Path("/person") | ||
| 19 | +@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) | ||
| 20 | +public class PersonRestService { | ||
| 21 | + | ||
| 22 | + @GET | ||
| 23 | + @Path("/all") | ||
| 24 | + public List<Personnel> findAll(){ | ||
| 25 | + return PersonBufferData.findAll(); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + @GET | ||
| 29 | + @Path("/bx/all") | ||
| 30 | + public List<Personnel> findAllBx(){ | ||
| 31 | + List<Personnel> personnels = PersonBufferData.findByCompany("77"), result = new ArrayList<>(); | ||
| 32 | + for (Personnel personnel : personnels) { | ||
| 33 | + if ("78".equals(personnel.getBrancheCompanyCode())) { | ||
| 34 | + result.add(personnel); | ||
| 35 | + } | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + return result; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + @GET | ||
| 42 | + @Path("/company/{companyId}") | ||
| 43 | + public List<Personnel> findByCompany(@PathParam("companyId") String companyId) { | ||
| 44 | + return companyId.equals("-9999") ? PersonBufferData.findAll() : PersonBufferData.findByCompany(companyId); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + @GET | ||
| 48 | + @Path("/{workId}") | ||
| 49 | + public Personnel findOne(@PathParam("workId") String workId) { | ||
| 50 | + return PersonBufferData.findOne(workId); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + @POST | ||
| 54 | + @Path("/setCards") | ||
| 55 | + public Map<String, Object> multiPostCards(String bodyStr){ | ||
| 56 | + bodyStr = StringEscapeUtils.unescapeHtml4(bodyStr); | ||
| 57 | + List<PersonCardDto> list = JSON.parseObject(bodyStr, new TypeReference<List<PersonCardDto>>() {}); | ||
| 58 | + return PersonBufferData.multiSaveCards(list); | ||
| 59 | + } | ||
| 60 | +} |