|
@@ -1,11 +1,16 @@
|
|
|
package com.ozs.web.controller.system;
|
|
|
|
|
|
+import java.io.InputStream;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
+import com.ozs.common.utils.file.FileUtils;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -34,6 +39,7 @@ import com.ozs.system.service.ISysUserService;
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/system/user")
|
|
|
+@Slf4j
|
|
|
public class SysUserController extends BaseController {
|
|
|
@Autowired
|
|
|
private ISysUserService userService;
|
|
@@ -73,8 +79,8 @@ public class SysUserController extends BaseController {
|
|
|
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
|
|
|
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
|
|
List<SysUser> userList = util.importExcel(file.getInputStream());
|
|
|
- String operName = getUsername();
|
|
|
- String message = userService.importUser(userList, updateSupport, operName);
|
|
|
+ String userId = getUserId();
|
|
|
+ String message = userService.importUser(userList, updateSupport, userId);
|
|
|
return success(message);
|
|
|
}
|
|
|
|
|
@@ -84,6 +90,19 @@ public class SysUserController extends BaseController {
|
|
|
util.importTemplateExcel(response, "用户数据");
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation("用户管理信息模板下载")
|
|
|
+ @GetMapping("/downloaExcel")
|
|
|
+ public void downloadZip(HttpServletResponse response) {
|
|
|
+ try {
|
|
|
+ InputStream resourceAsStream = this.getClass().getResourceAsStream("/SysUser.xlsx");
|
|
|
+ response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
|
|
+ FileUtils.setAttachmentResponseHeader(response, "用户管理信息模板.xlsx");
|
|
|
+ FileUtils.writeBytesByInput(resourceAsStream, response.getOutputStream());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("下载文件失败", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 根据用户编号获取详细信息
|
|
|
*/
|
|
@@ -232,4 +251,17 @@ public class SysUserController extends BaseController {
|
|
|
public AjaxResult deptTree(SysDept dept) {
|
|
|
return success(deptService.selectDeptTreeList(dept));
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 数据权限分配
|
|
|
+ */
|
|
|
+ @GetMapping("/dataPermission/{id}/{dataPermission}")
|
|
|
+ @ApiOperation("数据权限分配")
|
|
|
+ public AjaxResult dataPermission(@PathVariable("id") Long id,@PathVariable("dataPermission") Integer dataPermission) {
|
|
|
+ if (userService.dataPermission(id,dataPermission)){
|
|
|
+ return success();
|
|
|
+ }else {
|
|
|
+ return error();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|