✨ 添加新特性。 字典、字典项目维护

This commit is contained in:
冷冷 committed 2019-03-19 11:58:53 +08:00
1 parent ddc0bc5749
commit e3fba61dfb
15 files changed
+448 -136

No files matched your search

@@ -119,11 +119,11 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
final Map<String, Object> additionalInfo = new HashMap<>(8);
PigxUser pigxUser = (PigxUser) authentication.getUserAuthentication().getPrincipal();
additionalInfo.put("user_id", pigxUser.getId());
additionalInfo.put("username", pigxUser.getUsername());
additionalInfo.put("dept_id", pigxUser.getDeptId());
additionalInfo.put("tenant_id", pigxUser.getTenantId());
additionalInfo.put("license", SecurityConstants.PIGX_LICENSE);
additionalInfo.put(SecurityConstants.DETAILS_USER_ID, pigxUser.getId());
additionalInfo.put(SecurityConstants.DETAILS_USERNAME, pigxUser.getUsername());
additionalInfo.put(SecurityConstants.DETAILS_DEPT_ID, pigxUser.getDeptId());
additionalInfo.put(SecurityConstants.DETAILS_TENANT_ID, pigxUser.getTenantId());
additionalInfo.put(SecurityConstants.DETAILS_LICENSE, SecurityConstants.PIGX_LICENSE);
((DefaultOAuth2AccessToken) accessToken).setAdditionalInformation(additionalInfo);
return accessToken;
};
@@ -130,4 +130,29 @@ public interface SecurityConstants {
*/
String CLIENT_CREDENTIALS = "client_credentials";
/**
* 用户ID字段
*/
String DETAILS_USER_ID = "user_id";
/**
* 用户名字段
*/
String DETAILS_USERNAME = "username";
/**
* 用户部门字段
*/
String DETAILS_DEPT_ID = "dept_id";
/**
* 租户ID 字段
*/
String DETAILS_TENANT_ID = "tenant_id";
/**
* 协议字段
*/
String DETAILS_LICENSE = "license";
}
@@ -17,6 +17,7 @@
package com.pig4cloud.pigx.common.security.component;
import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
import com.pig4cloud.pigx.common.security.service.PigxUser;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
@@ -36,9 +37,6 @@ import java.util.Map;
* 根据checktoken 的结果转化用户信息
*/
public class PigxUserAuthenticationConverter implements UserAuthenticationConverter {
private static final String USER_ID = "user_id";
private static final String DEPT_ID = "dept_id";
private static final String TENANT_ID = "tenant_id";
private static final String N_A = "N/A";
/**
@@ -69,9 +67,9 @@ public class PigxUserAuthenticationConverter implements UserAuthenticationConver
Collection<? extends GrantedAuthority> authorities = getAuthorities(map);
String username = (String) map.get(USERNAME);
Integer id = (Integer) map.get(USER_ID);
Integer deptId = (Integer) map.get(DEPT_ID);
Integer tenantId = (Integer) map.get(TENANT_ID);
Integer id = (Integer) map.get(SecurityConstants.DETAILS_USER_ID);
Integer deptId = (Integer) map.get(SecurityConstants.DETAILS_DEPT_ID);
Integer tenantId = (Integer) map.get(SecurityConstants.DETAILS_TENANT_ID);
PigxUser user = new PigxUser(id, deptId, tenantId, username, N_A, true
, true, true, true, authorities);
return new UsernamePasswordAuthenticationToken(user, N_A, authorities);
@@ -1,92 +1,75 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.admin.api.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;
/**
* <p>
* 字典表
* </p>
*
* @author lengleng
* @since 2017-11-19
* @author pigx code generator
* @date 2019-03-19 09:52:47
*/
@Data
@TableName("sys_dict")
@EqualsAndHashCode(callSuper = true)
public class SysDict extends Model<SysDict> {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
/**
* 编号
*/
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/**
* 数据值
*/
@NotBlank(message = "字典项数据值不能为空")
private String value;
/**
* 标签名
*/
@NotBlank(message = "字典项标签不能为空")
private String label;
/**
* 类型
*/
@NotBlank(message = "字典项数据类型不能为空")
private String type;
/**
* 描述
*/
private String description;
/**
* 排序(升序)
*/
private Integer sort;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新时间
*/
private LocalDateTime updateTime;
/**
* 备注信息
*/
private String remarks;
/**
* 删除标记
*/
/**
* 编号
*/
@TableId
private Integer id;
/**
* 类型
*/
private String type;
/**
* 描述
*/
private String description;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新时间
*/
private LocalDateTime updateTime;
/**
* 备注信息
*/
private String remarks;
/**
* 删除标记
*/
@TableLogic
private String delFlag;
private String delFlag;
/**
* 所属租户
*/
private Integer tenantId;
}
@@ -0,0 +1,91 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.admin.api.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDateTime;
/**
* 字典项
*
* @author pigx code generator
* @date 2019-03-19 09:46:46
*/
@Data
@TableName("sys_dict_item")
@EqualsAndHashCode(callSuper = true)
public class SysDictItem extends Model<SysDictItem> {
private static final long serialVersionUID = 1L;
/**
* 编号
*/
@TableId
private Integer id;
/**
*
*/
private Integer dictId;
/**
* 数据值
*/
private String value;
/**
* 标签名
*/
private String label;
/**
* 类型
*/
private String type;
/**
* 描述
*/
private String description;
/**
* 排序(升序)
*/
private Integer sort;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新时间
*/
private LocalDateTime updateTime;
/**
* 备注信息
*/
private String remarks;
/**
* 删除标记
*/
@TableLogic
private String delFlag;
/**
* 所属租户
*/
private Integer tenantId;
}
@@ -24,6 +24,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.pigx.admin.api.entity.SysDict;
import com.pig4cloud.pigx.admin.api.entity.SysDictItem;
import com.pig4cloud.pigx.admin.service.SysDictItemService;
import com.pig4cloud.pigx.admin.service.SysDictService;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.log.annotation.SysLog;
@@ -42,7 +44,7 @@ import javax.validation.Valid;
* </p>
*
* @author lengleng
* @since 2017-11-19
* @since 2019-03-19
*/
@RestController
@AllArgsConstructor
@@ -50,6 +52,7 @@ import javax.validation.Valid;
@Api(value = "dict", description = "字典管理模块")
public class DictController {
private final SysDictService sysDictService;
private final SysDictItemService sysDictItemService;
/**
* 通过ID查询字典信息
@@ -82,9 +85,9 @@ public class DictController {
@GetMapping("/type/{type}")
@Cacheable(value = "dict_details", key = "#type")
public R getDictByType(@PathVariable String type) {
return new R<>(sysDictService.list(Wrappers
.<SysDict>query().lambda()
.eq(SysDict::getType, type)));
return new R<>(sysDictItemService.list(Wrappers
.<SysDictItem>query().lambda()
.eq(SysDictItem::getType, type)));
}
/**
@@ -95,7 +98,6 @@ public class DictController {
*/
@SysLog("添加字典")
@PostMapping
@CacheEvict(value = "dict_details", key = "#sysDict.type")
@PreAuthorize("@pms.hasPermission('sys_dict_add')")
public R save(@Valid @RequestBody SysDict sysDict) {
return new R<>(sysDictService.save(sysDict));
@@ -104,16 +106,14 @@ public class DictController {
/**
* 删除字典,并且清除字典缓存
*
* @param id ID
* @param type 类型
* @param id ID
* @return R
*/
@SysLog("删除字典")
@DeleteMapping("/{id}/{type}")
@CacheEvict(value = "dict_details", key = "#type")
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('sys_dict_del')")
public R removeById(@PathVariable Integer id, @PathVariable String type) {
return new R<>(sysDictService.removeById(id));
public R removeById(@PathVariable Integer id) {
return new R<>(sysDictService.removeDict(id));
}
/**
@@ -124,9 +124,71 @@ public class DictController {
*/
@PutMapping
@SysLog("修改字典")
@CacheEvict(value = "dict_details", key = "#sysDict.type")
@PreAuthorize("@pms.hasPermission('sys_dict_edit')")
public R updateById(@Valid @RequestBody SysDict sysDict) {
return new R<>(sysDictService.updateById(sysDict));
}
/**
* 分页查询
*
* @param page 分页对象
* @param sysDictItem 字典项
* @return
*/
@GetMapping("/item/page")
public R getSysDictItemPage(Page page, SysDictItem sysDictItem) {
return new R<>(sysDictItemService.page(page, Wrappers.query(sysDictItem)));
}
/**
* 通过id查询字典项
*
* @param id id
* @return R
*/
@GetMapping("/item/{id}")
public R getDictItemById(@PathVariable("id") Integer id) {
return new R<>(sysDictItemService.getById(id));
}
/**
* 新增字典项
*
* @param sysDictItem 字典项
* @return R
*/
@SysLog("新增字典项")
@PostMapping("/item")
@CacheEvict(value = "dict_details", allEntries = true)
public R save(@RequestBody SysDictItem sysDictItem) {
return new R<>(sysDictItemService.save(sysDictItem));
}
/**
* 修改字典项
*
* @param sysDictItem 字典项
* @return R
*/
@SysLog("修改字典项")
@PutMapping("/item")
@CacheEvict(value = "dict_details", allEntries = true)
public R updateById(@RequestBody SysDictItem sysDictItem) {
return new R<>(sysDictItemService.updateById(sysDictItem));
}
/**
* 通过id删除字典项
*
* @param id id
* @return R
*/
@SysLog("删除字典项")
@DeleteMapping("/item/{id}")
@CacheEvict(value = "dict_details", allEntries = true)
public R removeDictItemById(@PathVariable Integer id) {
return new R<>(sysDictItemService.removeById(id));
}
}
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.admin.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pig4cloud.pigx.admin.api.entity.SysDictItem;
/**
* 字典项
*
* @author pigx code generator
* @date 2019-03-19 09:46:46
*/
public interface SysDictItemMapper extends BaseMapper<SysDictItem> {
}
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.admin.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.pig4cloud.pigx.admin.api.entity.SysDictItem;
/**
* 字典项
*
* @author pigx code generator
* @date 2019-03-19 09:46:46
*/
public interface SysDictItemService extends IService<SysDictItem> {
}
@@ -1,34 +1,37 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.admin.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.pig4cloud.pigx.admin.api.entity.SysDict;
/**
* <p>
* 字典表 服务类
* </p>
* 字典表
*
* @author lengleng
* @since 2017-11-19
* @author pigx code generator
* @date 2019-03-19 09:52:47
*/
public interface SysDictService extends IService<SysDict> {
/**
* 根据ID 删除字典
*
* @param id
* @return
*/
Boolean removeDict(Integer id);
}
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.admin.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.pigx.admin.api.entity.SysDictItem;
import com.pig4cloud.pigx.admin.mapper.SysDictItemMapper;
import com.pig4cloud.pigx.admin.service.SysDictItemService;
import org.springframework.stereotype.Service;
/**
* 字典项
*
* @author pigx code generator
* @date 2019-03-19 09:46:46
*/
@Service
public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDictItem> implements SysDictItemService {
}
@@ -1,39 +1,58 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.admin.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.pigx.admin.api.entity.SysDict;
import com.pig4cloud.pigx.admin.api.entity.SysDictItem;
import com.pig4cloud.pigx.admin.mapper.SysDictItemMapper;
import com.pig4cloud.pigx.admin.mapper.SysDictMapper;
import com.pig4cloud.pigx.admin.service.SysDictService;
import lombok.AllArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* <p>
* 字典表 服务实现类
* </p>
* 字典表
*
* @author lengleng
* @since 2017-11-19
* @author pigx code generator
* @date 2019-03-19 09:52:47
*/
@Service
@AllArgsConstructor
public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> implements SysDictService {
private final SysDictItemMapper dictItemMapper;
/**
* 根据ID 删除字典
*
* @param id
* @return
*/
@Override
@CacheEvict(value = "dict_details", allEntries = true)
@Transactional(rollbackFor = Exception.class)
public Boolean removeDict(Integer id) {
baseMapper.deleteById(id);
dictItemMapper.delete(Wrappers.<SysDictItem>lambdaQuery()
.eq(SysDictItem::getDictId, id));
return Boolean.TRUE;
}
}
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2018-2025, lengleng All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~
~ Redistributions of source code must retain the above copyright notice,
~ this list of conditions and the following disclaimer.
~ Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ Neither the name of the pig4cloud.com developer nor the names of its
~ contributors may be used to endorse or promote products derived from
~ this software without specific prior written permission.
~ Author: lengleng (wangiegie@gmail.com)
~
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.pig4cloud.pigx.admin.mapper.SysDictItemMapper">
<resultMap id="sysDictItemMap" type="com.pig4cloud.pigx.admin.api.entity.SysDictItem">
<id property="id" column="id"/>
<result property="dictId" column="dict_id"/>
<result property="value" column="value"/>
<result property="label" column="label"/>
<result property="type" column="type"/>
<result property="description" column="description"/>
<result property="sort" column="sort"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
<result property="remarks" column="remarks"/>
<result property="delFlag" column="del_flag"/>
<result property="tenantId" column="tenant_id"/>
</resultMap>
</mapper>
@@ -25,14 +25,12 @@
<resultMap id="sysDictMap" type="com.pig4cloud.pigx.admin.api.entity.SysDict">
<id property="id" column="id"/>
<result property="value" column="value"/>
<result property="label" column="label"/>
<result property="type" column="type"/>
<result property="description" column="description"/>
<result property="sort" column="sort"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
<result property="remarks" column="remarks"/>
<result property="delFlag" column="del_flag"/>
<result property="tenantId" column="tenant_id"/>
</resultMap>
</mapper>
@@ -20,7 +20,7 @@ package com.pig4cloud.pigx.daemon.event;
import com.pig4cloud.pigx.daemon.config.PigxQuartzInvokeFactory;
import com.pig4cloud.pigx.daemon.service.SysJobLogService;
import com.pig4cloud.pigx.daemon.util.TaskInvokUtil;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.annotation.Bean;
@@ -35,12 +35,11 @@ import org.springframework.scheduling.annotation.EnableAsync;
*/
@EnableAsync
@Configuration
@AllArgsConstructor
@ConditionalOnWebApplication
public class EventAutoConfiguration {
@Autowired
private TaskInvokUtil taskInvokUtil;
@Autowired
private SysJobLogService sysJobLogService;
@Bean
+1 -1
View File
@@ -59,7 +59,7 @@
<ttl.version>2.10.2</ttl.version>
<minio.version>6.0.2</minio.version>
<elastic-job-lite.version>2.1.5</elastic-job-lite.version>
<security.oauth.version>2.3.4.RELEASE</security.oauth.version>
<security.oauth.version>2.3.5.RELEASE</security.oauth.version>
<security.oauth.auto.version>2.1.2.RELEASE</security.oauth.auto.version>
<activiti.version>5.22.0</activiti.version>
<zipkin.version>2.12.2</zipkin.version>