Commit 9d9a48f9 authored by liqin's avatar liqin 💬

Merge branch 'master' of http://111.203.232.171:8888/lee/chnmuseum-party into master

 Conflicts:
	src/main/java/cn/wisenergy/chnmuseum/party/common/enums/RESULT_INFO_ENUM.java
parents 0be86b8b 7e440353
......@@ -6,6 +6,7 @@ import cn.wisenergy.chnmuseum.party.model.*;
import cn.wisenergy.chnmuseum.party.service.PermissionService;
import cn.wisenergy.chnmuseum.party.service.RolePermissionService;
import cn.wisenergy.chnmuseum.party.service.RoleService;
import cn.wisenergy.chnmuseum.party.service.TUserService;
import cn.wisenergy.chnmuseum.party.service.impl.EmployeeRoleServiceImpl;
import cn.wisenergy.chnmuseum.party.service.impl.EmployeeServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
......@@ -58,6 +59,9 @@ public class MyShiroRealm extends AuthorizingRealm {
@Resource
private StringRedisTemplate stringRedisTemplate;
@Resource
private TUserService userService;
/**
* 必须重写此方法,不然Shiro会报错
*/
......@@ -89,9 +93,9 @@ public class MyShiroRealm extends AuthorizingRealm {
// 通过username从数据库中查找
// 实际项目中,这里可以根据实际情况做缓存,如果不做,Shiro自己也是有时间间隔机制,2分钟内不会重复执行该方法
String employeeId = JwtTokenUtil.getEmployeeId(credentials);
Employee employee = this.employeeService.selectByEmpId(employeeId);
if (employee == null) {
String userId = JwtTokenUtil.getEmployeeId(credentials);
TUser user = userService.getById(userId);
if (user == null) {
throw new AuthenticationException("User does not exist!");
}
......@@ -99,7 +103,7 @@ public class MyShiroRealm extends AuthorizingRealm {
throw new AuthenticationException("token invalid");
}
return new SimpleAuthenticationInfo(new Employee(employee.getId(), credentials), credentials, getName());
return new SimpleAuthenticationInfo(new TUser(user.getId(), credentials), credentials, getName());
}
/**
......@@ -108,27 +112,29 @@ public class MyShiroRealm extends AuthorizingRealm {
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
System.out.println("权限认证方法:MyShiroRealm.doGetAuthorizationInfo()");
Employee employee = (Employee) principals.getPrimaryPrincipal();
Boolean hasToken = stringRedisTemplate.hasKey(SHIRO_JWT_TOKEN + employee.getJwtToken());
TUser user = (TUser) principals.getPrimaryPrincipal();
Boolean hasToken = stringRedisTemplate.hasKey(SHIRO_JWT_TOKEN + user.getJwtToken());
if (hasToken == null || !hasToken) {
throw new AuthenticationException("token invalid!");
}
String employeeId = JwtTokenUtil.getEmployeeId(employee.getJwtToken());
String userId = JwtTokenUtil.getEmployeeId(user.getJwtToken());
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
// 根据用户ID查询角色(role),放入到Authorization里。
Map<String, Object> map = new HashMap<>();
map.put("employee_id", employeeId);
List<EmployeeRole> employeeRoleList = this.employeeRoleService.listByMap(map);
List<Role> list = roleService.selectRoleByUserId(userId);
// // 根据用户ID查询角色(role),放入到Authorization里。
// Map<String, Object> map = new HashMap<>();
// map.put("user_id", userId);
// List<EmployeeRole> employeeRoleList = this.employeeRoleService.listByMap(map);
List<String> ridList = new LinkedList<>();
for (EmployeeRole employeeRole : employeeRoleList) {
ridList.add(employeeRole.getRoleId());
}
List<Role> roleList = this.roleService.listByIds(ridList);
// for (EmployeeRole employeeRole : employeeRoleList) {
// ridList.add(employeeRole.getRoleId());
// }
// List<Role> roleList = this.roleService.listByIds(ridList);
Set<String> roleSet = new HashSet<>();
for (Role role : roleList) {
for (Role role : list) {
roleSet.add(role.getAlias());
ridList.add(role.getId());
}
info.setRoles(roleSet);
......
......@@ -12,7 +12,8 @@ public enum OperType {
DELETE(4,"删除"),
UNABLE(5,"启用"),
DISABLE(6,"禁用"),
IMPORT(7,"导入");
IMPORT(7,"导入"),
LOGIN(8,"登录");
// 错误编码
private Integer code;
......
......@@ -3,8 +3,10 @@ package cn.wisenergy.chnmuseum.party.common.log;
import cn.wisenergy.chnmuseum.party.auth.util.JwtTokenUtil;
import cn.wisenergy.chnmuseum.party.common.util.DateUtil80;
import cn.wisenergy.chnmuseum.party.core.annotations.OperationLog;
import cn.wisenergy.chnmuseum.party.mapper.SysLogMapper;
import cn.wisenergy.chnmuseum.party.model.SysLog;
import cn.wisenergy.chnmuseum.party.model.TOperationLog;
import cn.wisenergy.chnmuseum.party.model.TUser;
import cn.wisenergy.chnmuseum.party.service.impl.TUserServiceImpl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
......@@ -28,6 +30,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.net.InetAddress;
import java.time.LocalDateTime;
import java.util.List;
......@@ -103,10 +106,17 @@ class SystemOperationLogService extends ServiceImpl<SysLogMapper, SysLog> {
// 异常处理记录日志..log.error(e);
throw e;
}
if (methodLog.operModule().getMsg().contains("运维")) {
TOperationLog operationLog = new TOperationLog();
operationLog.setCreateTime(LocalDateTime.now());
operationLog.setUserId(user.getId());
operationLog.setOperationType(methodLog.operType().getMsg());
return object;
}
SysLog sysLog = new SysLog();
if ("1".equals(user.getId())) {
sysLog.setType(1);
}else {
} else {
sysLog.setType(2);
}
sysLog.setOperator(user.getUserName());
......@@ -117,10 +127,8 @@ class SystemOperationLogService extends ServiceImpl<SysLogMapper, SysLog> {
// 处理设置注解上的参数
getControllerMethodDescription(methodLog, sysLog);
baseMapper.insert(sysLog);
// System.out.println("日志实体:"+sysLog.getLoginName()+sysLog.getMethodRemark()+sysLog.getOperationContent());
sysLogMapper.insert(sysLog);
return object;
}
/**
......
......@@ -3,22 +3,10 @@ package cn.wisenergy.chnmuseum.party.common.mybatis;
public class MysqlGenerator {
private static final String[] tableNames = new String[]{
"asset",
"asset_type",
"copyright_owner",
"copyright_owner_asset_type",
"copyright_owner_board_type",
"exhibition_board",
"exhibition_board_cat",
"learning_content",
"learning_content_board",
"learning_content_board_cat",
"learning_content_copyright_owner",
"learning_project"
"t_area"
};
// private static final String projectPath = "D:\\develop\\Project\\chnmuseum-party";
private static final String projectPath = "/opt/ss";
private static final String projectPath = "D:\\develop\\Project\\chnmuseum-party";
// private static final String projectPath = "/opt/ss";
public static void main(String[] args) {
CodeGenerator codeGenerator = new CodeGenerator();
......
......@@ -27,6 +27,9 @@ public abstract class BasePageOrderParam extends BasePageParam {
@ApiModelProperty("类型")
private String type;
@ApiModelProperty("操作类型")
private String operationType;
@ApiModelProperty("起始修改时间")
private LocalDate startDate;
......
package cn.wisenergy.chnmuseum.party.mapper;
import cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam;
import cn.wisenergy.chnmuseum.party.model.RunLog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
/**
* <p>
......@@ -13,4 +17,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface RunLogMapper extends BaseMapper<RunLog> {
List<RunLog> pageList(Page<RunLog> page, RunLog runLog);
}
package cn.wisenergy.chnmuseum.party.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.wisenergy.chnmuseum.party.model.TArea;
import java.util.List;
import java.util.Map;
/**
* <pre>
* 区域表 Mapper 接口
* </pre>
*
* @author Danny Lee
* @since 2021-03-24
*/
public interface TAreaMapper extends BaseMapper<TArea> {
List<Map<String,String>> languageInfo();
}
package cn.wisenergy.chnmuseum.party.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.wisenergy.chnmuseum.party.model.TInteraction;
/**
* <pre>
* 看板互动 Mapper 接口
* </pre>
*
* @author Danny Lee
* @since 2021-03-23
*/
public interface TInteractionMapper extends BaseMapper<TInteraction> {
}
package cn.wisenergy.chnmuseum.party.mapper;
import cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.wisenergy.chnmuseum.party.model.TOperationLog;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
/**
* <pre>
* 运维日志表 Mapper 接口
* </pre>
*
* @author Danny Lee
* @since 2021-03-23
*/
public interface TOperationLogMapper extends BaseMapper<TOperationLog> {
List<TOperationLog> pageList(Page<TOperationLog> page,TOperationLog operationLog);
}
......@@ -16,4 +16,6 @@ import java.util.Map;
*/
public interface TOrganMapper extends BaseMapper<TOrgan> {
List<Map<String,Object>> selectArea();
TOrgan getById(String id);
}
......@@ -18,4 +18,6 @@ public interface TUserMapper extends BaseMapper<TUser> {
TUser selectByUsername(String userName);
List<TUser> selectList(String userName);
TUser getById(String id);
}
......@@ -8,9 +8,11 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
/**
* <p>
......@@ -52,4 +54,21 @@ public class RunLog implements Serializable {
@TableField("end_time")
private LocalDateTime endTime;
@ApiModelProperty(value = "结束时间")
@TableField(exist = false)
private String orgName;
@ApiModelProperty(value = "学习内容名称")
@TableField(exist = false)
private String learnName;
@ApiModelProperty("开始时间")
@TableField(exist = false)
@DateTimeFormat(pattern = "yyyy-MM-dd hh:mm:ss")
private Date startDate;
@ApiModelProperty("结束时间")
@TableField(exist = false)
@DateTimeFormat(pattern = "yyyy-MM-dd hh:mm:ss")
private Date endDate;
}
package cn.wisenergy.chnmuseum.party.model;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.Version;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import java.util.List;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import cn.wisenergy.chnmuseum.party.common.validator.groups.Add;
import cn.wisenergy.chnmuseum.party.common.validator.groups.Update;
import com.baomidou.mybatisplus.annotation.TableField;
/**
* <p>
* 区域表
* </p>
*
* @author Danny Lee
* @since 2021-03-24
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@TableName("t_area")
@ApiModel(value = "区域表", description = "区域表")
public class TArea implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("ID")
@TableId(value = "id", type = IdType.ASSIGN_ID)
@NotNull(message = "ID不能为空", groups = {Update.class})
private Integer id;
@ApiModelProperty("名称")
@TableField("name")
@NotBlank(message = "名称不能为空", groups = {Add.class, Update.class})
private String name;
@ApiModelProperty("简称")
@TableField("sname")
private String sname;
@ApiModelProperty("代码")
@TableField("code")
@NotBlank(message = "代码不能为空", groups = {Add.class, Update.class})
private String code;
@ApiModelProperty("类型")
@TableField("type")
@NotBlank(message = "类型不能为空", groups = {Add.class, Update.class})
private String type;
@ApiModelProperty("上级代码")
@TableField("parent_id")
private String parentId;
@ApiModelProperty("排序")
@TableField("sort_position")
private Integer sortPosition;
@ApiModelProperty("经度")
@TableField("longitude")
private BigDecimal longitude;
@ApiModelProperty("维度")
@TableField("latitude")
private BigDecimal latitude;
@ApiModelProperty("全称")
@TableField("full_name")
private String fullName;
@ApiModelProperty("备注")
@TableField("remarks")
private String remarks;
@ApiModelProperty("下级")
@TableField(exist = false)
private List<TArea> children;
}
package cn.wisenergy.chnmuseum.party.model;
import cn.wisenergy.chnmuseum.party.common.validator.groups.Add;
import cn.wisenergy.chnmuseum.party.common.validator.groups.Update;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* <p>
* 看板互动
* </p>
*
* @author Danny Lee
* @since 2021-03-23
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@TableName("t_interaction")
@ApiModel(value = "看板互动", description = "看板互动")
public class TInteraction implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("id")
@TableId(value = "id", type = IdType.ASSIGN_ID)
@NotNull(message = "idID不能为空", groups = {Update.class})
private String id;
@ApiModelProperty("机构id")
@TableField("organ_id")
private String organId;
@ApiModelProperty("帐户名")
@TableField("username")
@NotBlank(message = "帐户名不能为空", groups = {Add.class, Update.class})
private String username;
@ApiModelProperty("展板ID")
@TableField("board_id")
private String boardId;
@ApiModelProperty("学习时间")
@TableField(value = "study_time", fill = FieldFill.INSERT)
@NotNull(message = "创建时间不能为空", groups = {Add.class, Update.class})
private LocalDateTime studyTime;
@ApiModelProperty("观影人数")
@TableField("num")
private Integer num;
@ApiModelProperty("内容")
@TableField("content")
private String content;
@ApiModelProperty("图片信息")
@TableField("images")
private String images;
@ApiModelProperty("创建时间")
@TableField(value = "create_time", fill = FieldFill.INSERT)
@NotNull(message = "创建时间不能为空", groups = {Add.class, Update.class})
private LocalDateTime createTime;
@ApiModelProperty("管理员账号")
@TableField(exist = false)
@NotNull(message = "管理员账号不能为空", groups = {Add.class})
private String name;
@ApiModelProperty("密码")
@TableField(exist = false)
@NotNull(message = "密码不能为空", groups = {Add.class})
private String password;
}
package cn.wisenergy.chnmuseum.party.model;
import cn.wisenergy.chnmuseum.party.common.validator.groups.Add;
import cn.wisenergy.chnmuseum.party.common.validator.groups.Update;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.Version;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import java.util.Date;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import com.baomidou.mybatisplus.annotation.TableField;
import org.springframework.format.annotation.DateTimeFormat;
/**
* <p>
* 运维日志表
* </p>
*
* @author Danny Lee
* @since 2021-03-23
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@TableName("t_operation_log")
@ApiModel(value = "运维日志表", description = "运维日志表")
public class TOperationLog implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.ASSIGN_ID)
@NotNull(message = "ID不能为空", groups = {Update.class})
private String id;
@ApiModelProperty("运维用户id")
@TableField("user_id")
@NotNull(message = "运维用户id不能为空", groups = {Add.class, Update.class})
private String userId;
@ApiModelProperty("运维区域")
@TableField("area")
@NotBlank(message = "运维区域不能为空", groups = {Add.class, Update.class})
private String area;
@ApiModelProperty("操作内容")
@TableField("operation_type")
@NotBlank(message = "操作内容不能为空", groups = {Add.class, Update.class})
private String operationType;
@ApiModelProperty("创建时间")
@TableField(value = "create_time", fill = FieldFill.INSERT)
@NotNull(message = "创建时间不能为空", groups = {Add.class, Update.class})
private LocalDateTime createTime;
@ApiModelProperty("运维用户账号")
@TableField(exist = false)
private String userName;
@ApiModelProperty("开始时间")
@TableField(exist = false)
@DateTimeFormat(pattern = "yyyy-MM-dd hh:mm:ss")
private Date startDate;
@ApiModelProperty("结束时间")
@TableField(exist = false)
@DateTimeFormat(pattern = "yyyy-MM-dd hh:mm:ss")
private Date endDate;
}
......@@ -74,40 +74,35 @@ public class TOrgan implements Serializable {
@NotNull(message = "修改时间不能为空", groups = {Add.class, Update.class})
private LocalDateTime updateTime;
@ApiModelProperty("省")
@TableField("province")
@NotNull(message = "省不能为空", groups = {Add.class, Update.class})
private Integer province;
@ApiModelProperty("市")
@TableField("city")
@NotNull(message = "市不能为空", groups = {Add.class, Update.class})
private Integer city;
@ApiModelProperty("县")
@TableField("country")
@NotNull(message = "县不能为空", groups = {Add.class, Update.class})
private Integer country;
@ApiModelProperty("区域")
@TableField("area_id")
@NotNull(message = "区域不能为空", groups = {Add.class, Update.class})
private String areaId;
@ApiModelProperty("icon")
@TableField("icon")
@NotBlank(message = "icon不能为空", groups = {Add.class, Update.class})
private String icon;
@ApiModelProperty("备注")
@TableField("remarks")
@NotBlank(message = "备注不能为空", groups = {Add.class, Update.class})
private String remarks;
@ApiModelProperty("级别")
@TableField("level")
@NotNull(message = "级别不能为空", groups = {Add.class, Update.class})
private Integer level;
@ApiModelProperty("下级机构")
@TableField(exist = false)
private List<TOrgan> children;
@ApiModelProperty("上级机构名")
@TableField(exist = false)
private String parentName;
@ApiModelProperty("区域名")
@TableField(exist = false)
private String areaName;
}
......@@ -126,6 +126,10 @@ public class TUser implements Serializable {
@TableField("audit_status")
private String auditStatus;
@ApiModelProperty("区域")
@TableField("area_id")
private String areaId;
@ApiModelProperty("机构名称")
@TableField(exist = false)
private String orgName;
......@@ -138,4 +142,21 @@ public class TUser implements Serializable {
@TableField(exist = false)
private String password;
@ApiModelProperty("区域名")
@TableField(exist = false)
private String areaName;
@TableField(exist = false)
private String jwtToken;
public TUser(String id, String jwtToken) {
this.id = id;
this.jwtToken = jwtToken;
}
public TUser(String jwtToken) {
this.jwtToken = jwtToken;
}
}
package cn.wisenergy.chnmuseum.party.service;
import cn.wisenergy.chnmuseum.party.model.TArea;
import cn.wisenergy.chnmuseum.party.model.TOrgan;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 区域表 服务接口
* </p>
*
* @author Danny Lee
* @since 2021-03-24
*/
public interface TAreaService extends IService<TArea> {
List<TArea> getAreaTree();
}
package cn.wisenergy.chnmuseum.party.service;
import cn.wisenergy.chnmuseum.party.model.TInteraction;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 看板互动 服务接口
* </p>
*
* @author Danny Lee
* @since 2021-03-23
*/
public interface TInteractionService extends IService<TInteraction> {
}
package cn.wisenergy.chnmuseum.party.service;
import cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam;
import cn.wisenergy.chnmuseum.party.model.TOperationLog;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 运维日志表 服务接口
* </p>
*
* @author Danny Lee
* @since 2021-03-23
*/
public interface TOperationLogService extends IService<TOperationLog> {
Page<TOperationLog> pageList(Page<TOperationLog> page, TOperationLog operationLog);
}
......@@ -18,4 +18,6 @@ public interface TOrganService extends IService<TOrgan> {
List<TOrgan> getTree();
boolean batchUpload(List excelList);
TOrgan selectById(String id);
}
......@@ -17,4 +17,6 @@ public interface TUserService extends IService<TUser> {
TUser selectByUsername(String userName);
Page<TUser> selectList(Page<TUser> page, String userName);
TUser selectById(String id);
}
package cn.wisenergy.chnmuseum.party.service.impl;
import cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam;
import cn.wisenergy.chnmuseum.party.model.RunLog;
import cn.wisenergy.chnmuseum.party.mapper.RunLogMapper;
import cn.wisenergy.chnmuseum.party.service.RunLogService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
......@@ -27,4 +29,7 @@ public class RunLogServiceImpl extends ServiceImpl<RunLogMapper, RunLog> impleme
return save;
}
public Page<RunLog> pageList(Page<RunLog> page, RunLog runLog) {
return page.setRecords(runLogMapper.pageList(page,runLog));
}
}
package cn.wisenergy.chnmuseum.party.service.impl;
import cn.wisenergy.chnmuseum.party.model.TArea;
import cn.wisenergy.chnmuseum.party.mapper.TAreaMapper;
import cn.wisenergy.chnmuseum.party.model.TOrgan;
import cn.wisenergy.chnmuseum.party.service.TAreaService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* <pre>
* 区域表 服务实现类
* </pre>
*
* @author Danny Lee
* @since 2021-03-24
*/
@Slf4j
@Service
public class TAreaServiceImpl extends ServiceImpl<TAreaMapper, TArea> implements TAreaService {
@Resource
private TAreaMapper areaMapper;
@Override
public List<TArea> getAreaTree() {
List<TArea> list = list();
HashMap<String, TArea> map = new HashMap<>();
list.forEach(o-> map.put(o.getId().toString(),o));
for (TArea o : list) {
TArea area= map.get(o.getParentId());
if(area!=null){
//说明有值
if(area.getChildren()==null){
area.setChildren(new ArrayList<>());
}
area.getChildren().add(o);
}
}
list = list.stream().filter(o -> o.getType().equals("P")).collect(Collectors.toList());
return list;
}
public List<Map<String,String>> languageInfo() {
return areaMapper.languageInfo();
}
}
package cn.wisenergy.chnmuseum.party.service.impl;
import cn.wisenergy.chnmuseum.party.model.TInteraction;
import cn.wisenergy.chnmuseum.party.mapper.TInteractionMapper;
import cn.wisenergy.chnmuseum.party.service.TInteractionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
/**
* <pre>
* 看板互动 服务实现类
* </pre>
*
* @author Danny Lee
* @since 2021-03-23
*/
@Slf4j
@Service
public class TInteractionServiceImpl extends ServiceImpl<TInteractionMapper, TInteraction> implements TInteractionService {
@Resource
private TInteractionMapper tInteractionMapper;
}
package cn.wisenergy.chnmuseum.party.service.impl;
import cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam;
import cn.wisenergy.chnmuseum.party.model.TOperationLog;
import cn.wisenergy.chnmuseum.party.mapper.TOperationLogMapper;
import cn.wisenergy.chnmuseum.party.service.TOperationLogService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
/**
* <pre>
* 运维日志表 服务实现类
* </pre>
*
* @author Danny Lee
* @since 2021-03-23
*/
@Slf4j
@Service
public class TOperationLogServiceImpl extends ServiceImpl<TOperationLogMapper, TOperationLog> implements TOperationLogService {
@Autowired
private TOperationLogMapper tOperationLogMapper;
@Override
public Page<TOperationLog> pageList(Page<TOperationLog> page, TOperationLog operationLog) {
return page.setRecords(tOperationLogMapper.pageList(page,operationLog));
}
}
......@@ -59,10 +59,10 @@ public class TOrganServiceImpl extends ServiceImpl<TOrganMapper, TOrgan> impleme
HashMap<String, TOrgan> map1 = new HashMap<>();
list1.stream().forEach(o-> map1.put(o.getName(),o));
HashMap<String, Integer> area = new HashMap<>();
HashMap<String, String> 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())));
mapList.stream().forEach(m->area.put(m.get("name").toString(),m.get("id").toString()));
for (int i = 0; i < excelList.size(); i++) {
Map<String, String> map = null;
......@@ -77,9 +77,7 @@ public class TOrganServiceImpl extends ServiceImpl<TOrganMapper, TOrgan> impleme
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.setAreaId(area.get(map.get("区域")));
organ.setIcon(map.get("icon"));
organ.setRemarks(map.get("备注"));
organ.setIsDeleted(false);
......@@ -90,4 +88,9 @@ public class TOrganServiceImpl extends ServiceImpl<TOrganMapper, TOrgan> impleme
flag = saveBatch(list);
return flag;
}
@Override
public TOrgan selectById(String id) {
return organMapper.getById(id);
}
}
......@@ -37,4 +37,9 @@ public class TUserServiceImpl extends ServiceImpl<TUserMapper, TUser> implements
public Page<TUser> selectList(Page<TUser> page, String userName) {
return page.setRecords(tUserMapper.selectList(userName));
}
@Override
public TUser selectById(String id) {
return tUserMapper.getById(id);
}
}
......@@ -32,6 +32,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.time.LocalDate;
import java.util.*;
import java.util.concurrent.TimeUnit;
......@@ -120,6 +121,8 @@ public class LoginController {
TUser user;
if (StringUtils.isNoneBlank(username)) {
try {
//访问一次,计数一次
ValueOperations<String, String> opsForValue = stringRedisTemplate.opsForValue();
if ("LOCK".equals(opsForValue.get(SHIRO_IS_LOCK + username))) {
......@@ -129,8 +132,6 @@ public class LoginController {
}
user = userService.selectByUsername(username);
List<Role> roles = roleService.selectRoleByUserId(user.getId());
user.setRoleList(roles);
if (user == null) {
resultMap.put("status", 500);
resultMap.put("message", "用户名或密码不正确!");
......@@ -141,11 +142,13 @@ public class LoginController {
throw new DisabledAccountException("此帐号已禁用,请联系管理员!");
}
// if (!user.getAllowLogin()) {
// throw new DisabledAccountException("您无权访问,请联系管理员!");
// }
if (user.getPermanent()!=null&&!user.getPermanent()) {
if (user.getEffectiveDate().isAfter(LocalDate.now())||user.getExiredDate().isBefore(LocalDate.now())) {
throw new DisabledAccountException("此帐号已失效,请联系管理员!");
}
}
try {
byte[] salt = user.getPasswordSalt();
String s1 = new String(SHA256PasswordEncryptionService.createPasswordHash(password, salt));
if (!new String(SHA256PasswordEncryptionService.createPasswordHash(password, salt)).equals(new String(user.getPasswordHash()))) {
......@@ -160,7 +163,8 @@ public class LoginController {
}
throw new IncorrectCredentialsException("用户名或密码不正确!");
}
List<Role> roles = roleService.selectRoleByUserId(user.getId());
user.setRoleList(roles);
//获取当前用户角色拥有菜单
List<Menu> userMenuPerms = new ArrayList<>();
if (roles.size() > 0) {
......@@ -196,7 +200,7 @@ public class LoginController {
public ResponseEntity<JSONObject> logout(@RequestHeader(value = "token") String token) {
try {
if (StringUtils.isNotBlank(token)) {
SecurityUtils.getSubject().logout();
// SecurityUtils.getSubject().logout();
this.stringRedisTemplate.delete(SHIRO_JWT_TOKEN + token);
}
JSONObject resultMap = new JSONObject();
......
......@@ -651,7 +651,7 @@ public class RoleController extends BaseController {
ew.eq("is_deleted", 0);
ew.eq("status", 1);
ew.orderByAsc("sortorder");
ew.orderByDesc("update_time");
ew.orderByDesc("create_time");
return ResponseEntity.ok(this.roleService.list(ew));
} catch (Exception e) {
LOGGER.error("查询角色列表出错!", e);
......
package cn.wisenergy.chnmuseum.party.web.controller;
import cn.wisenergy.chnmuseum.party.common.log.OperType;
import cn.wisenergy.chnmuseum.party.common.util.DateUtil80;
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.common.vo.GenericPageParam;
import cn.wisenergy.chnmuseum.party.model.*;
import cn.wisenergy.chnmuseum.party.service.TOperationLogService;
import cn.wisenergy.chnmuseum.party.service.impl.RunLogServiceImpl;
import cn.wisenergy.chnmuseum.party.service.impl.SysLogServiceImpl;
import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
......@@ -24,9 +30,13 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Map;
@RestController
@RequestMapping("/sysLog")
@Api(tags = {"日志管理接口"})
public class SysLogController extends BaseController {
@Resource
......@@ -35,12 +45,15 @@ public class SysLogController extends BaseController {
@Resource
private RunLogServiceImpl runLogService;
@Resource
private TOperationLogService operationLogService;
/**
* 插入系统日志表
*/
@ApiOperation(value = "插入系统日志", notes = "插入系统日志")
@PostMapping(value = "/insertSysLog")
public Boolean insertSysLog(String operationContent, String username,String id) {
public Boolean insertSysLog(String operationContent, String username, String id) {
SysLog sysLog = new SysLog();
//日志时间
sysLog.setOperationTime(DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis()));
......@@ -57,7 +70,7 @@ public class SysLogController extends BaseController {
}
if ("1".equals(id)) {
sysLog.setType(1);
}else {
} else {
sysLog.setType(2);
}
//日志内容
......@@ -72,17 +85,38 @@ public class SysLogController extends BaseController {
* 查询系统日志
*/
@ApiOperation(value = "查询系统日志", notes = "查询系统日志")
@ApiImplicitParams({
@ApiImplicitParam(name = "_index", value = "分页起始偏移量", required = false, paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "_size", value = "返回条数", required = false, paramType = "query", dataType = "Integer")})
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "_size", value = "返回条数", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "nameOrCode", value = "名称或编码", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "startDate", value = "创建时间-开始", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endDate", value = "创建时间-结束", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "type", value = "日志类型", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "operationType", value = "操作类型", paramType = "query", dataType = "String")
})
@GetMapping(value = "/querySysLogList")
@RequiresPermissions("/sysLog/querySysLogList")
public ResponseEntity<Page<SysLog>> querySysLogList() {
public ResponseEntity<Page<SysLog>> querySysLogList(GenericPageParam genericPageParam) {
try {
QueryWrapper<SysLog> ew = new QueryWrapper<>();
ew.orderByDesc("operation_time");
Page<SysLog> page = getPage();
page = sysLogService.page(page, ew);
LambdaQueryWrapper<SysLog> queryWrapper = new LambdaQueryWrapper<>();
// 对名称或编码模糊查询
if (StringUtils.isNotBlank(genericPageParam.getNameOrCode())) {
queryWrapper.like(SysLog::getOperator, genericPageParam.getNameOrCode());
}
if (StringUtils.isNotBlank(genericPageParam.getType())) {
queryWrapper.eq(SysLog::getType, genericPageParam.getType());
}
if (StringUtils.isNotBlank(genericPageParam.getOperationType())) {
queryWrapper.eq(SysLog::getOperationType,genericPageParam.getOperationType());
}
// 根据创建时间区间检索
if (genericPageParam.getStartDate() != null && genericPageParam.getEndDate() != null) {
queryWrapper.ge(SysLog::getOperationTime, genericPageParam.getStartDate().atTime(0, 0, 0))
.le(SysLog::getOperationTime, genericPageParam.getEndDate().atTime(23, 59, 59));
}
// 设置排序规则
queryWrapper.orderByDesc(SysLog::getOperationTime);
Page<SysLog> page = sysLogService.page(getPage(), queryWrapper);
return ResponseEntity.ok(page);
} catch (Exception e) {
logger.error("查询系统日志列表出错!", e);
......@@ -93,12 +127,87 @@ public class SysLogController extends BaseController {
/**
* 插入机顶盒日志表
*/
@ApiOperation(value = "插入系统日志", notes = "插入系统日志")
@ApiOperation(value = "插入机顶盒日志表", notes = "插入机顶盒日志表")
@PostMapping(value = "/insertRunLog")
public Boolean insertRunLog(RunLog runLog) {
boolean b = runLogService.insertRunLog(runLog);
return b;
}
/**
* 插入运维日志表
*/
@ApiOperation(value = "插入运维日志表", notes = "插入运维日志表")
@PostMapping(value = "/insertOperationLog")
public Boolean insertOperationLog(TOperationLog tOperationLog) {
tOperationLog.setCreateTime(LocalDateTime.now());
boolean b = operationLogService.save(tOperationLog);
return b;
}
/**
* 查询运维日志
*/
@ApiOperation(value = "查询运维日志", notes = "查询运维日志")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "_size", value = "返回条数", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "userName", value = "运维账号", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "startDate", value = "创建时间-开始", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endDate", value = "创建时间-结束", paramType = "query", dataType = "String")
})
@GetMapping(value = "/OperationLog")
@RequiresPermissions("/sysLog/OperationLog")
public ResponseEntity<Page<TOperationLog>> OperationLog(TOperationLog operationLog) {
try {
Page<TOperationLog> page = operationLogService.pageList(getPage(), operationLog);
return ResponseEntity.ok(page);
} catch (Exception e) {
logger.error("查询系统日志列表出错!", e);
}
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
/**
* 查询机顶盒日志
*/
@ApiOperation(value = "查询机顶盒日志", notes = "查询机顶盒日志")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "_size", value = "返回条数", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "nameOrCode", value = "名称或编码", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "startDate", value = "创建时间-开始", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endDate", value = "创建时间-结束", paramType = "query", dataType = "String")
})
@GetMapping(value = "/runLogList")
@RequiresPermissions("/sysLog/runLogList")
public ResponseEntity<Page<RunLog>> runLogList(RunLog runLog) {
try {
Page<RunLog> page = runLogService.pageList(getPage(), runLog);
return ResponseEntity.ok(page);
} catch (Exception e) {
logger.error("查询系统日志列表出错!", e);
}
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
/**
* 返回日志操作类型
* @param
* @return
*/
@PostMapping("/getOperationType")
@RequiresPermissions("/sysLog/getOperationType")
@ApiOperation(value = "返回日志操作类型", notes = "返回日志操作类型")
public Map<String, Object> getTInteractionPageList() {
OperType[] values = OperType.values();
ArrayList<String> list = new ArrayList<>();
for (OperType value : values) {
list.add(value.getMsg());
}
return getResult(list);
}
}
package cn.wisenergy.chnmuseum.party.web.controller;
import cn.wisenergy.chnmuseum.party.auth.SHA256PasswordEncryptionService;
import cn.wisenergy.chnmuseum.party.auth.SecureRandomSaltService;
import cn.wisenergy.chnmuseum.party.common.util.DateUtil80;
import cn.wisenergy.chnmuseum.party.model.TUser;
import cn.wisenergy.chnmuseum.party.service.impl.TUserServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController;
import cn.wisenergy.chnmuseum.party.model.TInteraction;
import cn.wisenergy.chnmuseum.party.service.TInteractionService;
import cn.wisenergy.chnmuseum.party.common.enums.AuditStatusEnum;
import cn.wisenergy.chnmuseum.party.common.validator.groups.Add;
import cn.wisenergy.chnmuseum.party.common.validator.groups.Update;
import cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
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.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* <pre>
* 看板互动 前端控制器
* </pre>
*
* @author Danny Lee
* @since 2021-03-23
*/
@Slf4j
@RestController
@RequestMapping("/interaction")
@Api(tags = {"看板互动操作接口"})
public class TInteractionController extends BaseController {
@Resource
private TInteractionService tInteractionService;
@Resource
private TUserServiceImpl userService;
@PostMapping("/add")
@RequiresPermissions("/interaction/add")
@ApiOperation(value = "添加看板互动", notes = "添加看板互动")
public Map<String, Object> saveTInteraction(TInteraction tInteraction) {
Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
if (StringUtils.isBlank(tInteraction.getName())||StringUtils.isBlank(tInteraction.getPassword())) {
resultMap.put("code", 400);
resultMap.put("msg", "请输入用户名和密码");
return resultMap;
}
TUser user = userService.selectByUsername(tInteraction.getName());
if (user == null) {
resultMap.put("code", 500);
resultMap.put("msg", "用户名错误");
return resultMap;
}
byte[] salt = user.getPasswordSalt();
if (!new String(SHA256PasswordEncryptionService.createPasswordHash(tInteraction.getPassword(), salt))
.equals(new String(user.getPasswordHash()))) {
resultMap.put("code", 500);
resultMap.put("msg", "密码错误");
return resultMap;
}
tInteraction.setCreateTime(LocalDateTime.now());
// 保存业务节点信息
boolean result = tInteractionService.save(tInteraction);
// 返回操作结果
if (result) {
return getSuccessResult();
} else {
// 保存失败
return getFailResult();
}
}
@PutMapping("/update")
@RequiresPermissions("/interaction/update")
@ApiOperation(value = "修改看板互动信息", notes = "修改看板互动信息")
public Map<String, Object> updateTInteraction(@Validated(value = {Update.class}) TInteraction tInteraction) {
boolean flag = tInteractionService.updateById(tInteraction);
if (flag) {
return getSuccessResult();
}
return getFailResult();
}
@DeleteMapping("/delete")
@RequiresPermissions("/interaction/delete")
@ApiOperation(value = "根据ID删除看板互动", notes = "根据ID删除看板互动")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "id", value = "标识ID", paramType = "path", dataType = "String")
})
public Map<String, Object> deleteTInteraction(@PathVariable("id") String id) {
boolean result = tInteractionService.removeById(id);
if (result) {
return getSuccessResult();
}
return getFailResult();
}
@PostMapping("/getList")
@RequiresPermissions("/interaction/getList")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "_size", value = "返回条数", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "orgId", value = "机构id", paramType = "query", dataType = "String")
})
@ApiOperation(value = "获取看板互动列表", notes = "获取看板互动列表")
public Map<String, Object> getTInteractionPageList(String orgId) {
Page<TInteraction> list = tInteractionService.page(getPage(),new UpdateWrapper<TInteraction>().eq("organ_id", orgId));
return getResult(list);
}
@ApiOperation(value = "获取看板互动详情", notes = "获取看板互动详情")
@GetMapping("/getById")
@RequiresPermissions("/interaction/getById")
public Map<String, Object> getById(String id) {
TInteraction tInteraction = tInteractionService.getById(id);
return getResult(tInteraction);
}
// @ApiImplicitParams(value = {
// @ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"),
// @ApiImplicitParam(name = "_size", value = "返回条数", paramType = "query", dataType = "Integer"),
// @ApiImplicitParam(name = "nameOrCode", value = "名称或编码", paramType = "query", dataType = "String"),
// @ApiImplicitParam(name = "startDate", value = "创建时间-开始", paramType = "query", dataType = "String"),
// @ApiImplicitParam(name = "endDate", value = "创建时间-结束", paramType = "query", dataType = "String")
// })
// @PostMapping("/getPageList")
// @RequiresPermissions("/interaction/getPageList")
// @ApiOperation(value = "获取看板互动分页列表", notes = "获取看板互动分页列表")
// public Map<String, Object> getTInteractionPageList(GenericPageParam genericPageParam) {
// LambdaQueryWrapper<TInteraction> queryWrapper = new LambdaQueryWrapper<>();
// // 对名称或编码模糊查询
// if (StringUtils.isNotBlank(genericPageParam.getNameOrCode())) {
// queryWrapper.like(TInteraction::getUsername, genericPageParam.getNameOrCode());
// }
// // 根据创建时间区间检索
// if (genericPageParam.getStartDate() != null && genericPageParam.getEndDate() != null) {
// queryWrapper.ge(TInteraction::getCreateTime, genericPageParam.getStartDate().atTime(0, 0, 0))
// .le(TInteraction::getCreateTime, genericPageParam.getEndDate().atTime(23, 59, 59));
// }
// // 设置排序规则
// queryWrapper.orderByDesc(TInteraction::getCreateTime);
// Page<TInteraction> page = this.tInteractionService.page(getPage(), queryWrapper);
// for (TInteraction tInteraction : page.getRecords()) {
//
// }
// return getResult(page);
// }
}
//package cn.wisenergy.chnmuseum.party.web.controller;
//
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
//import com.baomidou.mybatisplus.core.toolkit.Wrappers;
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController;
//import cn.wisenergy.chnmuseum.party.model.TOperationLog;
//import cn.wisenergy.chnmuseum.party.service.TOperationLogService;
//import cn.wisenergy.chnmuseum.party.common.enums.AuditStatusEnum;
//import cn.wisenergy.chnmuseum.party.common.validator.groups.Add;
//import cn.wisenergy.chnmuseum.party.common.validator.groups.Update;
//import cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam;
//
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang3.StringUtils;
//import org.apache.shiro.authz.annotation.RequiresPermissions;
//import org.springframework.validation.annotation.Validated;
//import org.springframework.web.bind.annotation.*;
//import org.springframework.stereotype.Controller;
//
//import javax.annotation.Resource;
//import javax.validation.constraints.NotNull;
//import java.util.List;
//import java.util.Map;
//
///**
// * <pre>
// * 运维日志表 前端控制器
// * </pre>
// *
// * @author Danny Lee
// * @since 2021-03-23
// */
//@Slf4j
//@RestController
//@RequestMapping("/tOperationLog")
//@Api(tags = {"运维日志表操作接口"})
//public class TOperationLogController extends BaseController {
//
// @Resource
// private TOperationLogService tOperationLogService;
//
// @PostMapping("/batchSave")
// @RequiresPermissions("t:operation:log:batch:save")
// @ApiOperation(value = "批量添加运维日志表", notes = "批量添加运维日志表")
// public Map<String, Object> batchSaveTOperationLog(@Validated(value = {Add.class}) List<TOperationLog> tOperationLogList) {
// // 保存业务节点信息
// boolean result = tOperationLogService.saveBatch(tOperationLogList);
// // 返回操作结果
// if (result) {
// return getSuccessResult();
// } else {
// // 保存失败
// return getFailResult();
// }
// }
//
// @PostMapping("/save")
// @RequiresPermissions("t:operation:log:save")
// @ApiOperation(value = "添加运维日志表", notes = "添加运维日志表")
// public Map<String, Object> saveTOperationLog(@Validated(value = {Add.class}) TOperationLog tOperationLog) {
// // 保存业务节点信息
// boolean result = tOperationLogService.save(tOperationLog);
// // 返回操作结果
// if (result) {
// return getSuccessResult();
// } else {
// // 保存失败
// return getFailResult();
// }
// }
//
// @PutMapping("/update")
// @RequiresPermissions("t:operation:log:update")
// @ApiOperation(value = "修改运维日志表信息", notes = "修改运维日志表信息")
// public Map<String, Object> updateTOperationLog(@Validated(value = {Update.class}) TOperationLog tOperationLog) {
// boolean flag = tOperationLogService.updateById(tOperationLog);
// if (flag) {
// return getSuccessResult();
// }
// return getFailResult();
// }
//
// @PutMapping("/updateAuditStatus/{id}")
// @RequiresPermissions("t:operation:log:update:audit:status")
// @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<TOperationLog> updateWrapper = new UpdateWrapper<>();
// updateWrapper.eq("id", id);
// updateWrapper.eq("audit_status", status.name());
// boolean flag = tOperationLogService.update(updateWrapper);
// if (flag) {
// return getSuccessResult();
// }
// return getFailResult();
// }
//
// @DeleteMapping("/delete/{id}")
// @RequiresPermissions("t:operation:log:delete")
// @ApiOperation(value = "根据ID删除运维日志表", notes = "根据ID删除运维日志表")
// @ApiImplicitParams(value = {
// @ApiImplicitParam(name = "id", value = "标识ID", paramType = "path", dataType = "String")
// })
// public Map<String, Object> deleteTOperationLog(@PathVariable("id") String id) {
// boolean result = tOperationLogService.removeById(id);
// if (result) {
// return getSuccessResult();
// }
// return getFailResult();
// }
//
// @GetMapping("/getList")
// @RequiresPermissions("t:operation:log:list")
// @ApiOperation(value = "获取运维日志表全部列表(无分页)", notes = "获取运维日志表全部列表(无分页)")
// @ApiImplicitParams(value = {
// @ApiImplicitParam(name = "auditStatus", value = "审核状态", paramType = "query", dataType = "String")
// })
// public Map<String, Object> getTOperationLogList(@RequestParam(value = "auditStatus", defaultValue = "APPROVED_FINAL", required = false) AuditStatusEnum auditStatus) {
// List<TOperationLog> tOperationLogList = tOperationLogService.list();
// return getResult(tOperationLogList);
// }
//
// @ApiImplicitParams(value = {
// @ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"),
// @ApiImplicitParam(name = "_size", value = "返回条数", paramType = "query", dataType = "Integer"),
// @ApiImplicitParam(name = "nameOrCode", value = "名称或编码", paramType = "query", dataType = "String"),
// @ApiImplicitParam(name = "startDate", value = "创建时间-开始", paramType = "query", dataType = "String"),
// @ApiImplicitParam(name = "endDate", value = "创建时间-结束", paramType = "query", dataType = "String")
// })
// @PostMapping("/getPageList")
// @RequiresPermissions("t:operation:log:page")
// @ApiOperation(value = "获取运维日志表分页列表", notes = "获取运维日志表分页列表")
// public Map<String, Object> getTOperationLogPageList(GenericPageParam genericPageParam) {
// LambdaQueryWrapper<TOperationLog> queryWrapper = new LambdaQueryWrapper<>();
// // 对名称或编码模糊查询
// if (StringUtils.isNotBlank(genericPageParam.getNameOrCode())) {
// queryWrapper.like(TOperationLog::getUserId, genericPageParam.getNameOrCode());
// }
// // 根据创建时间区间检索
// if (genericPageParam.getStartDate() != null && genericPageParam.getEndDate() != null) {
// queryWrapper.ge(TOperationLog::getCreateTime, genericPageParam.getStartDate().atTime(0, 0, 0))
// .le(TOperationLog::getCreateTime, genericPageParam.getEndDate().atTime(23, 59, 59));
// }
// // 设置排序规则
// queryWrapper.orderByDesc(TOperationLog::getCreateTime);
// Page<TOperationLog> page = this.tOperationLogService.page(getPage(), queryWrapper);
// for (TOperationLog tOperationLog : page.getRecords()) {
//
// }
// return getResult(page);
// }
//
// @ApiOperation(value = "获取运维日志表详情", notes = "获取运维日志表详情")
// @ApiImplicitParams({
// @ApiImplicitParam(name = "id", value = "标识ID", dataType = "String", paramType = "path")
// })
// @GetMapping("/get/{id}")
// @RequiresPermissions("t:operation:log:get:id")
// public Map<String, Object> getById(@PathVariable("id") String id) {
// TOperationLog tOperationLog = tOperationLogService.getById(id);
// return getResult(tOperationLog);
// }
//
//}
//
......@@ -5,6 +5,8 @@ import cn.wisenergy.chnmuseum.party.common.log.OperModule;
import cn.wisenergy.chnmuseum.party.common.log.OperType;
import cn.wisenergy.chnmuseum.party.common.util.DateUtil80;
import cn.wisenergy.chnmuseum.party.common.util.ImportExcelUtil;
import cn.wisenergy.chnmuseum.party.model.TArea;
import cn.wisenergy.chnmuseum.party.service.TAreaService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
......@@ -61,6 +63,9 @@ public class TOrganController extends BaseController {
@Resource
private TOrganService tOrganService;
@Resource
private TAreaService tAreaService;
@PostMapping("/add")
@RequiresPermissions("/organ/add")
......@@ -157,7 +162,7 @@ public class TOrganController extends BaseController {
@RequiresPermissions("/organ/getById")
@MethodLog(operModule = OperModule.ORG,operType = OperType.SELECT)
public Map<String, Object> getById(String id) {
TOrgan tOrgan = tOrganService.getById(id);
TOrgan tOrgan = tOrganService.selectById(id);
return getResult(tOrgan);
}
......@@ -165,7 +170,7 @@ public class TOrganController extends BaseController {
@GetMapping("/getTree")
@RequiresPermissions("/organ/getTree")
@ApiOperation(value = "获取机构树", notes = "获取机构树")
@MethodLog(operModule = OperModule.ORG,operType = OperType.SELECT)
// @MethodLog(operModule = OperModule.ORG,operType = OperType.SELECT)
public Map<String, Object> getTree(String name) {
List<TOrgan> list = new ArrayList<>();
if (StringUtils.isBlank(name)) {
......@@ -176,6 +181,15 @@ public class TOrganController extends BaseController {
return getResult(list);
}
@GetMapping("/getAreaTree")
@RequiresPermissions("/organ/getAreaTree")
@ApiOperation(value = "获取区域树", notes = "获取机构树")
// @MethodLog(operModule = OperModule.ORG,operType = OperType.SELECT)
public Map<String, Object> getAreaTree() {
List<TArea> list = tAreaService.getAreaTree();
return getResult(list);
}
// 导入EXCEL
@ApiOperation(value = "导入EXCEL", notes = "导入EXCEL", httpMethod = "POST")
......
......@@ -72,6 +72,7 @@ public class BaseController implements Serializable {
Map<String, Object> map = new HashMap<>();
map.put(RESULT_INFO_ENUM.RESULT_CODE.getKey(), RESPONSE_CODE_ENUM.REQUEST_SUCCESS.getCode());
map.put(RESULT_INFO_ENUM.RESULT_MSG.getKey(), RESPONSE_CODE_ENUM.REQUEST_SUCCESS.getMsg());
map.put(RESULT_INFO_ENUM.RESULT_BODY.getKey(),"");
return map;
}
......
......@@ -10,6 +10,8 @@
<result column="learning_content_id" property="learningContentId" />
<result column="start_time" property="startTime" />
<result column="end_time" property="endTime" />
<result column="org_name" property="orgName" />
<result column="learn_name" property="learnName" />
</resultMap>
<!-- 通用查询结果列 -->
......@@ -17,4 +19,21 @@
id, mac_addr, organ_id, learning_content_id, start_time, end_time
</sql>
<select id="pageList" resultMap="BaseResultMap">
SELECT r.*,o.name org_name,l.name learn_name
FROM run_log r
left join t_organ o on o.id = r.organ_id
left join learning_content l on l.id =r.learning_content_id
where 1=1
<if test=" runLog.organId != null and runLog.organId != '' ">
and r.organ_id = #{runLog.organId}
</if>
<if test=" runLog.startDate != null">
and r.start_time <![CDATA[>=]]> #{runLog.startDate}
</if>
<if test=" runLog.endDate != null">
and r.start_time <![CDATA[<=]]> #{runLog.endDate}
</if>
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.wisenergy.chnmuseum.party.mapper.TAreaMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.wisenergy.chnmuseum.party.model.TArea">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="sname" property="sname" />
<result column="code" property="code" />
<result column="type" property="type" />
<result column="parent_id" property="parentId" />
<result column="sort_position" property="sortPosition" />
<result column="longitude" property="longitude" />
<result column="latitude" property="latitude" />
<result column="full_name" property="fullName" />
<result column="remarks" property="remarks" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, name, sname, code, type, parent_id, sort_position, longitude, latitude, full_name, remarks
</sql>
<select id="languageInfo" resultType="java.util.HashMap">
select id,name,code from t_language
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.wisenergy.chnmuseum.party.mapper.TInteractionMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.wisenergy.chnmuseum.party.model.TInteraction">
<id column="id" property="id"/>
<result column="organ_id" property="organId"/>
<result column="username" property="username"/>
<result column="board_id" property="boardId"/>
<result column="study_time" property="studyTime"/>
<result column="num" property="num"/>
<result column="content" property="content"/>
<result column="images" property="images"/>
<result column="create_time" property="createTime"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, organ_id, username, board_id, study_time, num, content, images, create_time
</sql>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.wisenergy.chnmuseum.party.mapper.TOperationLogMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.wisenergy.chnmuseum.party.model.TOperationLog">
<id column="id" property="id"/>
<result column="user_id" property="userId"/>
<result column="area" property="area"/>
<result column="operation_type" property="operationType"/>
<result column="create_time" property="createTime"/>
<result column="user_name" property="userName"/>
<result column="start_date" property="startDate"/>
<result column="end_date" property="endDate"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, user_id, area, operation_type, create_time
</sql>
<select id="pageList" resultMap="BaseResultMap">
SELECT o.*,u.user_name
FROM t_operation_log o
left join t_user u on o.user_id = u.id
where 1=1
<if test=" operationLog.userName != null and operationLog.userName != '' ">
and u.user_name like concat('%', #{operationLog.userName}, '%')
</if>
<if test=" operationLog.startDate != null">
and o.create_time <![CDATA[>=]]> #{operationLog.startDate}
</if>
<if test=" operationLog.endDate != null">
and o.create_time <![CDATA[<=]]> #{operationLog.endDate}
</if>
</select>
</mapper>
......@@ -4,28 +4,36 @@
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.wisenergy.chnmuseum.party.model.TOrgan">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="parent_id" property="parentId" />
<result column="is_deleted" property="isDeleted" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
<result column="province" property="province" />
<result column="city" property="city" />
<result column="country" property="country" />
<result column="icon" property="icon" />
<result column="remarks" property="remarks" />
<result column="level" property="level" />
</resultMap>
<id column="id" property="id"/>
<result column="name" property="name"/>
<result column="parent_id" property="parentId"/>
<result column="is_deleted" property="isDeleted"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="area_id" property="areaId"/>
<result column="icon" property="icon"/>
<result column="remarks" property="remarks"/>
<result column="level" property="level"/>
<result column="parent_name" property="parentName"/>
<result column="area_name" property="areaName"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
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, area_id, icon, remarks, level
</sql>
<select id="selectArea" resultType="java.util.HashMap">
select concat(name,type) name,id from t_area
select full_name name,id from t_area
</select>
<select id="getById" resultMap="BaseResultMap">
select o.* ,r.`name` parent_name,a.full_name area_name
from t_organ o
left join t_organ r on o.parent_id = r.id
left join t_area a on o.area_id = a.id
where o.id = #{id}
</select>
</mapper>
......@@ -23,7 +23,9 @@
<result column="real_name" property="realName"/>
<result column="type" property="type"/>
<result column="audit_status" property="auditStatus"/>
<result column="area_id" property="areaId"/>
<result column="org_name" property="orgName"/>
<result column="area_name" property="areaName"/>
<collection fetchType="eager" property="roleList" ofType="cn.wisenergy.chnmuseum.party.model.Role"
select="selectRoles" column="user_name"/>
</resultMap>
......@@ -48,16 +50,26 @@
</sql>
<select id="selectByUsername" resultMap="BaseResultMap">
select u.*,o.name org_name
select u.*,o.name org_name,a.full_name area_name
from t_user u
left join t_organ o on o.id = u.org_id
left join t_area a on u.area_id = a.id
where u.user_name =#{userName}
</select>
<select id="getById" resultMap="BaseResultMap">
select u.*,o.name org_name,a.full_name area_name
from t_user u
left join t_organ o on o.id = u.org_id
left join t_area a on u.area_id = a.id
where u.id =#{id}
</select>
<select id="selectList" resultMap="BaseResultMap">
select u.*,o.name org_name
select u.*,o.name org_name,a.full_name area_name
from t_user u
left join t_organ o on o.id = u.org_id
left join t_area a on u.area_id = a.id
<if test=" username != null and username != '' ">
where u.user_name LIKE concat('%', #{userName}, '%')
</if>
......
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