提交 176caa66 authored 作者: gongwenjie's avatar gongwenjie

接口注释,人员部分代码

上级 c00cc5c0
...@@ -2,6 +2,7 @@ package com.zjty.tynotes.pas.controller; ...@@ -2,6 +2,7 @@ package com.zjty.tynotes.pas.controller;
import com.zjty.tynotes.misc.config.AutoDocument; import com.zjty.tynotes.misc.config.AutoDocument;
import com.zjty.tynotes.pas.entity.User; import com.zjty.tynotes.pas.entity.User;
import com.zjty.tynotes.pas.entity.vo.PageRequest;
import com.zjty.tynotes.pas.service.IUserService; import com.zjty.tynotes.pas.service.IUserService;
import com.zjty.tynotes.pas.utils.LogoutUtil; import com.zjty.tynotes.pas.utils.LogoutUtil;
import com.zjty.tynotes.search.subject.service.EsUtil; import com.zjty.tynotes.search.subject.service.EsUtil;
...@@ -92,23 +93,11 @@ public class UserController { ...@@ -92,23 +93,11 @@ public class UserController {
@ApiOperation(value = "根据id查询用户", response = User.class) @ApiOperation(value = "根据id查询用户", response = User.class)
@GetMapping("/findUser/{id}") @GetMapping("/findUser/{id}")
public ResponseEntity addUser(@RequestBody @Valid String id) { public ResponseEntity findUser(@RequestBody @Valid String id) {
return ok(iUserService.findUserById(id)); return ok(iUserService.findUserById(id));
} }
//待完成
@ApiOperation(value = "查询人员列表", response = User.class)
@GetMapping("/findUser/{id}")
public ResponseEntity findUserList(String id,String deId,String sort) {
return ok(iUserService.findUserList(id,deId,sort));
}
@ApiOperation(value = "查询可查看部门列表", response = User.class)
@GetMapping("/findDepartmentList/{id}")
public ResponseEntity findDepartmentList(String id) {
return ok(iUserService.findDepartmentList(id));
}
......
...@@ -68,8 +68,24 @@ public interface PasUserDao extends MongoRepository<User, String> { ...@@ -68,8 +68,24 @@ public interface PasUserDao extends MongoRepository<User, String> {
*/ */
List<User> findAllByIdIn(List<String> ids); List<User> findAllByIdIn(List<String> ids);
/**
* 根绝用户名查询用户
* @param name
* @return
*/
List<User> findAllByUsername(String name); List<User> findAllByUsername(String name);
/**
* 根据部门id查询用户
* @param id
* @return
*/
List<User> findAllByDepartmentId(String id); List<User> findAllByDepartmentId(String id);
/**
* 根据部门列表查询用户
* @param departmentIds
* @return
*/
List<User> findAllByDepartmentIdIn(List<String> departmentIds);
} }
...@@ -91,6 +91,12 @@ public class User implements UserDetails, Serializable { ...@@ -91,6 +91,12 @@ public class User implements UserDetails, Serializable {
@Transient @Transient
private List<Role> roles; private List<Role> roles;
@Transient
private List<Work> works;
@Transient
private String status;//工作状态(0代表空闲 1代表忙碌)
// @NotNull(message = "角色Id不可为空") // @NotNull(message = "角色Id不可为空")
// @ApiModelProperty(value = "角色id",example = "1") // @ApiModelProperty(value = "角色id",example = "1")
// private Integer roleId; // private Integer roleId;
......
package com.zjty.tynotes.pas.entity.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author gwj
* @create 2020/3/2 11:02
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PageRequest {
/**
* 每页显示个数
*/
private int pageSize;
/**
* 当前页数
*/
private int currentPage;
/**
* 总页数
*/
private int totalPage;
/**
* 总记录数
*/
private int totalCount;
/**
* 访问人员id
*/
private String id;
/**
* 查询条件:部门id(默认查询所有可查询的所有人员)
*/
private String deId;
/**
* 查询条件:任务数量升降序(默认降序0 1升序)
*/
private Integer sort;
}
package com.zjty.tynotes.pas.entity.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
/**
* @Author gwj
* @create 2020/3/2 10:54
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PageResponse<T> implements Serializable {
private static final long serialVersionUID = 5760097915453738435L;
/**
* 每页显示个数
*/
private int pageSize;
/**
* 当前页数
*/
private int currentPage;
/**
* 总页数
*/
private int totalPage;
/**
* 总记录数
*/
private int totalCount;
/**
* 结果列表
*/
private List<T> rows;
public void setTotalCount(int totalCount) {
//设置了totalCount就可以计算出总totalPage
this.totalCount = totalCount;
int countRecords = this.getTotalCount();
int totalPages = countRecords % pageSize == 0 ? countRecords / pageSize : (countRecords / pageSize + 1);
setTotalPage(totalPages);
}
/**
* 设置结果 及总页数
* @param rows 分页之后查询到的结果
*/
public void build(List<T> rows) {
this.setRows(rows);
int count = this.getTotalCount();
int divisor = count / this.getPageSize();
int remainder = count % this.getPageSize();
//设置总页数, Trash code, confusing.
this.setTotalPage(remainder == 0 ? (divisor == 0 ? 1 : divisor) : divisor + 1);
//已在setTotalCount中进行
int countRecords = this.getTotalCount();
int totalPages = countRecords % pageSize == 0 ? countRecords / pageSize : (countRecords / pageSize + 1);
setTotalPage(totalPages);
}
public List<T> getRows() {
return rows;
}
public void setRows(List<T> rows) {
this.rows = rows;
}
}
...@@ -12,13 +12,38 @@ import java.util.List; ...@@ -12,13 +12,38 @@ import java.util.List;
* @create 2020/3/1 9:45 * @create 2020/3/1 9:45
*/ */
public interface ConfigService { public interface ConfigService {
/**
* 保存参数配置
* @param configs
* @return
*/
List<Config> save(List<Config> configs); List<Config> save(List<Config> configs);
/**
* 查找节假日
* @param holidayRequest
* @return
*/
List<Date> findHolidays(HolidayRequest holidayRequest); List<Date> findHolidays(HolidayRequest holidayRequest);
/**
* 批量设置节假日
* @param days
* @return
*/
List<Day> setHolidays(List<Day> days); List<Day> setHolidays(List<Day> days);
/**
* 设置单个节假日
* @param day
* @return
*/
Day setHoliday(Day day); Day setHoliday(Day day);
/**
* 查找某个月的节假日情况
* @param date
* @return
*/
List<Day> findHolidaysByMonth(String date); List<Day> findHolidaysByMonth(String date);
} }
...@@ -9,11 +9,30 @@ import java.util.List; ...@@ -9,11 +9,30 @@ import java.util.List;
* @author mcj * @author mcj
*/ */
public interface IAuthorityService { public interface IAuthorityService {
/**
* 添加权限
* @param authority
* @return
*/
Authority addAuthority(Authority authority); Authority addAuthority(Authority authority);
/**
* 删除权限
* @param id
* @return
*/
boolean deleteAuthority(String id); boolean deleteAuthority(String id);
/**
* 修改权限
* @param authority
* @return
*/
Authority updateAuthority(Authority authority); Authority updateAuthority(Authority authority);
/**
* 查找权限
* @return
*/
List<Authority> findAuthority(); List<Authority> findAuthority();
} }
...@@ -34,8 +34,10 @@ public interface IDepartmentService { ...@@ -34,8 +34,10 @@ public interface IDepartmentService {
*/ */
Department findOne(String id); Department findOne(String id);
/**
* 查找所有部门列表
* @return
*/
List<Department> findList(); List<Department> findList();
void getDepartments(List<Department> departments);
} }
...@@ -34,7 +34,17 @@ public interface IRoleService { ...@@ -34,7 +34,17 @@ public interface IRoleService {
*/ */
void deleteAll(); void deleteAll();
/**
* 修改角色
* @param role
* @return
*/
Boolean updateRole(Role role); Boolean updateRole(Role role);
/**
* 删除角色
* @param id
* @return
*/
boolean deleteRole(String id); boolean deleteRole(String id);
} }
...@@ -2,6 +2,8 @@ package com.zjty.tynotes.pas.service; ...@@ -2,6 +2,8 @@ package com.zjty.tynotes.pas.service;
import com.zjty.tynotes.pas.entity.Department; import com.zjty.tynotes.pas.entity.Department;
import com.zjty.tynotes.pas.entity.User; import com.zjty.tynotes.pas.entity.User;
import com.zjty.tynotes.pas.entity.vo.PageRequest;
import com.zjty.tynotes.pas.entity.vo.PageResponse;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import java.util.List; import java.util.List;
...@@ -73,9 +75,11 @@ public interface IUserService { ...@@ -73,9 +75,11 @@ public interface IUserService {
*/ */
String addUserCount(String username); String addUserCount(String username);
/**
* 新增用户
* @param user
* @return
*/
User addUser(User user); User addUser(User user);
List<User> findUserList(String id, String deId, String sort);
List<Department> findDepartmentList(String id);
} }
...@@ -54,7 +54,6 @@ public class DepartmentServiceImpl implements IDepartmentService { ...@@ -54,7 +54,6 @@ public class DepartmentServiceImpl implements IDepartmentService {
return departmentList; return departmentList;
} }
@Override
public void getDepartments(List<Department> departments) { public void getDepartments(List<Department> departments) {
for (Department department : departments) { for (Department department : departments) {
List<Department> departmentList = departmentDao.findAllByParentId(department.getId()); List<Department> departmentList = departmentDao.findAllByParentId(department.getId());
......
...@@ -2,6 +2,8 @@ package com.zjty.tynotes.pas.service.impl; ...@@ -2,6 +2,8 @@ package com.zjty.tynotes.pas.service.impl;
import com.zjty.tynotes.pas.dao.*; import com.zjty.tynotes.pas.dao.*;
import com.zjty.tynotes.pas.entity.*; import com.zjty.tynotes.pas.entity.*;
import com.zjty.tynotes.pas.entity.vo.PageRequest;
import com.zjty.tynotes.pas.entity.vo.PageResponse;
import com.zjty.tynotes.pas.service.IDepartmentService; import com.zjty.tynotes.pas.service.IDepartmentService;
import com.zjty.tynotes.pas.service.IUserService; import com.zjty.tynotes.pas.service.IUserService;
import com.zjty.tynotes.search.subject.service.EsUtil; import com.zjty.tynotes.search.subject.service.EsUtil;
...@@ -192,93 +194,5 @@ public class UserServiceImpl implements IUserService { ...@@ -192,93 +194,5 @@ public class UserServiceImpl implements IUserService {
return save; return save;
} }
@Override
public List<User> findUserList(String id, String deId, String sort) {
Optional<User> optional = pasUserDao.findById(id);
User user;
if(optional.isPresent()){
user = optional.get();
List<UserRole> userRoles = userRoleDao.findAllByUserId(user.getId());
List<String> roleIds = new ArrayList<>();
for (UserRole userRole : userRoles) {
if(!roleIds.contains(userRole.getRoleId())){
roleIds.add(userRole.getRoleId());
}
}
List<Role> roles = roleDao.findAllByIdIn(roleIds);
List<String> userIds = new ArrayList<>();
for (Role role : roles) {
String departmentId = role.getDepartmentId();
List<Authority> authorities = role.getAuthorities();
List<User> users2 = new ArrayList<>();
for (Authority authority : authorities) {
if("查看人员信息".equals(authority.getName())){
users2 = pasUserDao.findAllByDepartmentId(departmentId);
}
}
for (User user1 : users2) {
if(!userIds.contains(user1.getId())){
userIds.add(user1.getId());
}
}
}
}
return null;
}
@Override
public List<Department> findDepartmentList(String id) {
List<UserRole> userRoles = userRoleDao.findAllByUserId(id);
List<String> roleIds = new ArrayList<>();
for (UserRole userRole : userRoles) {
roleIds.add(userRole.getRoleId());
}
List<Role> roles = roleDao.findAllByIdIn(roleIds);
for (Role role : roles) {
List<RoleAuthority> roleAuthorities = roleAuthorityDao.findAllByRoleId(role.getId());
List<String> authorityIds = new ArrayList<>();
for (RoleAuthority roleAuthority : roleAuthorities) {
authorityIds.add(roleAuthority.getAuthorityId());
}
List<Authority> authorities = authorityDao.findAllByIdIn(authorityIds);
role.setAuthorities(authorities);
}
List<Role> roleList = new ArrayList<>();
for (Role role : roles) {
List<Authority> authorities = role.getAuthorities();
for (Authority authority : authorities) {
if("查看人员".equals(authority.getName())){
roleList.add(role);
}
}
}
if(roleList!=null){
for (Role role : roleList) {
}
}
return null;
}
private List<Department> findDepartmentList(List<Department> des, List<Department> deps){
for (Department department : deps) {
if(!des.contains(department)){
des.add(department);
}
}
for (Department department : deps) {
List<Department> departments = departmentDao.findAllByParentId(department.getId());
if(departments!=null){
findDepartmentList(des,departments);
}
}
return des;
}
} }
package com.zjty.tynotes.weekly.subject.controller;
import com.zjty.tynotes.misc.config.AutoDocument;
import com.zjty.tynotes.pas.entity.User;
import com.zjty.tynotes.pas.entity.vo.PageRequest;
import com.zjty.tynotes.weekly.subject.service.UserManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import static org.springframework.http.ResponseEntity.ok;
/**
* @Author gwj
* @create 2020/3/2 13:04
*/
@Api(tags = "人员管理模块", protocols = "http")
@RestController
@RequestMapping("/manage/user")
@AutoDocument
public class UserManageController {
@Autowired
private UserManageService userManageService;
@ApiOperation(value = "根据id查询用户", response = User.class)
@GetMapping("/findUser/{id}")
public ResponseEntity addUser(@RequestBody @Valid String id) {
return ok(userManageService.findUserById(id));
}
//待完成
@ApiOperation(value = "查询人员列表", response = User.class)
@GetMapping("/findUser/{id}")
public ResponseEntity findUserList(@RequestBody PageRequest pageRequest) {
return ok(userManageService.findUserList(pageRequest));
}
@ApiOperation(value = "查询可查看部门列表", response = User.class)
@GetMapping("/findDepartmentList/{id}")
public ResponseEntity findDepartmentList(@PathVariable("id") String id) {
return ok(userManageService.findDepartmentList(id));
}
@ApiOperation(value = "查询人员任务详情", response = User.class)
@GetMapping("/findUserWork/{id}/{status}")
public ResponseEntity findUserWork(@PathVariable("id") String id,
@PathVariable("status") String status) {
return ok(userManageService.findUserWork(id,status));
}
}
package com.zjty.tynotes.weekly.subject.controller;
import com.zjty.tynotes.misc.config.AutoDocument;
import com.zjty.tynotes.weekly.subject.entity.Weekly;
import com.zjty.tynotes.weekly.subject.entity.WeeklySimple;
import com.zjty.tynotes.weekly.subject.service.WeeklyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author LJJ cnljj1995@gmail.com
* on 2019-07-05
*/
@RestController
@RequestMapping("/weekly")
@AutoDocument
@Api(tags = "周报模块", value = "周报模块")
public class WebWeeklyController {
@Autowired
private WeeklyService weeklyService;
@PutMapping
@ApiOperation(value = "更新周报")
public ResponseEntity update(@RequestParam Weekly weekly) {
weeklyService.updateWeekly(weekly);
return ResponseEntity.ok(weekly);
}
@GetMapping
@ApiOperation(value = "根据id查找周报")
@ApiImplicitParams(
@ApiImplicitParam(name = "id", value = "周报id", dataType = "String",
example = "5cd92cb738693323e8ee3ba9", required = true)
)
public ResponseEntity<Weekly> findOne(@RequestParam String id) {
return ResponseEntity.ok(weeklyService.findOne(id));
}
@GetMapping("/findAll")
@ApiOperation(value = "根据用户id查找所有周报")
@ApiImplicitParams(
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "String",
example = "5cd92cb738693323e8ee3ba9", required = true)
)
public ResponseEntity<List<WeeklySimple>> findByUser(@RequestParam String userId) {
return ResponseEntity.ok(weeklyService.findALlByUser(userId));
}
}
package com.zjty.tynotes.weekly.subject.entity;
import com.zjty.tynotes.weekly.misc.TimeUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author LJJ cnljj1995@gmail.com
* on 2019-07-05
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "周报对象", description = "一条周报记录")
public class Weekly {
@ApiModelProperty(value = "主键id", name = "id", example = "qwer1234")
private String id = "";
@ApiModelProperty(value = "用户id", name = "userId", example = "qwer1234")
private String userId = "";
@ApiModelProperty(value = "周报标题", name = "taskId", example = "2019年01月01日 周报")
private String title = TimeUtil.longToString("yyyy年MM月dd日", System.currentTimeMillis()) + " 周报";
@ApiModelProperty(value = "创建时间", name = "createTime", example = "1500000000000")
private Long createTime = System.currentTimeMillis();
@ApiModelProperty(value = "更新时间", name = "updateTime", example = "1500000000000")
private Long updateTime = 0L;
@ApiModelProperty(value = "内容", name = "content", example = "这是内容")
private String content = "";
@ApiModelProperty(value = "问题备注", name = "problem", example = "这是问题备注")
private String problem = "";
@ApiModelProperty(value = "下周计划", name = "nextWeekPlan", example = "这是下周计划")
private String nextWeekPlan = "";
@ApiModelProperty(value = "备注", name = "remark", example = "这是备注")
private String remark = "";
}
package com.zjty.tynotes.weekly.subject.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author LJJ cnljj1995@gmail.com
* on 2019-07-05
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "周报简单对象", description = "周报的简单对象")
public class WeeklySimple {
@ApiModelProperty(value = "标题", name = "title", example = "2019年01月01日 周报")
private String title;
@ApiModelProperty(value = "用户id", name = "userId", example = "qweasd1234qqqwe")
private String userId;
@ApiModelProperty(value = "更新时间", name = "updateTime", example = "1560234567")
private Long updateTime;
}
package com.zjty.tynotes.weekly.subject.repository;
import com.zjty.tynotes.weekly.subject.entity.Weekly;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;
/**
* @author LJJ cnljj1995@gmail.com
* on 2019-07-05
*/
@Repository
public interface WeeklyRepository extends MongoRepository<Weekly, String> {
}
package com.zjty.tynotes.weekly.subject.service;
import com.zjty.tynotes.pas.entity.Department;
import com.zjty.tynotes.pas.entity.User;
import com.zjty.tynotes.pas.entity.vo.PageRequest;
import com.zjty.tynotes.pas.entity.vo.PageResponse;
import java.util.List;
/**
* @Author gwj
* @create 2020/3/2 13:07
*/
public interface UserManageService {
/**
* 根据id查询用户
* @param id
* @return
*/
User findUserById(String id);
/**
* 分页查询管理用户
* @param pageRequest
* @return
*/
PageResponse<User> findUserList(PageRequest pageRequest);
/**
* 根据用户id查询可管理的部门列表
* @param id
* @return
*/
List<Department> findDepartmentList(String id);
/**
* 根据任务状态查询人员任务列表
* @param id
* @param status
* @return
*/
List<Work> findUserWork(String id, String status);
}
package com.zjty.tynotes.weekly.subject.service;
import com.zjty.tynotes.weekly.subject.entity.Weekly;
import com.zjty.tynotes.weekly.subject.entity.WeeklySimple;
import java.util.List;
/**
* @author LJJ cnljj1995@gmail.com
* on 2019-07-05
*/
public interface WeeklyService {
/**
* 保存更新
* @param weekly
*/
void updateWeekly(Weekly weekly);
/**
* 创建任务
* @param userId
*/
void createWeekly(String userId);
/**
* 根据周报id查找周报
* @param id
* @return
*/
Weekly findOne(String id);
/**
* 根据user查找工作记录
* @param userId
* @return
*/
List<WeeklySimple> findALlByUser(String userId);
}
package com.zjty.tynotes.weekly.subject.service.impl;
import com.zjty.tynotes.pas.dao.*;
import com.zjty.tynotes.pas.entity.*;
import com.zjty.tynotes.pas.entity.vo.PageRequest;
import com.zjty.tynotes.pas.entity.vo.PageResponse;
import com.zjty.tynotes.weekly.subject.service.UserManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
* @Author gwj
* @create 2020/3/2 13:07
*/
@Service
public class UserManageServiceImpl implements UserManageService {
@Autowired
private PasUserDao pasUserDao;
@Autowired
private UserRoleDao userRoleDao;
@Autowired
private RoleDao roleDao;
@Autowired
private RoleAuthorityDao roleAuthorityDao;
@Autowired
private AuthorityDao authorityDao;
@Autowired
private DepartmentDao departmentDao;
@Override
public User findUserById(String id) {
Optional<User> optional = pasUserDao.findById(id);
User user = null;
if(optional.isPresent()){
user = optional.get();
List<String> roleIds = new ArrayList<>();
List<UserRole> userRoles = userRoleDao.findAllByUserId(user.getId());
for (UserRole userRole : userRoles) {
roleIds.add(userRole.getRoleId());
}
List<Role> roles = roleDao.findAllByIdIn(roleIds);
user.setRoles(roles);
}
return user;
}
/**
* 查询人员列表 待完成
* @param pageRequest
* @return
*/
@Override
public PageResponse<User> findUserList(PageRequest pageRequest) {
List<User> users = new ArrayList<>();
PageResponse<User> pageResponse = new PageResponse<>();
pageResponse.setCurrentPage(pageRequest.getCurrentPage());
pageResponse.setPageSize(pageRequest.getPageSize());
if(pageRequest.getDeId()!=null){
if(pageRequest.getSort()!=null && ("1").equals(pageRequest.getSort())){
users = pasUserDao.findAllByDepartmentId(pageRequest.getId());
if(pageRequest.getSort()!=null){
for (User user : users) {
//根据用户id查询任务数量
}
}
}else{
}
pageResponse.setTotalCount(users.size());
pageResponse.setRows(users);
pageResponse.build(users);
return pageResponse;
}else{
List<Department> departmentList = findDepartmentList(pageRequest.getId());
List<String> departmentIds = new ArrayList<>();
for (Department department : departmentList) {
departmentIds.add(department.getId());
}
users = pasUserDao.findAllByDepartmentIdIn(departmentIds);
}
return pageResponse;
}
/**
* 查询可查看的部门列表
* @param id
* @return
*/
@Override
public List<Department> findDepartmentList(String id) {
List<UserRole> userRoles = userRoleDao.findAllByUserId(id);
List<String> roleIds = new ArrayList<>();
for (UserRole userRole : userRoles) {
roleIds.add(userRole.getRoleId());
}
List<Role> roles = roleDao.findAllByIdIn(roleIds);
for (Role role : roles) {
List<RoleAuthority> roleAuthorities = roleAuthorityDao.findAllByRoleId(role.getId());
List<String> authorityIds = new ArrayList<>();
for (RoleAuthority roleAuthority : roleAuthorities) {
authorityIds.add(roleAuthority.getAuthorityId());
}
List<Authority> authorities = authorityDao.findAllByIdIn(authorityIds);
role.setAuthorities(authorities);
}
List<Role> roleList = new ArrayList<>();
for (Role role : roles) {
List<Authority> authorities = role.getAuthorities();
for (Authority authority : authorities) {
if("查看人员".equals(authority.getName())){
roleList.add(role);
}
}
}
List<Department> departments = new ArrayList<>();
if(roleList!=null){
for (Role role : roleList) {
String departmentId = role.getDepartmentId();
List<Department> departmentList = departmentDao.findAllByParentId(departmentId);
findDepartmentList(departments,departmentList);
}
return departments;
}
return departments;
}
/**
* 待完成,需要任务提供接口
* @param id
* @param status
* @return
*/
@Override
public List<Work> findUserWork(String id, String status) {
List<Work> works = workDao.find(id,status);
return works;
}
private List<Department> findDepartmentList(List<Department> des, List<Department> deps){
for (Department department : deps) {
if(!des.contains(department)){
des.add(department);
}
}
for (Department department : deps) {
List<Department> departments = departmentDao.findAllByParentId(department.getId());
if(departments!=null){
findDepartmentList(des,departments);
}
}
return des;
}
}
package com.zjty.tynotes.weekly.subject.service.impl;
import com.zjty.tynotes.weekly.subject.entity.Weekly;
import com.zjty.tynotes.weekly.subject.entity.WeeklySimple;
import com.zjty.tynotes.weekly.subject.repository.WeeklyRepository;
import com.zjty.tynotes.weekly.subject.service.WeeklyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* @author LJJ cnljj1995@gmail.com
* on 2019-07-05
*/
@Service
public class WeeklyServiceImpl implements WeeklyService {
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
private WeeklyRepository weeklyRepository;
@Override
public void updateWeekly(Weekly weekly) {
weekly.setUpdateTime(System.currentTimeMillis());
weeklyRepository.save(weekly);
}
@Override
public void createWeekly(String userId) {
Weekly weekly = new Weekly();
weekly.setUserId(userId);
weeklyRepository.save(weekly);
}
@Override
public Weekly findOne(String id) {
Criteria criteria = new Criteria();
criteria.and("_id").is(id);
Query query = new Query(criteria);
return mongoTemplate.findOne(query, Weekly.class);
}
@Override
public List<WeeklySimple> findALlByUser(String userId) {
Criteria criteria = new Criteria();
criteria.and("userId").is(userId);
Query query = new Query(criteria);
query.with(new Sort(Sort.Direction.DESC, "createTime"));
List<Weekly> weeklies = mongoTemplate.find(query, Weekly.class);
return weekly2simple(weeklies);
}
private List<WeeklySimple> weekly2simple(List<Weekly> weeklies) {
List<WeeklySimple> rs = new ArrayList<>();
weeklies.forEach(o -> rs.add(new WeeklySimple(o.getTitle(), o.getUserId(), o.getUpdateTime())));
return rs;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论