|
|
@@ -26,11 +26,15 @@ import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
-import java.io.IOException;
|
|
|
+import java.io.*;
|
|
|
import java.util.List;
|
|
|
import java.util.Set;
|
|
|
|
|
|
@@ -52,7 +56,8 @@ public class UserController {
|
|
|
private UserService userService;
|
|
|
@Autowired
|
|
|
private TokenService tokenService;
|
|
|
- private final static UsageBufferedLogger logger = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
|
|
|
+
|
|
|
+ private final static UsageBufferedLogger LOGGER = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
|
|
|
|
|
|
/**
|
|
|
* 分页查看全部用户信息
|
|
|
@@ -64,11 +69,7 @@ public class UserController {
|
|
|
@RequestMapping(method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
|
public SPage<User> getUsers(PageParams params, String keyword) {
|
|
|
- if (null != keyword) {
|
|
|
- logger.log("用户信息", "通过[" + keyword.trim() +"]搜索查看用户信息");
|
|
|
- } else {
|
|
|
- logger.log("用户信息", "查看所有用户信息");
|
|
|
- }
|
|
|
+ LOGGER.log("用户信息", "查看用户信息", "关键词: " + keyword);
|
|
|
PageInfo pageInfo = new PageInfo(params);
|
|
|
return userService.findByPageInfo(pageInfo, keyword);
|
|
|
}
|
|
|
@@ -82,7 +83,7 @@ public class UserController {
|
|
|
@RequestMapping(value = "/info", method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
|
public Set<User> getUsersByKeyword(String keyword) {
|
|
|
- logger.log("用户信息", "通过[" + keyword.trim() +"]搜索查看用户信息");
|
|
|
+ LOGGER.log("用户信息", "通过[" + keyword.trim() +"]搜索查看用户信息");
|
|
|
return userService.findUsersByKeyWord(keyword.trim());
|
|
|
}
|
|
|
|
|
|
@@ -95,7 +96,7 @@ public class UserController {
|
|
|
@RequestMapping(value = "/customer/{uu}", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
public List<User> getUsersAndDistribute(@PathVariable("uu") Long custUu) {
|
|
|
- logger.log("用户信息", "查询[" + custUu +"]客户分配信息");
|
|
|
+ LOGGER.log("用户信息", "查询[" + custUu +"]客户分配信息");
|
|
|
return userService.findUserInfoDistribute(custUu);
|
|
|
}
|
|
|
|
|
|
@@ -112,7 +113,7 @@ public class UserController {
|
|
|
} else {
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
headers.add("Content-Type", "application/text; charset=utf-8");
|
|
|
- return new ResponseEntity<Boolean>(userService.isTelUseable(tel.replaceAll("\\s*", "")), headers,
|
|
|
+ return new ResponseEntity<>(userService.isTelUseable(tel.replaceAll("\\s*", "")), headers,
|
|
|
HttpStatus.OK);
|
|
|
}
|
|
|
}
|
|
|
@@ -164,7 +165,7 @@ public class UserController {
|
|
|
if (result) {
|
|
|
return new ResponseEntity<String>(HttpStatus.OK);
|
|
|
}
|
|
|
- logger.log("用户信息", "验证用户密码,UU:" + user.getUserUU());
|
|
|
+ LOGGER.log("用户信息", "验证用户密码,UU:" + user.getUserUU());
|
|
|
}
|
|
|
return new ResponseEntity<String>(HttpStatus.EXPECTATION_FAILED);
|
|
|
}
|
|
|
@@ -186,8 +187,8 @@ public class UserController {
|
|
|
user.setEnterprise(enterprise);
|
|
|
session.setAttribute("user", user);
|
|
|
SystemSession.setUser(user);
|
|
|
- logger.log("用户信息", "修改用户密码,UU:" + user.getUserUU());
|
|
|
- return new ResponseEntity<String>(HttpStatus.OK);
|
|
|
+ LOGGER.log("用户信息", "修改用户密码,UU:" + user.getUserUU());
|
|
|
+ return new ResponseEntity<>(HttpStatus.OK);
|
|
|
} else {
|
|
|
throw new IllegalOperatorException("新密码不能为空");
|
|
|
}
|
|
|
@@ -204,7 +205,7 @@ public class UserController {
|
|
|
User user = FlexJsonUtils.fromJson(json, User.class);
|
|
|
user = userService.addUser(user, request);
|
|
|
if (user != null) {
|
|
|
- logger.log("用户信息", "新增用户,姓名:" + user.getUserName());
|
|
|
+ LOGGER.log("用户信息", "新增用户,姓名:" + user.getUserName());
|
|
|
}
|
|
|
return new ResponseEntity<String>(HttpStatus.OK);
|
|
|
}
|
|
|
@@ -219,7 +220,7 @@ public class UserController {
|
|
|
User user = FlexJsonUtils.fromJson(json, User.class);
|
|
|
user = userService.updateUserInfo(user);
|
|
|
if (user != null) {
|
|
|
- logger.log("用户信息", "修改用户信息,UU:" + user.getUserUU());
|
|
|
+ LOGGER.log("用户信息", "修改用户信息,UU:" + user.getUserUU());
|
|
|
if (SystemSession.getUser().getUserUU().equals(user.getUserUU())) {
|
|
|
request.getSession().setAttribute("user", user);
|
|
|
}
|
|
|
@@ -238,7 +239,7 @@ public class UserController {
|
|
|
User user = FlexJsonUtils.fromJson(json, User.class);
|
|
|
user = userService.updateUserRole(user);
|
|
|
if (user != null) {
|
|
|
- logger.log("用户信息", "修改用户权限,UU:" + user.getUserUU());
|
|
|
+ LOGGER.log("用户信息", "修改用户权限,UU:" + user.getUserUU());
|
|
|
if (SystemSession.getUser().getUserUU().equals(user.getUserUU())) {
|
|
|
request.getSession().setAttribute("user", user);
|
|
|
}
|
|
|
@@ -255,7 +256,7 @@ public class UserController {
|
|
|
@RequestMapping(value = "/{uu}", method = RequestMethod.DELETE)
|
|
|
public ResponseEntity<String> removeUser(@PathVariable("uu") Long uu) {
|
|
|
userService.removeUser(uu);
|
|
|
- logger.log("用户信息", "删除用户,UU:" + uu);
|
|
|
+ LOGGER.log("用户信息", "删除用户,UU:" + uu);
|
|
|
return new ResponseEntity<String>(HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
@@ -284,7 +285,8 @@ public class UserController {
|
|
|
@ResponseBody
|
|
|
public ResponseEntity<String> bindUser(Long userUU) {
|
|
|
userService.bindUserToMyEnterprise(userUU);
|
|
|
- return new ResponseEntity<String>(HttpStatus.OK);
|
|
|
+ LOGGER.log("用户信息", "添加用户", "userUU: " + userUU);
|
|
|
+ return new ResponseEntity<>(HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -297,6 +299,7 @@ public class UserController {
|
|
|
@RequestMapping(value = "/findVendor/{uu}", method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
|
public List<Vendor> findVendor(@PathVariable("uu") Long userUU) {
|
|
|
+ LOGGER.log("客户权限", "查找用户客户分配", "userUU: " + userUU);
|
|
|
return userService.findVendorToUser(userUU);
|
|
|
}
|
|
|
|
|
|
@@ -311,10 +314,12 @@ public class UserController {
|
|
|
public ResponseEntity<String> bindVendor(@PathVariable("uu") Long userUU, @RequestBody String json) {
|
|
|
List<Vendor> ids = FlexJsonUtils.fromJsonArray(json, Vendor.class);
|
|
|
boolean result = userService.addVendorToUser(userUU, ids);
|
|
|
+ String resultInfo = result ? "成功" : "失败";
|
|
|
+ LOGGER.log("客户权限", "分配客户权限", "userUU: " + userUU + "结果: 分配" + resultInfo);
|
|
|
if (result) {
|
|
|
- return new ResponseEntity<String>(HttpStatus.OK);
|
|
|
+ return new ResponseEntity<>(HttpStatus.OK);
|
|
|
} else {
|
|
|
- return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -329,10 +334,12 @@ public class UserController {
|
|
|
public ResponseEntity<String> bindUserToVendor(@PathVariable("uu") Long custUU, @RequestBody String json) {
|
|
|
List<User> users = FlexJsonUtils.fromJsonArray(json, User.class);
|
|
|
boolean result = userService.addUserToVendor(custUU, users);
|
|
|
+ String resultInfo = result ? "成功" : "失败";
|
|
|
+ LOGGER.log("客户分配", "绑定用户到指定客户", "客户UU: " + custUU + "结果: 绑定" + resultInfo);
|
|
|
if (result) {
|
|
|
- return new ResponseEntity<String>(HttpStatus.OK);
|
|
|
+ return new ResponseEntity<>(HttpStatus.OK);
|
|
|
} else {
|
|
|
- return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -347,10 +354,12 @@ public class UserController {
|
|
|
public ResponseEntity<String> transferUserToVendor(@PathVariable("uu") Long custUU, @RequestBody String json) {
|
|
|
List<User> users = FlexJsonUtils.fromJsonArray(json, User.class);
|
|
|
boolean result = userService.transferUserToVendor(custUU, users);
|
|
|
+ String resultInfo = result ? "成功" : "失败";
|
|
|
+ LOGGER.log("客户分配", "将客户权限转移给用户", "客户UU: " + custUU + "结果: 绑定" + resultInfo);
|
|
|
if (result) {
|
|
|
- return new ResponseEntity<String>(HttpStatus.OK);
|
|
|
+ return new ResponseEntity<>(HttpStatus.OK);
|
|
|
} else {
|
|
|
- return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -364,6 +373,8 @@ public class UserController {
|
|
|
@ResponseBody
|
|
|
public ResponseEntity<String> transferMyDistribute(Long custUU, Long userUU) {
|
|
|
boolean result = userService.transferMyDistribute(custUU, userUU);
|
|
|
+ String resultInfo = result ? "成功" : "失败";
|
|
|
+ LOGGER.log("客户分配", "将客户权限转移给用户", "客户UU: " + custUU + "结果: 绑定" + resultInfo);
|
|
|
if (result) {
|
|
|
return new ResponseEntity<String>(HttpStatus.OK);
|
|
|
} else {
|
|
|
@@ -383,10 +394,12 @@ public class UserController {
|
|
|
public ResponseEntity<String> removeChooseVendor(@PathVariable("uu") Long userUU, @RequestBody String json) {
|
|
|
List<Long> ids = FlexJsonUtils.fromJsonArray(json, Long.class);
|
|
|
boolean result = userService.removeChooseVendor(userUU, ids);
|
|
|
+ String resultInfo = result ? "成功" : "失败";
|
|
|
+ LOGGER.log("客户分配", "删除被选中客户", "用户UU: " + userUU + "结果: " + resultInfo);
|
|
|
if (result) {
|
|
|
- return new ResponseEntity<String>(HttpStatus.OK);
|
|
|
+ return new ResponseEntity<>(HttpStatus.OK);
|
|
|
} else {
|
|
|
- return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
}
|
|
|
|