| | |
| | | package com.mindskip.xzs.controller.admin; |
| | | |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.mindskip.xzs.base.BaseApiController; |
| | | import com.mindskip.xzs.base.RestResponse; |
| | | import com.mindskip.xzs.domain.*; |
| | | import com.mindskip.xzs.domain.other.KeyValue; |
| | | import com.mindskip.xzs.domain.enums.UserStatusEnum; |
| | | import com.mindskip.xzs.domain.other.KeyValue; |
| | | import com.mindskip.xzs.domain.vo.UserVO; |
| | | import com.mindskip.xzs.repository.UserDepartmentMapper; |
| | | import com.mindskip.xzs.service.*; |
| | | import com.mindskip.xzs.utility.DateTimeUtil; |
| | | import com.mindskip.xzs.utility.PageInfoHelper; |
| | | import com.mindskip.xzs.utility.convert.UserClassConvert; |
| | | import com.mindskip.xzs.utility.excel.ExcelUtils; |
| | | import com.mindskip.xzs.viewmodel.admin.user.*; |
| | | import com.mindskip.xzs.utility.PageInfoHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | @RequestMapping(value = "/page/list", method = RequestMethod.POST) |
| | | public RestResponse<PageInfo<UserResponseVM>> pageList(@RequestBody UserPageRequestVM model) { |
| | | model.setDepartmentId(ObjectUtils.isNotEmpty(model.getDepartmentId()) ? model.getDepartmentId() : getAdminDeptIds()); |
| | | PageInfo<User> pageInfo = userService.userPage(model); |
| | | PageInfo<UserResponseVM> page = PageInfoHelper.copyMap(pageInfo, d -> |
| | | UserResponseVM.from(d)); |
| | | page.setList(page.getList().stream().map(e->{ |
| | | List<UserDepartment> userDepartments = userDepartmentMapper.selectByUserId(e.getId()); |
| | | String deptIds = ""; |
| | | List<Department> list = new ArrayList<>(); |
| | | for (UserDepartment userDepartment : userDepartments) { |
| | | Department byId = departmentService.getById(userDepartment.getDepartmentId()); |
| | | if(byId != null){ |
| | | deptIds = deptIds + byId.getName(); |
| | | break; |
| | | if (ObjectUtils.isNotEmpty(byId)) { |
| | | list.add(byId); |
| | | } |
| | | } |
| | | e.setDeptNames(deptIds); |
| | | e.setDeptNames(StringUtils.join(list.stream().map(Department::getName).collect(Collectors.toList()), ",")); |
| | | e.setDeptIdList(list.stream().map(Department::getId).collect(Collectors.toList())); |
| | | e.setTagNames(tagService.selectTagNamesByUserId(e.getId())); |
| | | return e; |
| | | }).collect(Collectors.toList())); |
| | |
| | | |
| | | @RequestMapping(value = "/changeStatus/{id}", method = RequestMethod.POST) |
| | | public RestResponse<Integer> changeStatus(@PathVariable Integer id) { |
| | | User user = userService.getUserById(id); |
| | | User user = userService.selectById(id); |
| | | UserStatusEnum userStatusEnum = UserStatusEnum.fromCode(user.getStatus()); |
| | | Integer newStatus = userStatusEnum == UserStatusEnum.Enable ? UserStatusEnum.Disable.getCode() : UserStatusEnum.Enable.getCode(); |
| | | user.setStatus(newStatus); |
| | |
| | | } |
| | | |
| | | return RestResponse.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/setStatus", method = RequestMethod.POST) |
| | | public RestResponse<String> setStatus(@RequestBody UserVO user) { |
| | | userService.setStatus(user); |
| | | return RestResponse.ok("操作成功"); |
| | | } |
| | | |
| | | } |