Commit f5f800cb by chenweisong

更新

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