Commit f5f800cb by chenweisong

更新

parent c5890078
...@@ -24,10 +24,10 @@ ...@@ -24,10 +24,10 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency> <!-- <dependency>-->
<groupId>org.springframework.boot</groupId> <!-- <groupId>org.springframework.boot</groupId>-->
<artifactId>spring-boot-starter-data-mongodb</artifactId> <!-- <artifactId>spring-boot-starter-data-mongodb</artifactId>-->
</dependency> <!-- </dependency>-->
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
...@@ -138,11 +138,11 @@ ...@@ -138,11 +138,11 @@
<artifactId>spring-boot-starter-actuator</artifactId> <artifactId>spring-boot-starter-actuator</artifactId>
</dependency> </dependency>
<!-- <dependency>--> <!-- <dependency>-->
<!-- <groupId>org.springframework.security</groupId>--> <!-- <groupId>org.springframework.security</groupId>-->
<!-- <artifactId>spring-security-config</artifactId>--> <!-- <artifactId>spring-security-config</artifactId>-->
<!-- <version>${spring-security.version}</version>--> <!-- <version>${spring-security.version}</version>-->
<!-- </dependency>--> <!-- </dependency>-->
<!-- activiti end --> <!-- activiti end -->
......
...@@ -18,7 +18,8 @@ public class UserController { ...@@ -18,7 +18,8 @@ public class UserController {
private UserService userService; private UserService userService;
@Autowired @Autowired
private GroupService groupService; private GroupService groupService;
@Autowired
private RecordScopeService recordScopeService;
private Group root = new Group(); private Group root = new Group();
...@@ -29,20 +30,27 @@ public class UserController { ...@@ -29,20 +30,27 @@ public class UserController {
root.setParentId(Group.ROOT_LEVEL); root.setParentId(Group.ROOT_LEVEL);
} }
@ApiOperation(value = "获取补录范围列表") @ApiOperation(value = "获取补录人员列表")
@PostMapping(value = "/user/list") @PostMapping(value = "/user/list")
public ApiResponse getUserList() { public ApiResponse getUserList() {
// List<User> userList = userService.findAllByRole(UserConstant.ROLE_NORMAL); List<User> userList = userService.findAll();
return ApiResponse.ok(); return ApiResponse.ok(userList);
} }
@ApiOperation(value = "获取补录范围列表") @ApiOperation(value = "获取补录范围列表")
@PostMapping(value = "/extent/list") @PostMapping(value = "/scope/list")
public ApiResponse getExtentList() { public ApiResponse getExtentList() {
// List<User> userList = userService.findAllByRole(UserConstant.ROLE_NORMAL); List<RecordScope> recordScopeList = recordScopeService.findAll();
return ApiResponse.ok(); return ApiResponse.ok(recordScopeList);
} }
// @ApiOperation(value = "补录范围绑定人员")
// @PostMapping(value = "/scope/bindUser")
// public ApiResponse getExtentList() {
// List<RecordScope> recordScopeList = recordScopeService.findAll();
// return ApiResponse.ok(recordScopeList);
// }
@ApiOperation(value = "获取机构数据") @ApiOperation(value = "获取机构数据")
@PostMapping(value = "/group/list") @PostMapping(value = "/group/list")
public ApiResponse getGroupList() { public ApiResponse getGroupList() {
......
...@@ -3,5 +3,10 @@ package com.keymobile.rest.dao; ...@@ -3,5 +3,10 @@ package com.keymobile.rest.dao;
import com.keymobile.rest.model.RecordScope; import com.keymobile.rest.model.RecordScope;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface RecordScopeDao extends JpaRepository<RecordScope, Long> { public interface RecordScopeDao extends JpaRepository<RecordScope, Long> {
List<RecordScope> findAllByGroupId(long groupId);
} }
...@@ -7,4 +7,6 @@ import java.util.List; ...@@ -7,4 +7,6 @@ import java.util.List;
public interface UserDao extends JpaRepository<User, Long> { public interface UserDao extends JpaRepository<User, Long> {
List<User> findAllByIdIn(List<Long> ids); List<User> findAllByIdIn(List<Long> ids);
List<User> findAllByGroupId(long groupId);
} }
package com.keymobile.rest.service; package com.keymobile.rest.service;
import com.keymobile.rest.dao.GroupDao; import com.keymobile.rest.dao.GroupDao;
import com.keymobile.rest.dao.UserDao;
import com.keymobile.rest.model.Group; import com.keymobile.rest.model.Group;
import com.keymobile.rest.model.RecordScope;
import com.keymobile.rest.model.User;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.List; import java.util.List;
@Service @Service
...@@ -13,6 +17,27 @@ public class GroupService { ...@@ -13,6 +17,27 @@ public class GroupService {
@Autowired @Autowired
private GroupDao groupDao; private GroupDao groupDao;
@Autowired
private UserDao userDao;
@PostConstruct
private void init() {
List<Group> groupList = groupDao.findAll();
groupList.forEach(group -> {
List<User> userList = userDao.findAllByGroupId(group.getId());
if (userList.size() == 0) {
String groupName = group.getName();
User user = new User();
user.setGroup(group);
user.setUsername(groupName);
userDao.save(user);
user.setUsername(groupName + "员工" + user.getId());
userDao.save(user);
}
});
}
public List<Group> findAllByParentId(long parentId) { public List<Group> findAllByParentId(long parentId) {
return groupDao.findAllByParentId(parentId); return groupDao.findAllByParentId(parentId);
} }
......
package com.keymobile.rest.service; package com.keymobile.rest.service;
import com.keymobile.rest.dao.GroupDao;
import com.keymobile.rest.dao.RecordScopeDao; import com.keymobile.rest.dao.RecordScopeDao;
import com.keymobile.rest.model.Group;
import com.keymobile.rest.model.RecordScope;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.List;
@Service @Service
public class RecordScopeService { public class RecordScopeService {
@Autowired @Autowired
private RecordScopeDao recordScopeDao; private RecordScopeDao recordScopeDao;
@Autowired
private GroupDao groupDao;
@PostConstruct
private void init() {
List<Group> groupList = groupDao.findAll();
// 每个机构创建两条补录范围供填写
groupList.forEach(group -> {
List<RecordScope> exists = recordScopeDao.findAllByGroupId(group.getId());
if (exists.size() != 2) {
RecordScope scope = new RecordScope();
scope.setGroup(group);
scope.setRole(RecordScope.ROLE_RECORD);
recordScopeDao.save(scope);
scope = new RecordScope();
scope.setGroup(group);
scope.setRole(RecordScope.ROLE_AUDIT);
recordScopeDao.save(scope);
}
});
}
public List<RecordScope> findAll() {
return recordScopeDao.findAll();
}
} }
...@@ -17,4 +17,8 @@ public class UserService { ...@@ -17,4 +17,8 @@ public class UserService {
return userDao.findAllByIdIn(ids); return userDao.findAllByIdIn(ids);
} }
public List<User> findAll() {
return userDao.findAll();
}
} }
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