Commit 2c27db79 authored by wzp's avatar wzp

机构管理查询和导入,用户管理

parent 1ffb1bd9
...@@ -115,6 +115,19 @@ ...@@ -115,6 +115,19 @@
<version>1.27.2</version> <version>1.27.2</version>
</dependency> </dependency>
<!-- POI导入导出 -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
<!-- Swagger2 Document --> <!-- Swagger2 Document -->
<dependency> <dependency>
<groupId>io.springfox</groupId> <groupId>io.springfox</groupId>
......
package cn.wisenergy.chnmuseum.party.common.log; package cn.wisenergy.chnmuseum.party.common.log;
public enum OperModule { public enum OperModule {
用户管理, USER(1,"用户管理"),
角色管理, ROLE(1,"角色管理"),
人员管理, DEPT(1,"部门管理"),
部门管理, ORG(1,"机构管理");
机构管理;
// 错误编码
private Integer code;
// 信息
private String msg;
// 相应编码有参构造函数
OperModule(Integer code, String msg) {
this.code = code;
this.msg = msg;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
} }
...@@ -4,13 +4,41 @@ public enum OperType { ...@@ -4,13 +4,41 @@ public enum OperType {
/** /**
* *
*/ */
查询,
添加,
修改, SELECT(1,"查询"),
删除, ADD(2,"新增"),
禁用, UPDATE(3,"修改"),
启用, DELETE(4,"删除"),
复制, UNABLE(5,"启用"),
分享, DISABLE(6,"禁用"),
注销; IMPORT(7,"导入");
// 错误编码
private Integer code;
// 信息
private String msg;
// 相应编码有参构造函数
OperType(Integer code, String msg) {
this.code = code;
this.msg = msg;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
} }
...@@ -132,9 +132,9 @@ class SystemOperationLogService extends ServiceImpl<SysLogMapper, SysLog> { ...@@ -132,9 +132,9 @@ class SystemOperationLogService extends ServiceImpl<SysLogMapper, SysLog> {
*/ */
public void getControllerMethodDescription(MethodLog log, SysLog sysLog) throws Exception { public void getControllerMethodDescription(MethodLog log, SysLog sysLog) throws Exception {
// 设置action动作 // 设置action动作
sysLog.setOperationType(log.operType().name()); sysLog.setOperationType(log.operType().getMsg());
// 设置标题 // 设置标题
sysLog.setOperationObject(log.operModule().name()); sysLog.setOperationObject(log.operModule().getMsg());
} }
/** /**
......
package cn.wisenergy.chnmuseum.party.common.util;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ImportExcelUtil {
// abc.xls
public static boolean isXls(String fileName) {
// (?i)忽略大小写
if (fileName.matches("^.+\\.(?i)(xls)$")) {
return true;
} else if (fileName.matches("^.+\\.(?i)(xlsx)$")) {
return false;
} else {
throw new RuntimeException("格式不对");
}
}
public static List<Map<String,String>> readExcel(String fileName,InputStream is) throws Exception {
boolean ret = isXls(fileName);
Workbook workbook = null;
// 根据文件后缀创建不同的对象
if (ret) {
workbook = new HSSFWorkbook(is);
} else {
workbook = new XSSFWorkbook(is);
}
Sheet sheet = workbook.getSheetAt(0);
// 得到标题行
Row titleRow = sheet.getRow(0);
//行数
int lastRowNum = sheet.getLastRowNum();
//列数
int lastCellNum = titleRow.getLastCellNum();
List<Map<String,String>> list = new ArrayList<>();
for (int i = 1; i <= lastRowNum; i++) {
ArrayList<String> list1 = new ArrayList<>();
HashMap<String,String> map = new HashMap<>();
//获取行数据
Row row = sheet.getRow(i);
for (int j = 0; j < lastCellNum; j++) {
//获取单元格
Cell cell = row.getCell(j);
if (cell!=null) {
cell.setCellType(Cell.CELL_TYPE_STRING);
//获取单元格数据
list1.add(cell.getStringCellValue());
//列名 :数据
map.put(titleRow.getCell(j).getStringCellValue(), cell.getStringCellValue());
}else {
continue;
}
}
list.add(map);
}
is.close();
return list;
}
}
\ No newline at end of file
...@@ -32,8 +32,8 @@ public class SwaggerConfig { ...@@ -32,8 +32,8 @@ public class SwaggerConfig {
.apis(RequestHandlerSelectors.basePackage("cn.wisenergy.chnmuseum.party.web.controller")) .apis(RequestHandlerSelectors.basePackage("cn.wisenergy.chnmuseum.party.web.controller"))
.paths(PathSelectors.any()) .paths(PathSelectors.any())
.build() .build()
//.securitySchemes(newArrayList(apiKey())) .securitySchemes(newArrayList(apiKey()))
//.securityContexts(newArrayList(securityContext())) .securityContexts(newArrayList(securityContext()))
; ;
} }
......
...@@ -76,7 +76,7 @@ public class WebLogAspect { ...@@ -76,7 +76,7 @@ public class WebLogAspect {
content = annotation.value(); content = annotation.value();
} }
//插入到系统日志表 //插入到系统日志表
this.sysLogController.insertSysLog(content,null); this.sysLogController.insertSysLog(content,null,null);
} }
return proceedingJoinPoint.proceed(); return proceedingJoinPoint.proceed();
......
...@@ -3,6 +3,9 @@ package cn.wisenergy.chnmuseum.party.mapper; ...@@ -3,6 +3,9 @@ package cn.wisenergy.chnmuseum.party.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.wisenergy.chnmuseum.party.model.TOrgan; import cn.wisenergy.chnmuseum.party.model.TOrgan;
import java.util.List;
import java.util.Map;
/** /**
* <pre> * <pre>
* 用户 Mapper 接口 * 用户 Mapper 接口
...@@ -12,5 +15,5 @@ import cn.wisenergy.chnmuseum.party.model.TOrgan; ...@@ -12,5 +15,5 @@ import cn.wisenergy.chnmuseum.party.model.TOrgan;
* @since 2021-03-22 * @since 2021-03-22
*/ */
public interface TOrganMapper extends BaseMapper<TOrgan> { public interface TOrganMapper extends BaseMapper<TOrgan> {
List<Map<String,Object>> selectArea();
} }
...@@ -3,6 +3,8 @@ package cn.wisenergy.chnmuseum.party.mapper; ...@@ -3,6 +3,8 @@ package cn.wisenergy.chnmuseum.party.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.wisenergy.chnmuseum.party.model.TUser; import cn.wisenergy.chnmuseum.party.model.TUser;
import java.util.List;
/** /**
* <pre> * <pre>
* 用户 Mapper 接口 * 用户 Mapper 接口
...@@ -13,5 +15,7 @@ import cn.wisenergy.chnmuseum.party.model.TUser; ...@@ -13,5 +15,7 @@ import cn.wisenergy.chnmuseum.party.model.TUser;
*/ */
public interface TUserMapper extends BaseMapper<TUser> { public interface TUserMapper extends BaseMapper<TUser> {
TUser selectByUsername(String username); TUser selectByUsername(String userName);
List<TUser> selectList(String userName);
} }
...@@ -18,7 +18,7 @@ import java.util.List; ...@@ -18,7 +18,7 @@ import java.util.List;
* @author 杨智平 * @author 杨智平
* @since 2018-08-02 * @since 2018-08-02
*/ */
@TableName("role") @TableName("t_role")
public class Role extends Model<Role> { public class Role extends Model<Role> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
......
...@@ -90,7 +90,7 @@ public class TUser implements Serializable { ...@@ -90,7 +90,7 @@ public class TUser implements Serializable {
@TableField("exired_date") @TableField("exired_date")
private LocalDate exiredDate; private LocalDate exiredDate;
@ApiModelProperty("状态") @ApiModelProperty("状态 1.启用 2.禁用")
@TableField("status") @TableField("status")
private String status; private String status;
...@@ -122,7 +122,7 @@ public class TUser implements Serializable { ...@@ -122,7 +122,7 @@ public class TUser implements Serializable {
@TableField("type") @TableField("type")
private String type; private String type;
@ApiModelProperty("审核状态 1.通过 2.待初审 3.待复审 4.已驳回") @ApiModelProperty("审核状态 1.待初审 2.已驳回 3.待复审 4.通过 ")
@TableField("audit_status") @TableField("audit_status")
private String auditStatus; private String auditStatus;
......
...@@ -16,4 +16,6 @@ import java.util.List; ...@@ -16,4 +16,6 @@ import java.util.List;
public interface TOrganService extends IService<TOrgan> { public interface TOrganService extends IService<TOrgan> {
List<TOrgan> getTree(); List<TOrgan> getTree();
boolean batchUpload(List excelList);
} }
package cn.wisenergy.chnmuseum.party.service; package cn.wisenergy.chnmuseum.party.service;
import cn.wisenergy.chnmuseum.party.model.TUser; import cn.wisenergy.chnmuseum.party.model.TUser;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
/** /**
...@@ -13,5 +14,7 @@ import com.baomidou.mybatisplus.extension.service.IService; ...@@ -13,5 +14,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/ */
public interface TUserService extends IService<TUser> { public interface TUserService extends IService<TUser> {
TUser selectByUsername(String username); TUser selectByUsername(String userName);
Page<TUser> selectList(Page<TUser> page, String userName);
} }
...@@ -6,6 +6,8 @@ import cn.wisenergy.chnmuseum.party.service.RunLogService; ...@@ -6,6 +6,8 @@ import cn.wisenergy.chnmuseum.party.service.RunLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/** /**
* <p> * <p>
* 服务实现类 * 服务实现类
...@@ -17,4 +19,12 @@ import org.springframework.stereotype.Service; ...@@ -17,4 +19,12 @@ import org.springframework.stereotype.Service;
@Service @Service
public class RunLogServiceImpl extends ServiceImpl<RunLogMapper, RunLog> implements RunLogService { public class RunLogServiceImpl extends ServiceImpl<RunLogMapper, RunLog> implements RunLogService {
@Resource
private RunLogMapper runLogMapper;
public boolean insertRunLog(RunLog runLog){
boolean save = save(runLog);
return save;
}
} }
package cn.wisenergy.chnmuseum.party.service.impl; package cn.wisenergy.chnmuseum.party.service.impl;
import cn.wisenergy.chnmuseum.party.common.util.DateUtil80;
import cn.wisenergy.chnmuseum.party.model.TOrgan; import cn.wisenergy.chnmuseum.party.model.TOrgan;
import cn.wisenergy.chnmuseum.party.mapper.TOrganMapper; import cn.wisenergy.chnmuseum.party.mapper.TOrganMapper;
import cn.wisenergy.chnmuseum.party.service.TOrganService; import cn.wisenergy.chnmuseum.party.service.TOrganService;
...@@ -8,13 +10,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -8,13 +10,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.time.LocalDateTime;
import java.util.HashMap; import java.util.*;
import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -50,4 +49,45 @@ public class TOrganServiceImpl extends ServiceImpl<TOrganMapper, TOrgan> impleme ...@@ -50,4 +49,45 @@ public class TOrganServiceImpl extends ServiceImpl<TOrganMapper, TOrgan> impleme
list = list.stream().filter(o -> o.getLevel() == 1).collect(Collectors.toList()); list = list.stream().filter(o -> o.getLevel() == 1).collect(Collectors.toList());
return list; return list;
} }
@Override
public boolean batchUpload(List excelList) {
boolean flag =false;
List<TOrgan> list = new ArrayList<>();
List<TOrgan> list1 = list();
HashMap<String, TOrgan> map1 = new HashMap<>();
list1.stream().forEach(o-> map1.put(o.getName(),o));
HashMap<String, Integer> area = new HashMap<>();
List<Map<String, Object>> mapList = organMapper.selectArea();
mapList.stream().forEach(m->area.put(m.get("name").toString(),Integer.valueOf(m.get("id").toString())));
for (int i = 0; i < excelList.size(); i++) {
Map<String, String> map = null;
map = (Map<String, String>) excelList.get(i);
TOrgan organ = new TOrgan();
organ.setName(map.get("名称"));
String parent = map.get("上级机构");
if (map1.get(parent)==null){
organ.setParentId("0");
organ.setLevel(1);
}else {
organ.setParentId(map1.get(parent).getId());
organ.setLevel(map1.get(parent).getLevel()+1);
}
organ.setProvince(area.get(map.get("省")+"P"));
organ.setCity(area.get(map.get("市")+"C"));
organ.setCountry(area.get(map.get("县")+"T"));
organ.setIcon(map.get("icon"));
organ.setRemarks(map.get("备注"));
organ.setIsDeleted(false);
organ.setCreateTime(DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis()));
organ.setUpdateTime(LocalDateTime.now());
list.add(organ);
}
flag = saveBatch(list);
return flag;
}
} }
...@@ -3,6 +3,7 @@ package cn.wisenergy.chnmuseum.party.service.impl; ...@@ -3,6 +3,7 @@ package cn.wisenergy.chnmuseum.party.service.impl;
import cn.wisenergy.chnmuseum.party.model.TUser; import cn.wisenergy.chnmuseum.party.model.TUser;
import cn.wisenergy.chnmuseum.party.mapper.TUserMapper; import cn.wisenergy.chnmuseum.party.mapper.TUserMapper;
import cn.wisenergy.chnmuseum.party.service.TUserService; import cn.wisenergy.chnmuseum.party.service.TUserService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -28,7 +29,12 @@ public class TUserServiceImpl extends ServiceImpl<TUserMapper, TUser> implements ...@@ -28,7 +29,12 @@ public class TUserServiceImpl extends ServiceImpl<TUserMapper, TUser> implements
private TUserMapper tUserMapper; private TUserMapper tUserMapper;
@Override @Override
public TUser selectByUsername(String username) { public TUser selectByUsername(String userName) {
return tUserMapper.selectByUsername(username); return tUserMapper.selectByUsername(userName);
}
@Override
public Page<TUser> selectList(Page<TUser> page, String userName) {
return page.setRecords(tUserMapper.selectList(userName));
} }
} }
...@@ -32,10 +32,7 @@ import javax.servlet.http.HttpServletRequest; ...@@ -32,10 +32,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.LinkedHashMap; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** /**
...@@ -165,14 +162,17 @@ public class LoginController { ...@@ -165,14 +162,17 @@ public class LoginController {
} }
//获取当前用户角色拥有菜单 //获取当前用户角色拥有菜单
List<Menu> userMenuPerms = this.menuService.getUserMenuPerms(roles); List<Menu> userMenuPerms = new ArrayList<>();
if (roles.size() > 0) {
userMenuPerms = this.menuService.getUserMenuPerms(roles);
}
//登录时插入系统日志 //登录时插入系统日志
String operationContent = username + "登录本系统"; String operationContent = username + "登录本系统";
if (user.getOrgName() != null) { if (user.getOrgName() != null) {
operationContent += ",机构" + user.getOrgName(); operationContent += ",机构" + user.getOrgName();
} }
this.sysLogController.insertSysLog(operationContent, username); this.sysLogController.insertSysLog(operationContent, username, user.getId());
String token = JwtTokenUtil.sign(username, user.getId()); String token = JwtTokenUtil.sign(username, user.getId());
// 将token信息存入Redis // 将token信息存入Redis
......
...@@ -2,7 +2,9 @@ package cn.wisenergy.chnmuseum.party.web.controller; ...@@ -2,7 +2,9 @@ package cn.wisenergy.chnmuseum.party.web.controller;
import cn.wisenergy.chnmuseum.party.common.util.DateUtil80; import cn.wisenergy.chnmuseum.party.common.util.DateUtil80;
import cn.wisenergy.chnmuseum.party.common.util.NetWorkUtil; import cn.wisenergy.chnmuseum.party.common.util.NetWorkUtil;
import cn.wisenergy.chnmuseum.party.model.RunLog;
import cn.wisenergy.chnmuseum.party.model.SysLog; import cn.wisenergy.chnmuseum.party.model.SysLog;
import cn.wisenergy.chnmuseum.party.service.impl.RunLogServiceImpl;
import cn.wisenergy.chnmuseum.party.service.impl.SysLogServiceImpl; import cn.wisenergy.chnmuseum.party.service.impl.SysLogServiceImpl;
import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController; import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
...@@ -30,12 +32,15 @@ public class SysLogController extends BaseController { ...@@ -30,12 +32,15 @@ public class SysLogController extends BaseController {
@Resource @Resource
private SysLogServiceImpl sysLogService; private SysLogServiceImpl sysLogService;
@Resource
private RunLogServiceImpl runLogService;
/** /**
* 插入系统日志表 * 插入系统日志表
*/ */
@ApiOperation(value = "插入系统日志", notes = "插入系统日志") @ApiOperation(value = "插入系统日志", notes = "插入系统日志")
@PostMapping(value = "/insertSysLog") @PostMapping(value = "/insertSysLog")
public Boolean insertSysLog(String operationContent, String username) { public Boolean insertSysLog(String operationContent, String username,String id) {
SysLog sysLog = new SysLog(); SysLog sysLog = new SysLog();
//日志时间 //日志时间
sysLog.setOperationTime(DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis())); sysLog.setOperationTime(DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis()));
...@@ -50,6 +55,11 @@ public class SysLogController extends BaseController { ...@@ -50,6 +55,11 @@ public class SysLogController extends BaseController {
} else { } else {
sysLog.setOperator(username); sysLog.setOperator(username);
} }
if ("1".equals(id)) {
sysLog.setType(1);
}else {
sysLog.setType(2);
}
//日志内容 //日志内容
sysLog.setOperationContent(operationContent); sysLog.setOperationContent(operationContent);
sysLog.setOperationObject("登录管理"); sysLog.setOperationObject("登录管理");
...@@ -80,5 +90,15 @@ public class SysLogController extends BaseController { ...@@ -80,5 +90,15 @@ public class SysLogController extends BaseController {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
} }
/**
* 插入机顶盒日志表
*/
@ApiOperation(value = "插入系统日志", notes = "插入系统日志")
@PostMapping(value = "/insertRunLog")
public Boolean insertRunLog(RunLog runLog) {
boolean b = runLogService.insertRunLog(runLog);
return b;
}
} }
...@@ -4,6 +4,7 @@ import cn.wisenergy.chnmuseum.party.common.log.MethodLog; ...@@ -4,6 +4,7 @@ import cn.wisenergy.chnmuseum.party.common.log.MethodLog;
import cn.wisenergy.chnmuseum.party.common.log.OperModule; import cn.wisenergy.chnmuseum.party.common.log.OperModule;
import cn.wisenergy.chnmuseum.party.common.log.OperType; import cn.wisenergy.chnmuseum.party.common.log.OperType;
import cn.wisenergy.chnmuseum.party.common.util.DateUtil80; import cn.wisenergy.chnmuseum.party.common.util.DateUtil80;
import cn.wisenergy.chnmuseum.party.common.util.ImportExcelUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
...@@ -26,13 +27,20 @@ import lombok.extern.slf4j.Slf4j; ...@@ -26,13 +27,20 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils; import org.apache.commons.lang3.SystemUtils;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -57,7 +65,7 @@ public class TOrganController extends BaseController { ...@@ -57,7 +65,7 @@ public class TOrganController extends BaseController {
@PostMapping("/add") @PostMapping("/add")
@RequiresPermissions("/organ/add") @RequiresPermissions("/organ/add")
@ApiOperation(value = "添加机构", notes = "添加机构") @ApiOperation(value = "添加机构", notes = "添加机构")
@MethodLog(operModule = OperModule.机构管理,operType = OperType.添加) @MethodLog(operModule = OperModule.ORG,operType = OperType.ADD)
public Map<String, Object> add(TOrgan organ) { public Map<String, Object> add(TOrgan organ) {
organ.setCreateTime(DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis())); organ.setCreateTime(DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis()));
organ.setUpdateTime(DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis())); organ.setUpdateTime(DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis()));
...@@ -75,7 +83,7 @@ public class TOrganController extends BaseController { ...@@ -75,7 +83,7 @@ public class TOrganController extends BaseController {
@PutMapping("/update") @PutMapping("/update")
@RequiresPermissions("/organ/update") @RequiresPermissions("/organ/update")
@ApiOperation(value = "update", notes = "修改机构信息") @ApiOperation(value = "update", notes = "修改机构信息")
@MethodLog(operModule = OperModule.机构管理,operType = OperType.修改) @MethodLog(operModule = OperModule.ORG,operType = OperType.UPDATE)
public Map<String, Object> updateTOrgan(TOrgan tOrgan) { public Map<String, Object> updateTOrgan(TOrgan tOrgan) {
tOrgan.setUpdateTime(DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis())); tOrgan.setUpdateTime(DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis()));
boolean flag = tOrganService.updateById(tOrgan); boolean flag = tOrganService.updateById(tOrgan);
...@@ -85,28 +93,11 @@ public class TOrganController extends BaseController { ...@@ -85,28 +93,11 @@ public class TOrganController extends BaseController {
return getFailResult(); return getFailResult();
} }
// @PutMapping("/updateAuditStatus")
// @RequiresPermissions("/organ/updateAuditStatus")
// @ApiOperation(value = "更新机构审核状态", notes = "更新机构审核状态")
// @ApiImplicitParams(value = {
// @ApiImplicitParam(name = "id", value = "标识ID", dataType = "String", paramType = "path"),
// @ApiImplicitParam(name = "status", value = "状态", paramType = "query", dataType = "String")
// })
// public Map<String, Object> updateStatus(@NotNull(message = "机构ID不能为空") @PathVariable("id") String id, @RequestParam("status") AuditStatusEnum status) {
// UpdateWrapper<TOrgan> updateWrapper = new UpdateWrapper<>();
// updateWrapper.eq("id", id);
// updateWrapper.eq("audit_status", status.name());
// boolean flag = tOrganService.update(updateWrapper);
// if (flag) {
// return getSuccessResult();
// }
// return getFailResult();
// }
@DeleteMapping("/delete") @DeleteMapping("/delete")
@RequiresPermissions("/organ/delete") @RequiresPermissions("/organ/delete")
@ApiOperation(value = "根据ID删除机构", notes = "根据ID删除机构") @ApiOperation(value = "根据ID删除机构", notes = "根据ID删除机构")
@MethodLog(operModule = OperModule.机构管理,operType = OperType.删除) @MethodLog(operModule = OperModule.ORG,operType = OperType.DELETE)
@ApiImplicitParams(value = { @ApiImplicitParams(value = {
@ApiImplicitParam(name = "id", value = "标识ID", paramType = "path", dataType = "String") @ApiImplicitParam(name = "id", value = "标识ID", paramType = "path", dataType = "String")
}) })
...@@ -125,12 +116,14 @@ public class TOrganController extends BaseController { ...@@ -125,12 +116,14 @@ public class TOrganController extends BaseController {
@GetMapping("/getList") @GetMapping("/getList")
@RequiresPermissions("/organ/getList") @RequiresPermissions("/organ/getList")
@ApiOperation(value = "获取机构全部列表(无分页)", notes = "获取机构全部列表(无分页)") @ApiOperation(value = "获取机构全部列表(无分页)", notes = "获取机构全部列表(无分页)")
@MethodLog(operModule = OperModule.机构管理,operType = OperType.查询) @MethodLog(operModule = OperModule.ORG,operType = OperType.SELECT)
public Map<String, Object> getTOrganList() { public Map<String, Object> getTOrganList() {
List<TOrgan> tOrganList = tOrganService.list(Wrappers.<TOrgan>lambdaQuery().eq(TOrgan::getIsDeleted, 0)); List<TOrgan> tOrganList = tOrganService.list(Wrappers.<TOrgan>lambdaQuery().eq(TOrgan::getIsDeleted, 0));
return getResult(tOrganList); return getResult(tOrganList);
} }
@ApiImplicitParams(value = { @ApiImplicitParams(value = {
@ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"), @ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "_size", value = "返回条数", paramType = "query", dataType = "Integer"), @ApiImplicitParam(name = "_size", value = "返回条数", paramType = "query", dataType = "Integer"),
...@@ -141,7 +134,7 @@ public class TOrganController extends BaseController { ...@@ -141,7 +134,7 @@ public class TOrganController extends BaseController {
@PostMapping("/getPageList") @PostMapping("/getPageList")
@RequiresPermissions("/organ/getPageList") @RequiresPermissions("/organ/getPageList")
@ApiOperation(value = "获取机构分页列表", notes = "获取机构分页列表") @ApiOperation(value = "获取机构分页列表", notes = "获取机构分页列表")
@MethodLog(operModule = OperModule.机构管理,operType = OperType.查询) @MethodLog(operModule = OperModule.ORG,operType = OperType.SELECT)
public Map<String, Object> getTOrganPageList(GenericPageParam genericPageParam) { public Map<String, Object> getTOrganPageList(GenericPageParam genericPageParam) {
LambdaQueryWrapper<TOrgan> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<TOrgan> queryWrapper = new LambdaQueryWrapper<>();
// 对名称或编码模糊查询 // 对名称或编码模糊查询
...@@ -162,7 +155,7 @@ public class TOrganController extends BaseController { ...@@ -162,7 +155,7 @@ public class TOrganController extends BaseController {
@ApiOperation(value = "获取机构详情", notes = "获取机构详情") @ApiOperation(value = "获取机构详情", notes = "获取机构详情")
@GetMapping("/getById") @GetMapping("/getById")
@RequiresPermissions("/organ/getById") @RequiresPermissions("/organ/getById")
@MethodLog(operModule = OperModule.机构管理,operType = OperType.查询) @MethodLog(operModule = OperModule.ORG,operType = OperType.SELECT)
public Map<String, Object> getById(String id) { public Map<String, Object> getById(String id) {
TOrgan tOrgan = tOrganService.getById(id); TOrgan tOrgan = tOrganService.getById(id);
return getResult(tOrgan); return getResult(tOrgan);
...@@ -172,11 +165,44 @@ public class TOrganController extends BaseController { ...@@ -172,11 +165,44 @@ public class TOrganController extends BaseController {
@GetMapping("/getTree") @GetMapping("/getTree")
@RequiresPermissions("/organ/getTree") @RequiresPermissions("/organ/getTree")
@ApiOperation(value = "获取机构树", notes = "获取机构树") @ApiOperation(value = "获取机构树", notes = "获取机构树")
@MethodLog(operModule = OperModule.机构管理,operType = OperType.查询) @MethodLog(operModule = OperModule.ORG,operType = OperType.SELECT)
public Map<String, Object> getTree() { public Map<String, Object> getTree(String name) {
List<TOrgan> tOrganList = tOrganService.getTree(); List<TOrgan> list = new ArrayList<>();
return getResult(tOrganList); if (StringUtils.isBlank(name)) {
list = tOrganService.getTree();
}else {
list = tOrganService.list(new UpdateWrapper<TOrgan>().like("name",name));
}
return getResult(list);
} }
// 导入EXCEL
@ApiOperation(value = "导入EXCEL", notes = "导入EXCEL", httpMethod = "POST")
@RequestMapping(value = "/import", method = RequestMethod.POST)
@RequiresPermissions("/organ/import")
@MethodLog(operModule = OperModule.ORG,operType = OperType.IMPORT)
public ResponseEntity<Map> upload(MultipartFile file) {
Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
try {
boolean flag = false;
//使用工具类从文件中读取数据
List excelList = ImportExcelUtil.readExcel(file.getOriginalFilename(), file.getInputStream());
flag = tOrganService.batchUpload(excelList);
if (!flag) {
resultMap.put("status",500);
resultMap.put("massage","导入失败!");
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resultMap);
}
resultMap.put("status",200);
resultMap.put("massage","导入成功!");
return ResponseEntity.ok(resultMap);
} catch (Exception e) {
resultMap.put("status",500);
resultMap.put("massage","导入失败!");
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(resultMap);
}
}
} }
...@@ -23,4 +23,9 @@ ...@@ -23,4 +23,9 @@
id, name, parent_id, is_deleted, create_time, update_time, province, city, country, icon, remarks, level id, name, parent_id, is_deleted, create_time, update_time, province, city, country, icon, remarks, level
</sql> </sql>
<select id="selectArea" resultType="java.util.HashMap">
select concat(name,type) name,id from t_area
</select>
</mapper> </mapper>
...@@ -24,6 +24,22 @@ ...@@ -24,6 +24,22 @@
<result column="type" property="type"/> <result column="type" property="type"/>
<result column="audit_status" property="auditStatus"/> <result column="audit_status" property="auditStatus"/>
<result column="org_name" property="orgName"/> <result column="org_name" property="orgName"/>
<collection fetchType="eager" property="roleList" ofType="cn.wisenergy.chnmuseum.party.model.Role"
select="selectRoles" column="user_name"/>
</resultMap>
<resultMap id="roleMap" type="cn.wisenergy.chnmuseum.party.model.Role">
<result column="id" property="id" />
<result column="name" property="name" />
<result column="alias" property="alias" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
<result column="status" property="status" />
<result column="is_allow_login" property="allowLogin" />
<result column="instruction" property="instruction" />
<result column="is_deleted" property="isDeleted" />
<result column="sortorder" property="sortorder" />
</resultMap> </resultMap>
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
...@@ -35,7 +51,27 @@ ...@@ -35,7 +51,27 @@
select u.*,o.name org_name select u.*,o.name org_name
from t_user u from t_user u
left join t_organ o on o.id = u.org_id left join t_organ o on o.id = u.org_id
where u.user_name =#{username} where u.user_name =#{userName}
</select>
<select id="selectList" resultMap="BaseResultMap">
select u.*,o.name org_name
from t_user u
left join t_organ o on o.id = u.org_id
<if test=" username != null and username != '' ">
where u.user_name LIKE concat('%', #{userName}, '%')
</if>
</select>
<select id="selectRoles" resultMap="roleMap">
select r.*
from t_user u
left join t_organ o on o.id = u.org_id
left join t_user_role_link l on l.user_id = u.id
left join t_role r on l.role_id = r.id
<if test=" username != null and username != '' ">
where u.user_name =#{userName}
</if>
</select> </select>
</mapper> </mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment