提交 1adff340 authored 作者: 黄夏豪's avatar 黄夏豪

项目完善

上级 bf66e8d9
......@@ -6,6 +6,7 @@ import com.example.personnelmanager.dao.SimpleJpaRepositoryImpl;
import gnu.io.CommPortIdentifier;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
......@@ -22,11 +23,11 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
*/
@EnableAsync
@EnableScheduling
//@EnableDiscoveryClient
@SpringBootApplication
@EnableSwagger2
@EnableJpaAuditing
@EnableJpaRepositories(repositoryBaseClass = SimpleJpaRepositoryImpl.class)
@ServletComponentScan
public class PersonnelmanagerApplication extends SpringBootServletInitializer {
......@@ -34,8 +35,8 @@ public class PersonnelmanagerApplication extends SpringBootServletInitializer {
SpringApplication.run(PersonnelmanagerApplication.class, args);
//todo 初始化一个初始企业 初始化一个admin 初始化一个节点
System.out.println("程序运行成功");
DateCenterUtil dateCenterUtil = SpringUtils.getBean("dateCenterUtil");
dateCenterUtil.sendDateToCenter();
// DateCenterUtil dateCenterUtil = SpringUtils.getBean("dateCenterUtil");
// dateCenterUtil.sendDateToCenter();
// dateCenterUtil.initUser();
}
......
......@@ -28,11 +28,12 @@ public class JWTAuthorizationFilter extends BasicAuthenticationFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
if (request.getHeader("jwt")!=null){
if (request.getHeader("token")!=null){
System.out.println("1");
}
// 如果请求头中有token,则进行解析,并且设置认证信息
SecurityContextHolder.getContext().setAuthentication( new UsernamePasswordAuthenticationToken("username", null,
SecurityContextHolder.getContext().setAuthentication(
new UsernamePasswordAuthenticationToken("username", null,
Collections.singleton(new SimpleGrantedAuthority("ROLE_ADMIN"))
));
super.doFilterInternal(request, response, chain);
......
......@@ -7,7 +7,6 @@ import com.example.personnelmanager.common.authencation.filter.CustomJwtAuthenti
import com.example.personnelmanager.common.authencation.filter.CustomUsernamePasswordAuthenticationFilter;
import com.example.personnelmanager.entity.commonEntity.ResultObj;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
......
......@@ -45,7 +45,7 @@ public class DateCenterJsonUtil {
*/
public String initAllPeopleJsonStr(List<People> allPeople){
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("tableId",1320331389656211458L);
jsonObject.addProperty("tableId",1346658905505366017L);
jsonObject.addProperty("primaryKeyName","people_id");
JsonArray jsonElements = new JsonArray();
allPeople.forEach(people -> {
......@@ -106,7 +106,7 @@ public class DateCenterJsonUtil {
*/
public String initAllOrganizationNodeJsonStr(List<OrganizationNode> allNode){
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("tableId",1320331411160408065L);
jsonObject.addProperty("tableId",1346658965509079041L);
jsonObject.addProperty("primaryKeyName","node_id");
JsonArray jsonElements = new JsonArray();
allNode.forEach(node -> {
......
......@@ -12,6 +12,7 @@ import com.example.personnelmanager.service.UserServer;
import com.github.wenhao.jpa.PredicateBuilder;
import com.github.wenhao.jpa.Specifications;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Component;
......@@ -29,6 +30,9 @@ import java.util.List;
@Component
public class DateCenterUtil {
@Value("${dataCenter}")
public String dataCenterIp;
@Autowired
PeopleRepository peopleRepository;
......@@ -50,10 +54,10 @@ public class DateCenterUtil {
public void sendDateToCenter(){
// 将数据库中的人员数据存放到数据中心
List<People> allPeople = peopleRepository.findAll();
httpClientUtil.post("http://124.70.194.194:8090/opt/data", jsonUtil.initAllPeopleJsonStr(allPeople), "utf-8");
httpClientUtil.post("http://"+dataCenterIp+"/opt/data", jsonUtil.initAllPeopleJsonStr(allPeople), "utf-8");
// 将数据库中的部门信息存放到数据中心
List<OrganizationNode> allNode = organizationNodeRepository.findAll();
httpClientUtil.post("http://124.70.194.194:8090/opt/data", jsonUtil.initAllOrganizationNodeJsonStr(allNode), "utf-8");
httpClientUtil.post("http://"+dataCenterIp+"/opt/data", jsonUtil.initAllOrganizationNodeJsonStr(allNode), "utf-8");
};
public void initUser(){
......
......@@ -62,7 +62,7 @@ public class UserController {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("appId", "35");
jsonObject.addProperty("des", "请用户完善系统中人员信息");
jsonObject.addProperty("link", "http://192.168.100.248:8080/personnel");
jsonObject.addProperty("link", "http://192.168.100.246:8080/personnel");
jsonObject.addProperty("title", "请用户完善人员信息");
jsonObject.addProperty("userId", "1");
String post = httpClientUtil.post(centerServe + "/task/add", jsonObject.toString(), "utf-8");
......
......@@ -35,6 +35,7 @@ import java.util.List;
public class People {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "people_id",columnDefinition = "bigint comment '人员编号' ")
private Long peopleId;
......
......@@ -21,7 +21,8 @@ import java.util.List;
public class UserDetail extends User implements UserDetails {
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
public Collection<?
extends GrantedAuthority> getAuthorities() {
List<GrantedAuthority> simpleGrantedAuthorities = new ArrayList<>();
return simpleGrantedAuthorities;
}
......
......@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import javax.persistence.EntityManager;
......@@ -69,6 +70,7 @@ public class AgainEntryInformationServiceImpl implements AgainEntryInformationSe
AgainEntryInformation againEntryInformation = byId.get();
againEntryInformation.setDeleteTag(1);
againEntryInformationRepository.save(againEntryInformation);
return true;
}
......
......@@ -18,6 +18,7 @@ import com.github.wenhao.jpa.PredicateBuilder;
import com.github.wenhao.jpa.Specifications;
import javafx.geometry.Pos;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
......@@ -40,6 +41,9 @@ import java.util.stream.Collectors;
@Transactional
public class OrganizationNodeServiceImpl implements OrganizationNodeService {
@Value("${dataCenter}")
public String dataCenterIp;
@Autowired
OrganizationNodeRepository organizationNodeRepository;
......@@ -73,7 +77,7 @@ public class OrganizationNodeServiceImpl implements OrganizationNodeService {
organizationNode.setEnterprise(userDetails.getEnterprise());
OrganizationNode save = organizationNodeRepository.save(organizationNode);
executorService.submit(() -> {
httpClientUtil.post("http://124.70.194.194:8090/opt/data", dateCenterJsonUtil.initAllOrganizationNodeJsonStr(Arrays.asList(save)), "utf-8");
httpClientUtil.post("http://"+dataCenterIp+"/opt/data", dateCenterJsonUtil.initAllOrganizationNodeJsonStr(Arrays.asList(save)), "utf-8");
});
return save;
}
......@@ -173,7 +177,7 @@ public class OrganizationNodeServiceImpl implements OrganizationNodeService {
OrganizationNode after = organizationNodeRepository.save(organizationNode);
//向数据中心修改旧的数据
executorService.submit(() -> {
httpClientUtil.put("http://124.70.194.194:8090/opt/data", dateCenterJsonUtil.initAllOrganizationNodeJsonStr(Arrays.asList(after)), "utf-8");
httpClientUtil.put("http://"+dataCenterIp+":8090/opt/data", dateCenterJsonUtil.initAllOrganizationNodeJsonStr(Arrays.asList(after)), "utf-8");
});
return after;
}
......@@ -210,7 +214,7 @@ public class OrganizationNodeServiceImpl implements OrganizationNodeService {
});
//向数据中心修改旧的数据
executorService.submit(() -> {
httpClientUtil.put("http://124.70.194.194:8090/opt/data", dateCenterJsonUtil.initAllOrganizationNodeJsonStr(Arrays.asList(one)), "utf-8");
httpClientUtil.put("http://"+dataCenterIp+"/opt/data", dateCenterJsonUtil.initAllOrganizationNodeJsonStr(Arrays.asList(one)), "utf-8");
});
return true;
}
......
......@@ -12,6 +12,7 @@ import com.example.personnelmanager.service.PeoplePostService;
import com.github.wenhao.jpa.PredicateBuilder;
import com.github.wenhao.jpa.Specifications;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
......@@ -35,6 +36,9 @@ import java.util.concurrent.ExecutorService;
@Service
public class PeoplePostServiceImpl implements PeoplePostService {
@Value("${dataCenter}")
public String dataCenterIp;
@Autowired
DateCenterJsonUtil dateCenterJsonUtil;
......@@ -68,7 +72,7 @@ public class PeoplePostServiceImpl implements PeoplePostService {
}
PeoplePost save = peoplePostRepository.save(peoplePost);
executorService.submit(() -> {
httpClientUtil.put("http://124.70.194.194:8090/opt/data", dateCenterJsonUtil.initAllPeopleJsonStr(Arrays.asList(peopleRepository.getOne(save.getPeople().getPeopleId()))), "utf-8");
httpClientUtil.put("http://"+dataCenterIp+"/opt/data", dateCenterJsonUtil.initAllPeopleJsonStr(Arrays.asList(peopleRepository.getOne(save.getPeople().getPeopleId()))), "utf-8");
});
return save;
}
......@@ -89,7 +93,7 @@ public class PeoplePostServiceImpl implements PeoplePostService {
public PeoplePost update(PeoplePost peoplePost) {
PeoplePost save = peoplePostRepository.save(peoplePost);
executorService.submit(() -> {
httpClientUtil.put("http://124.70.194.194:8090/opt/data", dateCenterJsonUtil.initAllPeopleJsonStr(Arrays.asList(peopleRepository.getOne(save.getPeople().getPeopleId()))), "utf-8");
httpClientUtil.put("http://"+dataCenterIp+"/opt/data", dateCenterJsonUtil.initAllPeopleJsonStr(Arrays.asList(peopleRepository.getOne(save.getPeople().getPeopleId()))), "utf-8");
});
return save;
......
......@@ -7,17 +7,15 @@ import com.example.personnelmanager.common.utils.DateCenterJsonUtil;
import com.example.personnelmanager.common.utils.HttpClientUtil;
import com.example.personnelmanager.dao.PeopleRepository;
import com.example.personnelmanager.entity.*;
import com.example.personnelmanager.entity.vo.PeopleVo;
import com.example.personnelmanager.entity.vo.pageableVo.PeoplePageableVo;
import com.example.personnelmanager.service.*;
import com.github.wenhao.jpa.PredicateBuilder;
import com.github.wenhao.jpa.Specifications;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
......@@ -41,6 +39,9 @@ import java.util.concurrent.ExecutorService;
@Service
public class PeopleServiceImpl implements PeopleService {
@Value("${dataCenter}")
public String dataCenterIp;
@Autowired
PeopleRepository peopleRepository;
......@@ -107,9 +108,9 @@ public class PeopleServiceImpl implements PeopleService {
user.setPhone(people.getPhone());
userServer.addEntity(user);
// //向数据中心插入新的数据
// executorService.submit(() -> {
// httpClientUtil.post("http://124.70.194.194:8090/opt/data", dateCenterJsonUtil.initAllPeopleJsonStr(Arrays.asList(save)), "utf-8");
// });
executorService.submit(() -> {
httpClientUtil.post("http://"+dataCenterIp+"/opt/data", dateCenterJsonUtil.initAllPeopleJsonStr(Arrays.asList(save)), "utf-8");
});
return save;
}
......@@ -141,7 +142,7 @@ public class PeopleServiceImpl implements PeopleService {
People after = peopleRepository.save(people);
//向数据中心修改旧的数据
executorService.submit(() -> {
httpClientUtil.put("http://124.70.194.194:8090/opt/data", dateCenterJsonUtil.initAllPeopleJsonStr(Arrays.asList(after)), "utf-8");
httpClientUtil.put("http://"+dataCenterIp+"/opt/data", dateCenterJsonUtil.initAllPeopleJsonStr(Arrays.asList(after)), "utf-8");
});
return after;
}
......@@ -166,7 +167,7 @@ public class PeopleServiceImpl implements PeopleService {
People after = peopleRepository.save(people);
//向数据中心修改旧的数据
executorService.submit(() -> {
httpClientUtil.put("http://124.70.194.194:8090/opt/data", dateCenterJsonUtil.initAllPeopleJsonStr(Arrays.asList(after)), "utf-8");
httpClientUtil.put("http://"+dataCenterIp+"/opt/data", dateCenterJsonUtil.initAllPeopleJsonStr(Arrays.asList(after)), "utf-8");
});
return true;
}
......
package com.example.personnelmanager.service.impl;
import com.example.personnelmanager.entity.Enterprise;
import com.example.personnelmanager.entity.People;
import com.example.personnelmanager.entity.User;
import com.example.personnelmanager.entity.UserDetail;
import com.example.personnelmanager.service.UserServer;
......
......@@ -12,6 +12,8 @@ file:
#center:
# ip: 124.70.194.194
# serve: http://124.70.194.194:12346
##Eureka设置
#eureka:
# instance:
......@@ -72,4 +74,6 @@ spring:
center:
ip: 124.70.194.194
serve: http://124.70.194.194:11324
\ No newline at end of file
serve: http://124.70.194.194:11324
dataCenter: 192.168.100.246:8090
......@@ -10,8 +10,9 @@ file:
# serverAddress: 124.70.194.194:${server.port}
#
center:
ip: 124.70.194.194
serve: http://124.70.194.194:11324
ip: 127.0.0.1
serve: http://127.0.0.1:11324
##Eureka设置
#eureka:
# instance:
......@@ -64,10 +65,10 @@ center:
# com.zjty: debug
# dao: debug
dataCenter: 192.168.100.246:8090
spring:
datasource:
username: hxh
password: Qwert123123
url: jdbc:mysql://124.70.145.101:3306/personnelManager?useSSL=false&serverTimezone=UTC&characterEncoding=utf-8
username: root
password: root
url: jdbc:mysql://192.168.100.246:3306/personnelManager?useSSL=false&serverTimezone=UTC&characterEncoding=utf-8
# dao: debug
\ No newline at end of file
......@@ -28,4 +28,5 @@ spring:
sql-dialect: MySQL5Dialect
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
\ No newline at end of file
time-zone: GMT+8
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论