This commit is contained in:
xiangwb
2018-04-10 16:41:58 +08:00
parent 84598d7603
commit 4d228a3575
21 changed files with 124 additions and 174 deletions
@@ -11,53 +11,53 @@ import java.util.Date;
* 作者: xiangwb
*/
@Data
public class EmailModel {
public EmailModel(){
//默认值
}
/**
* 发送邮件协议名称,默认smtp
*/
private String protocol;
/**
* 发送邮箱地址
*/
private String fromEmail;
/**
* 邮箱密码
*/
private String password;
/**
* 接收邮箱
*/
private String toEmail;
/**
* 设置发送时间,默认是即时发送
*/
private Date sendTime;
/**
* 发送邮件服务器主机
*/
private String serverHost;
/**
* 发送邮件服务器端口
*/
private Integer serverPort;
/**
* 是否需要身份验证
*/
private boolean auth;
public class EmailModel {
public EmailModel() {
//默认值
}
/**
* 邮件主题
*/
private String subject;
/**
* 邮件内容
*/
private String centent;
/**
* 邮件附件的文件名
*/
private String[] attachFileNames;
/**
* 发送邮件协议名称,默认smtp
*/
private String protocol;
/**
* 发送邮箱地址
*/
private String fromEmail;
/**
* 邮箱密码
*/
private String password;
/**
* 接收邮箱
*/
private String toEmail;
/**
* 设置发送时间,默认是即时发送
*/
private Date sendTime;
/**
* 发送邮件服务器主机
*/
private String serverHost;
/**
* 发送邮件服务器端口
*/
private Integer serverPort;
/**
* 是否需要身份验证
*/
private boolean auth;
/**
* 邮件主题
*/
private String subject;
/**
* 邮件内容
*/
private String centent;
/**
* 邮件附件的文件名
*/
private String[] attachFileNames;
}
@@ -25,14 +25,14 @@ public class BaseEntity implements Serializable {
@Column(length = 50)
@ApiModelProperty(value = "主键")
private String id;
@ApiModelProperty(value = "创建者",hidden = true)
@ApiModelProperty(value = "创建者", hidden = true)
private String creator;
@ApiModelProperty(value = "修改者",hidden = true)
@ApiModelProperty(value = "修改者", hidden = true)
private String modifier;
@ApiModelProperty(value = "创建时间",hidden = true)
@ApiModelProperty(value = "创建时间", hidden = true)
@Column(name = "create_time")
private Date createTime;
@ApiModelProperty(value = "修改时间",hidden = true)
@ApiModelProperty(value = "修改时间", hidden = true)
@Column(name = "modified_time")
private Date modifiedTime;
}
@@ -1,5 +1,7 @@
package com.xwbing.domain.entity.sys;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -15,28 +17,19 @@ import javax.persistence.Entity;
@EqualsAndHashCode(callSuper = true)
@Data
@Entity(name = "data_dict")
@ApiModel
public class DataDictionary extends BaseEntity {
private static final long serialVersionUID = -3409347240188002427L;
public static String table = "data_dict";
/**
* 英文名称 编码 唯一
*/
@ApiModelProperty(value = "编码", required = true)
private String code;
/**
* 名称
*/
@ApiModelProperty(value = "名称", required = true)
private String name;
/**
* 描述
*/
@ApiModelProperty(value = "描述", required = true)
private String description;
/**
* 父键
*/
@ApiModelProperty(value = "父键", required = true)
@Column(name = "parent_id")
private String parentId;
/**
* 是否启用
*/
@ApiModelProperty(value = "是否启用(Y|N)", example = "Y", required = true)
private String enable;
}
@@ -1,5 +1,7 @@
package com.xwbing.domain.entity.sys;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -15,36 +17,23 @@ import javax.persistence.Entity;
@EqualsAndHashCode(callSuper = true)
@Data
@Entity(name = "sys_authority")
@ApiModel
public class SysAuthority extends BaseEntity {
private static final long serialVersionUID = -6469518352117371987L;
public static String table = "sys_authority";
/**
* 名称
*/
@ApiModelProperty(value = "名称", required = true)
private String name;
/**
* 编号
*/
@ApiModelProperty(value = "编码", required = true)
private String code;
/**
* 是否启用
*/
@ApiModelProperty(value = "是否启用(Y|N)", example = "Y", required = true)
private String enable;
/**
* url地址
*/
@ApiModelProperty(value = "url地址", required = true)
private String url;
/**
* 父ID
*/
@Column(name = "parent_id")
@ApiModelProperty(value = "父ID", required = true)
private String parentId;
/**
* 类型 1菜单 2按钮
*/
@ApiModelProperty(value = "类型(1菜单|2按钮)", example = "2", required = true)
private Integer type;
/**
* 排序
*/
@ApiModelProperty(value = "排序", required = true)
private Integer sort;
}
@@ -19,23 +19,23 @@ import javax.validation.constraints.Pattern;
@EqualsAndHashCode(callSuper = true)
@Data
@Entity(name = "system_config")
@ApiModel//swagger
@ApiModel
public class SysConfig extends BaseEntity {
private static final long serialVersionUID = -7587016038432881980L;
public static String table = "system_config";
@ApiModelProperty(value = "配置项的code",example = "email_config",required = true)
@NotBlank(message = "配置项的code不能为空")
@Length(min = 1, max = 50, message = "code长度为1-50")
@ApiModelProperty(value = "配置项的code", example = "email_config", required = true)
private String code;
@ApiModelProperty(value = "配置项的值",example = "{}",required = true)
@NotBlank(message = "配置项的value不能为空")
@ApiModelProperty(value = "配置项的值", example = "{}", required = true)
private String value;
@ApiModelProperty(value = "配置项的描述(名称)",example = "邮箱配置",required = true)
@NotBlank(message = "配置项的name不能为空")
@ApiModelProperty(value = "配置项的描述(名称)", example = "邮箱配置", required = true)
@Length(min = 1, max = 20, message = "value长度为1-20")
private String name;
@ApiModelProperty(value = "是否启用",example = "Y",required = true)
@NotBlank(message = "是否启用不能为空")
@Pattern(regexp = "[Y|N]", message = "是否启用格式为Y|N")
@ApiModelProperty(value = "是否启用(Y|N)", example = "Y", required = true)
private String enable;
}
@@ -1,5 +1,7 @@
package com.xwbing.domain.entity.sys;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -14,23 +16,16 @@ import javax.persistence.Entity;
@EqualsAndHashCode(callSuper = true)
@Data
@Entity(name = "sys_role")
@ApiModel
public class SysRole extends BaseEntity {
private static final long serialVersionUID = -3048021197170624143L;
public static String table = "sys_role";
/**
* 角色名称
*/
@ApiModelProperty(value = "角色名称", required = true)
private String name;
/**
* 角色编码
*/
@ApiModelProperty(value = "角色编码", required = true)
private String code;
/**
* 是否启用
*/
@ApiModelProperty(value = "是否启用(Y|N)", example = "Y", required = true)
private String enable;
/**
* 描述
*/
@ApiModelProperty(value = "描述", required = true)
private String remark;
}
@@ -26,28 +26,28 @@ import java.util.List;
public class SysUser extends BaseEntity {
private static final long serialVersionUID = -2447528751353457021L;
public static String table = "sys_user_info";
@ApiModelProperty(value = "用户名",example = "xxx",required = true)
@ApiModelProperty(value = "用户名", required = true)
@NotBlank(message = "用户名不能为空")
@Length(min = 1, max = 20, message = "用户名长度为1-20")
@Column(name = "user_name")
private String userName;
@ApiModelProperty(value = "姓名",example = "xxx",required = true)
@ApiModelProperty(value = "姓名", required = true)
@NotBlank(message = "姓名不能为空")
@Length(min = 1, max = 20, message = "姓名长度为1-5")
private String name;
@ApiModelProperty(value = "邮箱",example = "@163.com",required = true)
@ApiModelProperty(value = "邮箱", example = "@163.com", required = true)
@NotBlank(message = "邮箱不能为空")
@Email(message = "邮箱格式有误")
private String mail;
@ApiModelProperty(value = "性别",example = "1",required = true)
@ApiModelProperty(value = "性别(0|1)", example = "1", required = true)
@NotBlank(message = "性别不能为空")
@Pattern(regexp = "[01]", message = "性别格式为0|1,0代表女,1代表男")
private String sex;
@ApiModelProperty(value = "盐值",hidden = true)
@ApiModelProperty(value = "盐值", hidden = true)
private String salt;
@ApiModelProperty(value = "密码",hidden = true)
@ApiModelProperty(value = "密码", hidden = true)
private String password;
@ApiModelProperty(value = "是否为管理员",hidden = true)
@ApiModelProperty(value = "是否为管理员", hidden = true)
private String admin;
//临时字段
@ApiModelProperty(hidden = true)
@@ -60,5 +60,4 @@ public class SysUser extends BaseEntity {
private transient List<SysAuthority> menus;
@ApiModelProperty(hidden = true)
private transient List<SysAuthority> buttons;
}
@@ -17,15 +17,15 @@ import javax.persistence.Entity;
@Entity(name = "sys_user_role")
public class SysUserRole extends BaseEntity {
private static final long serialVersionUID = 7340808603856635810L;
public static String table="sys_user_role";
public static String table = "sys_user_role";
/**
* 用户主键
*/
@Column(name = "user_id")
private String userId;
private String userId;
/**
* 角色主键
*/
@Column(name = "role_id")
private String roleId;
private String roleId;
}
@@ -15,7 +15,7 @@ import java.util.List;
*/
@Data
@ApiModel
public class ListDataDictionaryVo extends RestMessageVo{
public class ListDataDictionaryVo extends RestMessageVo {
@ApiModelProperty(value = "返回数据")
private List<DataDictionary> data;
}
@@ -26,5 +26,6 @@ public class SysAuthVo extends SysAuthority {
e.printStackTrace();
}
}
private List<SysAuthVo> children;
}
@@ -14,7 +14,7 @@ import java.util.List;
public interface DataDictionaryRepository extends JpaRepository<DataDictionary, String> {
DataDictionary getByCode(String code);
DataDictionary getByCodeAndEnable(String code,String enable);
DataDictionary getByCodeAndEnable(String code, String enable);
List<DataDictionary> getByParentIdAndEnable(String parentId, String enable);
@@ -2,6 +2,7 @@ package com.xwbing.domain.repository.sys;
import com.xwbing.domain.entity.sys.SysUser;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* 说明:
* 项目名称: boot-module-demo
@@ -7,18 +7,18 @@ package com.xwbing.exception;
* 作者: xiangwb
*/
public class BusinessException extends RuntimeException {
private static final long serialVersionUID = 7493711492820795133L;
private static final long serialVersionUID = 7493711492820795133L;
public BusinessException(Throwable cause) {
super(cause);
}
public BusinessException(Throwable cause) {
super(cause);
}
public BusinessException(String message) {
super(message);
}
public BusinessException(String message) {
super(message);
}
public BusinessException(String message, Throwable cause) {
super(message, cause);
}
public BusinessException(String message, Throwable cause) {
super(message, cause);
}
}
@@ -13,6 +13,7 @@ import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* 说明: 封装redis 缓存服务器服务接口
* 项目名称: boot-module-demo
@@ -26,7 +27,8 @@ public class RedisService {
private JedisPool jedisPool;
@Value("${redisCode}")
private String redisCode;
private final Logger logger= LoggerFactory.getLogger(RedisService.class);
private final Logger logger = LoggerFactory.getLogger(RedisService.class);
private RedisService() {
}
@@ -39,7 +41,7 @@ public class RedisService {
private Jedis getJedis() {
try {
return jedisPool.getResource();
}catch (Exception ex){
} catch (Exception ex) {
logger.error("redis连接失败==================================");
throw new BusinessException("redis连接失败");
}
@@ -384,9 +386,9 @@ public class RedisService {
String ping = jedis.ping();
logger.info("redis连接成功");
return ping;
} catch (BusinessException ex){//获取jedis客户端失败
} catch (BusinessException ex) {//获取jedis客户端失败
return "";
} catch (Exception ex){//ping失败
} catch (Exception ex) {//ping失败
logger.error("redis连接失败=================================");
return "";
} finally {
@@ -33,15 +33,15 @@ public class RedisStartupInit implements InitializingBean {
public void afterPropertiesSet() {
logger.info("redis启动===执行方法===刷新缓存==========================");
String ping = redisService.ping();
if(StringUtils.isNotEmpty(ping)){
if (StringUtils.isNotEmpty(ping)) {
redisService.set("test", "成功");
logger.info("redis获取测试数据:{}",redisService.get("test"));
logger.info("redis获取测试数据:{}", redisService.get("test"));
redisService.del("xwb");
boolean exists = redisService.exists("xwb");
logger.info("redis删除测试数据:{}",!exists);
logger.info("redis删除测试数据:{}", !exists);
Set<String> set = redisService.keys(redisCode + "*");
set.forEach(keyStr -> {
logger.info("删除缓存名称:{}",keyStr);
logger.info("删除缓存名称:{}", keyStr);
redisService.delInit(keyStr);
});
logger.info("redis初始化成功=================================");
@@ -61,7 +61,7 @@ public class SysUserLoginInOutService {
List<SysUserLoginInOut> list = loginInOutRepository.getByInoutType(inout);
if (CollectionUtils.isNotEmpty(list)) {
if (MapUtils.isNotEmpty(userMap)) {
list=list.stream().sorted((o1, o2) -> o2.getCreateTime().compareTo(o1.getCreateTime())).peek(inOut -> {
list = list.stream().sorted((o1, o2) -> o2.getCreateTime().compareTo(o1.getCreateTime())).peek(inOut -> {
inOut.setUserIdName(userMap.get(inOut.getUserId()).getName());//用户姓名
inOut.setRecordTime(DateUtil2.dateToStr(inOut.getCreateTime(), DateUtil2.YYYY_MM_DD_HH_MM_SS));//记录时间
CommonEnum.LoginInOutEnum inOutEnum = Arrays.stream(CommonEnum.LoginInOutEnum.values()).filter(obj -> obj.getValue() == inout).findFirst().get();//登录登出
@@ -60,22 +60,4 @@ public class ApplicationContextConfig {
poolTaskExecutor.setQueueCapacity(200);//队列最大长度
return poolTaskExecutor;
}
// @Bean(name = "cloudQueryRunner")
// @Primary
// public CloudQueryRunner getCloudQueryRunner() {
// return getQueryRunner("y.drore.com", control_appId, control_appSecret);
//
// }
//
// private static CloudQueryRunner getQueryRunner(String cloud_host, String config_appId, String control_appSecret) {
// CloudBasicConnection cloudBasicConnection = new CloudBasicConnection(cloud_host, 80, config_appId, control_appSecret);
// CloudPoolingConnectionManager cloudPoolingConnectionManager = new CloudPoolingConnectionManager();
// cloudPoolingConnectionManager.setConnection(cloudBasicConnection);
// CloudBasicDataSource cloudBasicDataSource = new CloudBasicDataSource();
// cloudBasicDataSource.setCloudPoolingConnectionManager(cloudPoolingConnectionManager);
// CloudQueryRunner cloudQueryRunner = new CloudQueryRunner();
// cloudQueryRunner.setDataSource(cloudBasicDataSource);
// return cloudQueryRunner;
// }
}
@@ -83,7 +83,7 @@ public class DataDictionaryControl {
@ApiOperation(value = "根据父id列表查询", response = ListDataDictionaryVo.class)
@ApiImplicitParams({
@ApiImplicitParam(name = "parentId", value = "父id", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "enable", value = "是否启用,格式为Y|N", paramType = "query", dataType = "string")
@ApiImplicitParam(name = "enable", value = "是否启用(Y|N)", paramType = "query", dataType = "string")
})
@PostMapping("findListByParent")
public JSONObject findListByParent(String enable, String parentId) {
@@ -96,7 +96,7 @@ public class DataDictionaryControl {
@LogInfo("根据编码查询字典列表")
@ApiOperation(value = "根据编码查询字典列表", response = ListDataDictionaryVo.class)
@ApiImplicitParam(name = "enable", value = "是否启用,格式为Y|N", paramType = "query", dataType = "string")
@ApiImplicitParam(name = "enable", value = "是否启用(Y|N)", paramType = "query", dataType = "string")
@PostMapping("findListByCode")
public JSONObject findListByCode(@RequestParam String code, String enable) {
if (StringUtils.isEmpty(code)) {
@@ -97,7 +97,7 @@ public class SysAuthorityControl {
@LogInfo("根据是否启用查询所有权限")
@ApiOperation(value = "根据是否启用查询所有权限", response = ListSysAuthorityVo.class)
@ApiImplicitParam(name = "enable", value = "是否启用,格式Y|N", paramType = "query", dataType = "string")
@ApiImplicitParam(name = "enable", value = "是否启用(Y|N)", paramType = "query", dataType = "string")
@GetMapping("listByEnable")
public JSONObject listByEnable(String enable) {
List<SysAuthority> authoritys = sysAuthorityService.listByEnable(enable);
@@ -121,7 +121,7 @@ public class SysAuthorityControl {
@LogInfo("递归查询所有权限")
@ApiOperation(value = "递归查询所有权限", response = ListSysAuthorityVo.class)
@ApiImplicitParam(name = "enable", value = "是否启用,格式Y|N", paramType = "query", dataType = "string")
@ApiImplicitParam(name = "enable", value = "是否启用(Y|N)", paramType = "query", dataType = "string")
@GetMapping("listTree")
public JSONObject listTree(String enable) {
List<SysAuthVo> authoritys;
@@ -11,7 +11,6 @@ import com.xwbing.util.JsonResult;
import com.xwbing.util.RestMessage;
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.slf4j.Logger;
@@ -38,12 +37,6 @@ public class SysConfigControl {
@LogInfo("新增系统配置信息")
@ApiOperation(value = "新增", notes = "新增系统配置信息", response = RestMessageVo.class)
// @ApiImplicitParams({
// @ApiImplicitParam(name = "code", value = "配置项的key,长度为1-50", paramType = "query", required = true, dataType = "string"),
// @ApiImplicitParam(name = "value", value = "配置项的值", paramType = "query", required = true, dataType = "string"),
// @ApiImplicitParam(name = "enable", value = "是否启用,格式为Y|N", paramType = "query", required = true, dataType = "string"),
// @ApiImplicitParam(name = "name", value = "配置名称,长度为1-10", paramType = "query", required = true, dataType = "string")
// })
@PostMapping("save")
public JSONObject save(@RequestBody @Valid SysConfig sysConfig) {
String logMsg = "新增系统配置信息";
@@ -68,13 +61,8 @@ public class SysConfigControl {
@LogInfo("修改系统配置信息")
@ApiOperation(value = "修改", notes = "修改系统配置信息", response = RestMessageVo.class)
@ApiImplicitParams({
@ApiImplicitParam(name = "code", value = "配置项的key,长度为1-50", paramType = "query", required = true, dataType = "string"),
@ApiImplicitParam(name = "value", value = "配置项的值", paramType = "query", required = true, dataType = "string"),
@ApiImplicitParam(name = "enable", value = "是否启用,格式为Y|N", paramType = "query", required = true, dataType = "string"),
})
@PostMapping("update")
public JSONObject update(SysConfig sysConfig) {
public JSONObject update(@RequestBody @Valid SysConfig sysConfig) {
String logMsg = "修改系统配置信息";
logger.info(logMsg);
if (StringUtils.isEmpty(sysConfig.getCode())) {
@@ -106,13 +106,13 @@ public class SysUserControl {
@LogInfo("登录")
@ApiOperation(value = "登录", response = RestMessageVo.class)
@GetMapping("login")
public JSONObject login(HttpServletRequest request,@RequestParam boolean rememberMe, @RequestParam String userName, @RequestParam String passWord, @RequestParam String checkCode) {
public JSONObject login(HttpServletRequest request,@RequestParam boolean rememberMe, @RequestParam String userName, @RequestParam String passWord, @RequestParam String captcha) {
if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(passWord)) {
return JsonResult.toJSONObj("用户名或密码不能为空");
}
Subject subject = SecurityUtils.getSubject();
String ip = IpUtil.getIpAddr(request);
UsernamePasswordCaptchaToken token = new UsernamePasswordCaptchaToken(userName, passWord.toCharArray(), rememberMe, ip, checkCode);
UsernamePasswordCaptchaToken token = new UsernamePasswordCaptchaToken(userName, passWord.toCharArray(), rememberMe, ip, captcha);
subject.login(token);
if (subject.isAuthenticated()) {
//保存登录信息