|
@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.beanutils.BeanUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
@@ -24,10 +25,7 @@ import org.jeecg.common.system.api.ISysBaseAPI;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
import org.jeecg.common.system.util.JwtUtil;
|
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
|
-import org.jeecg.common.util.MD5Util;
|
|
|
-import org.jeecg.common.util.PasswordUtil;
|
|
|
-import org.jeecg.common.util.RedisUtil;
|
|
|
-import org.jeecg.common.util.oConvertUtils;
|
|
|
+import org.jeecg.common.util.*;
|
|
|
import org.jeecg.config.dataSource.OtherSource;
|
|
|
import org.jeecg.modules.system.entity.*;
|
|
|
import org.jeecg.modules.system.mapper.SysUserMapper;
|
|
@@ -44,7 +42,11 @@ import org.jeecgframework.poi.excel.entity.ExportParams;
|
|
|
import org.jeecgframework.poi.excel.entity.ImportParams;
|
|
|
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.http.client.ClientHttpResponse;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.client.ResponseErrorHandler;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
@@ -128,6 +130,18 @@ public class SysUserController {
|
|
|
|
|
|
IPage<SysUser> pageList = sysUserService.page(page, queryWrapper);
|
|
|
|
|
|
+ List<SysPosition> positionList = sysPositionService.list();
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ for(SysPosition o:positionList){
|
|
|
+ map.put(o.getCode(),o.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ pageList.getRecords().forEach( item ->{
|
|
|
+ if(StringUtils.isNotBlank(item.getPost()) && map.containsKey(item.getPost())){
|
|
|
+ item.setPostName(map.get(item.getPost()));
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
//批量查询用户的所属部门
|
|
|
//step.1 先拿到全部的 useids
|
|
|
//step.2 通过 useids,一次性查询用户的所属部门名字
|
|
@@ -1487,4 +1501,94 @@ public class SysUserController {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据用户名查询用户信息
|
|
|
+ * @param userId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/detail/{userId}", method = RequestMethod.GET)
|
|
|
+ public JSONObject getDetail(@PathVariable String userId) {
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ SysUser sysUser = sysUserService.getUserByName(userId);
|
|
|
+ if (sysUser == null) {
|
|
|
+ result.put("error_code", "999");
|
|
|
+ result.put("message", "未找到该用户");
|
|
|
+ } else {
|
|
|
+ result.put("error_code", "0");
|
|
|
+ result.put("message", "success");
|
|
|
+
|
|
|
+ JSONObject user = new JSONObject();
|
|
|
+ user.put("user_id", userId);
|
|
|
+ user.put("user_cn_name",sysUser.getRealname());
|
|
|
+ user.put("contact",sysUser.getPhone());
|
|
|
+ user.put("email",sysUser.getEmail());
|
|
|
+ user.put("update_time", sysUser.getUpdateTime());
|
|
|
+
|
|
|
+
|
|
|
+ List<SysDepart> departList = sysDepartService.queryUserDeparts(sysUser.getId());
|
|
|
+ if (departList != null && departList.size() > 0) {
|
|
|
+ String deptCode = departList.stream().map(SysDepart::getOrgCode).collect(Collectors.joining(","));
|
|
|
+ String deptName = departList.stream().map(SysDepart::getDepartName).collect(Collectors.joining(","));
|
|
|
+ user.put("dept_code",deptCode);
|
|
|
+ user.put("dept_cn_name",deptName);
|
|
|
+ }
|
|
|
+
|
|
|
+ result.put("data", user);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation("7天内新增用户")
|
|
|
+ @RequestMapping(value = "/recently/added", method = RequestMethod.GET)
|
|
|
+ public Result<List<JSONObject>> recentlyAdded(){
|
|
|
+ Result<List<JSONObject>> result = new Result<List<JSONObject>>();
|
|
|
+ RestUtil.getRestTemplate().setErrorHandler(new ResponseErrorHandler(){
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean hasError(ClientHttpResponse clientHttpResponse) throws IOException {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void handleError(ClientHttpResponse clientHttpResponse) throws IOException {
|
|
|
+ }
|
|
|
+ });
|
|
|
+ ResponseEntity<JSONObject> response = RestUtil.getNative("http://172.18.91.50:9002/prod-api/authEmployee/lastweek",null,null);
|
|
|
+ int statusCode = response.getStatusCodeValue();
|
|
|
+ JSONObject res = response.getBody();
|
|
|
+
|
|
|
+ if(HttpStatus.OK.value()!=statusCode){
|
|
|
+ result.setCode(statusCode);
|
|
|
+ result.setMessage(res.getString("error_description"));
|
|
|
+ }else{
|
|
|
+ String code = res.getString("error_code");
|
|
|
+ String msg = res.getString("msg");
|
|
|
+ JSONArray data = res.getJSONArray("data");
|
|
|
+
|
|
|
+ List<JSONObject> newUser = new ArrayList<>();
|
|
|
+
|
|
|
+ if(data==null || data.size()==0){
|
|
|
+ result.setCode(statusCode);
|
|
|
+ result.setResult(newUser);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SysUser> sysUsers = sysUserService.queryAllUserInfo();
|
|
|
+ List<String> userNames = sysUsers.stream().map(SysUser::getUsername).collect(Collectors.toList());
|
|
|
+ for (int i = 0; i < data.size(); i++) {
|
|
|
+ JSONObject user = data.getJSONObject(i);
|
|
|
+ String userId = user.getString("user_id");
|
|
|
+ int activeState = user.getIntValue("active_state");
|
|
|
+ if (! userNames.contains(userId) && activeState==1) {
|
|
|
+ newUser.add(user);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ result.setCode(statusCode);
|
|
|
+ result.setResult(newUser);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+
|
|
|
+ }
|
|
|
}
|