forked from gitee/vben-java
数据库字段命名优化
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
# 代码生成
|
||||
gen:
|
||||
# 作者
|
||||
author: zsvg
|
||||
# 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool
|
||||
packageName: com.zsvg.system
|
||||
# 自动去除表前缀,默认是false
|
||||
autoRemovePre: false
|
||||
# 表前缀(生成类名不会包含表前缀,多个用逗号分隔)
|
||||
tablePrefix: sys_
|
||||
+3
-3
@@ -30,7 +30,7 @@ public class DemoSingleCateController {
|
||||
* @return XX树状数据
|
||||
*/
|
||||
@GetMapping("tree")
|
||||
@SaCheckPermission("single:main:query")
|
||||
@SaCheckPermission("single:cate:query")
|
||||
public R<List<Ltree>> getTree(String name, Long id) {
|
||||
Sqler sqler = new Sqler(table);
|
||||
List<Ltree> list = service.findTreeList(sqler, name, id);
|
||||
@@ -43,7 +43,7 @@ public class DemoSingleCateController {
|
||||
* @return XX列表数据
|
||||
*/
|
||||
@GetMapping("list")
|
||||
@SaCheckPermission("single:main:query")
|
||||
@SaCheckPermission("single:cate:query")
|
||||
public R<List<DemoSingleCate>> getList(String name) {
|
||||
Sqler sqler = new Sqler(table);
|
||||
sqler.addLike("t.name", name);
|
||||
@@ -57,7 +57,7 @@ public class DemoSingleCateController {
|
||||
* @param id ID
|
||||
* @return XX对象
|
||||
*/
|
||||
@SaCheckPermission("single:main:query")
|
||||
@SaCheckPermission("single:cate:query")
|
||||
@GetMapping("info/{id}")
|
||||
public R<DemoSingleCate> info(@PathVariable Long id) {
|
||||
DemoSingleCate cate = service.select(id);
|
||||
|
||||
@@ -55,7 +55,7 @@ public class ExportDemoVo implements Serializable {
|
||||
* 使用ExcelDictFormat注解需要进行下拉选的部分
|
||||
*/
|
||||
@ExcelProperty(value = "性别", index = 2, converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(dictType = "sys_user_sex")
|
||||
@ExcelDictFormat(dictType = "sys_user_gender")
|
||||
@NotEmpty(message = "性别不能为空", groups = AddGroup.class)
|
||||
private String gender;
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# 代码生成
|
||||
gen:
|
||||
# 作者
|
||||
author: zsvg
|
||||
# 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool
|
||||
packageName: com.zsvg.system
|
||||
# 自动去除表前缀,默认是false
|
||||
autoRemovePre: false
|
||||
# 表前缀(生成类名不会包含表前缀,多个用逗号分隔)
|
||||
tablePrefix: sys_
|
||||
@@ -30,10 +30,10 @@
|
||||
<artifactId>ojdbc8</artifactId>
|
||||
</dependency>
|
||||
<!-- <!– 兼容oracle低版本 –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.oracle.database.nls</groupId>-->
|
||||
<!-- <artifactId>orai18n</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.oracle.database.nls</groupId>
|
||||
<artifactId>orai18n</artifactId>
|
||||
</dependency>
|
||||
<!-- <!– PostgreSql –>-->
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
|
||||
@@ -34,7 +34,7 @@ public class MonLoginLogEntity {
|
||||
*/
|
||||
@Column(length = 16)
|
||||
@Schema(description = "用户账号")
|
||||
private String usnam;
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 客户端
|
||||
|
||||
@@ -79,7 +79,7 @@ public class SysApiInitService {
|
||||
a102005.setOrnum(102005);
|
||||
a102005.setName("用户密码修改");
|
||||
a102005.setMenid(1020L);
|
||||
a102005.setPerm("sys:user:pacod");
|
||||
a102005.setPerm("sys:user:password");
|
||||
list.add(a102005);
|
||||
|
||||
SysApiEntity a103001 = new SysApiEntity();
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package vben.setup.sys.corp;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* 公司分类
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "sys_corp_cate")
|
||||
@Schema(description = "公司分类")
|
||||
public class SysCorpCateEntity {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@Id
|
||||
@Column(length = 32)
|
||||
@Schema(description = "主键ID")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@Schema(description = "名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 父ID
|
||||
*/
|
||||
@Column(length = 32)
|
||||
@Schema(description = "父ID")
|
||||
private String pid;
|
||||
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
@Schema(description = "排序号")
|
||||
private Integer ornum;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package vben.setup.sys.corp;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 公司
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "sys_corp")
|
||||
@Schema(description = "公司")
|
||||
public class SysCorpEntity {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@Id
|
||||
@Column(length = 36)
|
||||
@Schema(description = "主键ID")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@Column(length = 64)
|
||||
@Schema(description = "名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 分类ID
|
||||
*/
|
||||
@Column(length = 36)
|
||||
@Schema(description = "分类ID")
|
||||
private String catid;
|
||||
|
||||
/**
|
||||
* 公司类型
|
||||
*/
|
||||
@Schema(description = "公司类型")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
@Column(length = 32)
|
||||
@Schema(description = "标签")
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Schema(description = "备注")
|
||||
private String notes;
|
||||
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
@Schema(description = "排序号")
|
||||
private Integer ornum;
|
||||
|
||||
/**
|
||||
* 可用标记
|
||||
*/
|
||||
@Schema(description = "可用标记")
|
||||
private Boolean avtag;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间")
|
||||
private Date crtim = new Date();
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(description = "更新时间")
|
||||
private Date uptim;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
@Column(length = 32)
|
||||
@Schema(description = "创建人ID")
|
||||
private String cruid;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
@Column(length = 32)
|
||||
@Schema(description = "更新人ID")
|
||||
private String upuid;
|
||||
|
||||
}
|
||||
@@ -107,32 +107,4 @@ public class SysDeptEntity {
|
||||
@Schema(description = "更新人ID")
|
||||
private String upuid;
|
||||
|
||||
/**
|
||||
* 自定义扩展字段1
|
||||
*/
|
||||
@Column(length = 32)
|
||||
@Schema(description = "扩展字段1")
|
||||
private String ex1;
|
||||
|
||||
/**
|
||||
* 自定义扩展字段2
|
||||
*/
|
||||
@Column(length = 32)
|
||||
@Schema(description = "扩展字段2")
|
||||
private String ex2;
|
||||
|
||||
/**
|
||||
* 自定义扩展字段3
|
||||
*/
|
||||
@Column(length = 32)
|
||||
@Schema(description = "扩展字段3")
|
||||
private String ex3;
|
||||
|
||||
/**
|
||||
* 自定义扩展字段4
|
||||
*/
|
||||
@Column(length = 32)
|
||||
@Schema(description = "扩展字段4")
|
||||
private String ex4;
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.Date;
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "sys_menu")
|
||||
@Schema(description = "权限菜单")
|
||||
@Schema(description = "系统菜单")
|
||||
public class SysMenuEntity {
|
||||
|
||||
/**
|
||||
@@ -48,7 +48,7 @@ public class SysMenuEntity {
|
||||
private Integer ornum;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
* 类型()
|
||||
*/
|
||||
@Column(length = 8)
|
||||
@Schema(description = "类型")
|
||||
|
||||
@@ -38,7 +38,7 @@ public class SysNoticeEntity {
|
||||
*/
|
||||
@Column(length = 2000)
|
||||
@Schema(description = "公告内容")
|
||||
private String content;
|
||||
private String cont;
|
||||
|
||||
/**
|
||||
* 公告类型(1通知 2公告)
|
||||
|
||||
@@ -21,7 +21,7 @@ public class SysNoticeInitService {
|
||||
SysNoticeEntity n1 = new SysNoticeEntity();
|
||||
n1.setId(1L);
|
||||
n1.setName("系统停机公告");
|
||||
n1.setContent("系统将于今天晚上20点到22点进行停机维护,请提前做好工作安排");
|
||||
n1.setCont("系统将于今天晚上20点到22点进行停机维护,请提前做好工作安排");
|
||||
n1.setOrnum(1);
|
||||
n1.setType(1);
|
||||
list.add(n1);
|
||||
|
||||
@@ -10,12 +10,12 @@ import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 组织架构用户
|
||||
* 系统用户
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "sys_user")
|
||||
@Schema(description = "组织架构-用户")
|
||||
@Schema(description = "系统用户")
|
||||
public class SysUserEntity {
|
||||
|
||||
/**
|
||||
@@ -27,18 +27,54 @@ public class SysUserEntity {
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
* 姓名(昵称)
|
||||
*/
|
||||
@Column(length = 16)
|
||||
@Schema(description = "姓名")
|
||||
@Schema(description = "姓名(昵称)")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 自定义昵称
|
||||
* 用户名(账号)
|
||||
*/
|
||||
@Column(length = 32)
|
||||
@Schema(description = "用户名(账号)")
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@Column(length = 64)
|
||||
@Schema(description = "密码")
|
||||
private String password;
|
||||
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
@Column(length = 32)
|
||||
@Schema(description = "邮箱")
|
||||
private String email;
|
||||
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@Column(length = 16)
|
||||
@Schema(description = "昵称")
|
||||
private String ninam;
|
||||
@Schema(description = "手机号")
|
||||
private String monum;
|
||||
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
@Schema(description = "排序号")
|
||||
private Integer ornum;
|
||||
|
||||
/**
|
||||
* 可用标记
|
||||
*/
|
||||
@Schema(description = "可用标记")
|
||||
private Boolean avtag;
|
||||
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
@@ -61,52 +97,13 @@ public class SysUserEntity {
|
||||
@Schema(description = "职务")
|
||||
private String job;
|
||||
|
||||
/**
|
||||
* 登录名
|
||||
*/
|
||||
@Column(length = 32)
|
||||
@Schema(description = "登录名")
|
||||
private String usnam;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@Column(length = 64)
|
||||
@Schema(description = "密码")
|
||||
private String pacod;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
@Column(length = 32)
|
||||
@Schema(description = "邮箱")
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
@Column(length = 8)
|
||||
@Schema(description = "性别")
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@Column(length = 16)
|
||||
@Schema(description = "手机号")
|
||||
private String monum;
|
||||
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
@Schema(description = "排序号")
|
||||
private Integer ornum;
|
||||
|
||||
/**
|
||||
* 可用标记
|
||||
*/
|
||||
@Schema(description = "可用标记")
|
||||
private Boolean avtag;
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 标签
|
||||
@@ -115,11 +112,6 @@ public class SysUserEntity {
|
||||
@Schema(description = "标签")
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Schema(description = "notes")
|
||||
private String notes;
|
||||
|
||||
/**
|
||||
* 缓存标记
|
||||
@@ -180,31 +172,36 @@ public class SysUserEntity {
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 自定义扩展字段1
|
||||
* 备注--个性签名
|
||||
*/
|
||||
@Column(length = 32)
|
||||
@Schema(description = "扩展字段1")
|
||||
private String ex1;
|
||||
@Schema(description = "notes")
|
||||
private String notes;
|
||||
|
||||
//---------------------im补充--
|
||||
/**
|
||||
* 直接可加还是需要同意后再加
|
||||
*/
|
||||
@Schema(description = "直接可加还是需要同意后再加")
|
||||
private Boolean jotyp;
|
||||
|
||||
/**
|
||||
* 自定义扩展字段2
|
||||
* 地区
|
||||
*/
|
||||
@Column(length = 32)
|
||||
@Schema(description = "扩展字段2")
|
||||
private String ex2;
|
||||
@Column(length = 64)
|
||||
@Schema(description = "地区名称")
|
||||
private String arnam;
|
||||
|
||||
/**
|
||||
* 自定义扩展字段3
|
||||
* 地区
|
||||
*/
|
||||
@Column(length = 32)
|
||||
@Schema(description = "扩展字段3")
|
||||
private String ex3;
|
||||
@Column(length = 64)
|
||||
@Schema(description = "地区编号")
|
||||
private String arcod;
|
||||
|
||||
/**
|
||||
* 自定义扩展字段4
|
||||
* 最后离开时间
|
||||
*/
|
||||
@Column(length = 32)
|
||||
@Schema(description = "扩展字段4")
|
||||
private String ex4;
|
||||
@Schema(description = "最后离开时间")
|
||||
private Date oftim;
|
||||
|
||||
}
|
||||
|
||||
@@ -24,30 +24,30 @@ public class SysUserInitService {
|
||||
SysUserEntity user = new SysUserEntity();
|
||||
user.setId("u1");
|
||||
user.setName("管理员");
|
||||
user.setUsnam("admin");
|
||||
user.setUsername("admin");
|
||||
user.setDepid("d1000");
|
||||
user.setTier("_d1000_u1_");
|
||||
user.setMonum("13812345678");
|
||||
user.setEmail("admin@qq.com");
|
||||
user.setSex("1");
|
||||
user.setGender("1");
|
||||
user.setNotes("管理员不给修改");
|
||||
list.add(user);
|
||||
|
||||
SysUserEntity user2 = new SysUserEntity();
|
||||
user2.setId("u2");
|
||||
user2.setName("小狐狸");
|
||||
user2.setUsnam("vben");
|
||||
user2.setUsername("vben");
|
||||
user2.setDepid("d1000");
|
||||
user2.setTier("_d1000_u2_");
|
||||
user2.setMonum("13912345678");
|
||||
user.setEmail("vben@qq.com");
|
||||
user2.setSex("2");
|
||||
user2.setGender("2");
|
||||
list.add(user2);
|
||||
|
||||
SysUserEntity user3 = new SysUserEntity();
|
||||
user3.setId("u3");
|
||||
user3.setName("张三");
|
||||
user3.setUsnam("zs");
|
||||
user3.setUsername("zs");
|
||||
user3.setDepid("d1000");
|
||||
user3.setTier("_d1000_u3_");
|
||||
list.add(user3);
|
||||
@@ -55,7 +55,7 @@ public class SysUserInitService {
|
||||
SysUserEntity user4 = new SysUserEntity();
|
||||
user4.setId("u4");
|
||||
user4.setName("李四");
|
||||
user4.setUsnam("ls");
|
||||
user4.setUsername("ls");
|
||||
user4.setDepid("d1100");
|
||||
user4.setTier("_d1000_d1100_u4_");
|
||||
list.add(user4);
|
||||
@@ -63,7 +63,7 @@ public class SysUserInitService {
|
||||
SysUserEntity user5 = new SysUserEntity();
|
||||
user5.setId("u5");
|
||||
user5.setName("王五");
|
||||
user5.setUsnam("ww");
|
||||
user5.setUsername("ww");
|
||||
user5.setDepid("d1110");
|
||||
user5.setTier("_d1000_d1100_d1110_u5_");
|
||||
list.add(user5);
|
||||
@@ -71,7 +71,7 @@ public class SysUserInitService {
|
||||
SysUserEntity user6 = new SysUserEntity();
|
||||
user6.setId("u6");
|
||||
user6.setName("赵六");
|
||||
user6.setUsnam("zl");
|
||||
user6.setUsername("zl");
|
||||
user6.setDepid("d1111");
|
||||
user6.setTier("_d1000_d1100_d1110_d1111_u6_");
|
||||
list.add(user6);
|
||||
@@ -79,7 +79,7 @@ public class SysUserInitService {
|
||||
SysUserEntity user7 = new SysUserEntity();
|
||||
user7.setId("u7");
|
||||
user7.setName("孙七");
|
||||
user7.setUsnam("sq");
|
||||
user7.setUsername("sq");
|
||||
user7.setDepid("d1111");
|
||||
user7.setTier("_d1000_d1100_d1110_d1111_u7_");
|
||||
list.add(user7);
|
||||
@@ -87,7 +87,7 @@ public class SysUserInitService {
|
||||
SysUserEntity user8 = new SysUserEntity();
|
||||
user8.setId("u8");
|
||||
user8.setName("周八");
|
||||
user8.setUsnam("zb");
|
||||
user8.setUsername("zb");
|
||||
user8.setDepid("d1111");
|
||||
user8.setTier("_d1000_d1100_d1110_d1111_u8_");
|
||||
list.add(user8);
|
||||
@@ -95,7 +95,7 @@ public class SysUserInitService {
|
||||
SysUserEntity user9 = new SysUserEntity();
|
||||
user9.setId("u9");
|
||||
user9.setName("吴九");
|
||||
user9.setUsnam("wj");
|
||||
user9.setUsername("wj");
|
||||
user9.setDepid("d1111");
|
||||
user9.setTier("_d1000_d1100_d1110_d1111_u9_");
|
||||
list.add(user9);
|
||||
@@ -111,8 +111,7 @@ public class SysUserInitService {
|
||||
List<SysOrg> list2=new ArrayList<>();
|
||||
for (SysUserEntity user : list) {
|
||||
user.setAvtag(true);
|
||||
user.setNinam(user.getName());
|
||||
user.setPacod("$2a$10$09f8rxsX4tbj1CZla2MSOuiwHwp5QAPUzbp5whnoZEFK4/xplNwZq");
|
||||
user.setPassword("$2a$10$09f8rxsX4tbj1CZla2MSOuiwHwp5QAPUzbp5whnoZEFK4/xplNwZq");
|
||||
user.setOrnum(Integer.parseInt(user.getId().substring(1)));
|
||||
SysOrg org = new SysOrg();
|
||||
org.setId(user.getId());
|
||||
|
||||
@@ -58,7 +58,7 @@ public class UserDTO implements Serializable {
|
||||
/**
|
||||
* 用户性别(0男 1女 2未知)
|
||||
*/
|
||||
private String sex;
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 帐号状态(0正常 1停用)
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ import java.lang.annotation.Target;
|
||||
public @interface DictPattern {
|
||||
|
||||
/**
|
||||
* 字典类型,如 "sys_user_sex"
|
||||
* 字典类型,如 "sys_user_gender"
|
||||
*/
|
||||
String dictType();
|
||||
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ import java.lang.annotation.*;
|
||||
public @interface ExcelDictFormat {
|
||||
|
||||
/**
|
||||
* 如果是字典类型,请设置字典的type值 (如: sys_user_sex)
|
||||
* 如果是字典类型,请设置字典的type值 (如: sys_user_gender)
|
||||
*/
|
||||
String dictType() default "";
|
||||
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ public @interface Translation {
|
||||
String mapper() default "";
|
||||
|
||||
/**
|
||||
* 其他条件 例如: 字典type(sys_user_sex)
|
||||
* 其他条件 例如: 字典type(sys_user_gender)
|
||||
*/
|
||||
String other() default "";
|
||||
|
||||
|
||||
+4
-5
@@ -145,17 +145,16 @@ public class PasswordAuthStrategy implements IAuthStrategy {
|
||||
|
||||
private AuthUserVo loadUserByUsername(String username) {
|
||||
// SysUserVo user = userService.findById().selectVoOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, username));
|
||||
SysUser orgUser = userDao.findByUsnam(username);
|
||||
SysUser orgUser = userDao.findByUsername(username);
|
||||
AuthUserVo user=new AuthUserVo();
|
||||
user.setUserId(orgUser.getId());
|
||||
user.setUserName(orgUser.getUsnam());
|
||||
user.setPassword(orgUser.getPacod());
|
||||
user.setNickName(orgUser.getNinam());
|
||||
user.setUserName(orgUser.getUsername());
|
||||
user.setPassword(orgUser.getPassword());
|
||||
user.setNickName(orgUser.getName());
|
||||
user.setDeptId(orgUser.getDepid());
|
||||
user.setDeptName(orgUser.getDepna());
|
||||
user.setStatus(orgUser.getAvtag()?"0":"1");
|
||||
user.setAvatar(orgUser.getAvatar());
|
||||
//user.set(orgUser.getUsnam());
|
||||
|
||||
if (ObjectUtils.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", username);
|
||||
|
||||
+4
-4
@@ -88,14 +88,14 @@ public class SmsAuthStrategy implements IAuthStrategy {
|
||||
SysUser orgUser = userDao.findByMonum(phonenumber);
|
||||
AuthUserVo user=new AuthUserVo();
|
||||
user.setUserId(orgUser.getId());
|
||||
user.setUserName(orgUser.getUsnam());
|
||||
user.setPassword(orgUser.getPacod());
|
||||
user.setNickName(orgUser.getNinam());
|
||||
user.setUserName(orgUser.getUsername());
|
||||
user.setPassword(orgUser.getPassword());
|
||||
user.setNickName(orgUser.getName());
|
||||
user.setDeptId(orgUser.getDepid());
|
||||
user.setDeptName(orgUser.getDepna());
|
||||
user.setStatus(orgUser.getAvtag()?"0":"1");
|
||||
user.setAvatar(orgUser.getAvatar());
|
||||
//user.set(orgUser.getUsnam());
|
||||
//user.set(orgUser.getUsername());
|
||||
|
||||
if (ObjectUtils.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", phonenumber);
|
||||
|
||||
+3
-3
@@ -111,10 +111,10 @@ public class SocialAuthStrategy implements IAuthStrategy {
|
||||
private AuthUserVo loadUser(String userId) {
|
||||
SysUser orgUser = userDao.findById(userId);
|
||||
AuthUserVo user=new AuthUserVo();
|
||||
user.setUserName(orgUser.getUsnam());
|
||||
user.setUserName(orgUser.getUsername());
|
||||
user.setUserId(orgUser.getId());
|
||||
user.setPassword(orgUser.getPacod());
|
||||
user.setNickName(orgUser.getNinam());
|
||||
user.setPassword(orgUser.getPassword());
|
||||
user.setNickName(orgUser.getName());
|
||||
user.setDeptId(orgUser.getDepid());
|
||||
user.setDeptName(orgUser.getDepna());
|
||||
user.setUserType("sys_user");
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package vben.base.auth.register;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import vben.common.core.domain.R;
|
||||
import vben.common.core.domain.model.RegisterBody;
|
||||
|
||||
/**
|
||||
* 认证
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Slf4j
|
||||
@SaIgnore
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
public class AuthRegisterApi {
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
@PostMapping("/auth/register")
|
||||
public R<Void> register(@Validated @RequestBody RegisterBody user) {
|
||||
registerService.register(user);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
private final SysRegisterService registerService;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package vben.base.auth.register;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import vben.base.sys.user.SysUserService;
|
||||
import vben.base.sys.user.vo.RegisterVo;
|
||||
import vben.common.core.constant.Constants;
|
||||
import vben.common.core.constant.GlobalConstants;
|
||||
import vben.common.core.domain.model.RegisterBody;
|
||||
import vben.common.core.enums.UserType;
|
||||
import vben.common.core.exception.user.CaptchaException;
|
||||
import vben.common.core.exception.user.CaptchaExpireException;
|
||||
import vben.common.core.utils.MessageUtils;
|
||||
import vben.common.core.utils.ServletUtils;
|
||||
import vben.common.core.utils.SpringUtils;
|
||||
import vben.common.core.utils.StrUtils;
|
||||
import vben.common.log.event.LogininforEvent;
|
||||
import vben.common.redis.utils.RedisUtils;
|
||||
import vben.common.web.config.properties.CaptchaProperties;
|
||||
|
||||
/**
|
||||
* 注册校验方法
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SysRegisterService {
|
||||
|
||||
private final SysUserService userService;
|
||||
private final CaptchaProperties captchaProperties;
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
public void register(RegisterBody registerBody) {
|
||||
String tenantId = registerBody.getTenantId();
|
||||
String username = registerBody.getUsername();
|
||||
String password = registerBody.getPassword();
|
||||
// 校验用户类型是否存在
|
||||
String userType = UserType.getUserType(registerBody.getUserType()).getUserType();
|
||||
|
||||
boolean captchaEnabled = captchaProperties.getEnable();
|
||||
// 验证码开关
|
||||
if (captchaEnabled) {
|
||||
validateCaptcha(tenantId, username, registerBody.getCode(), registerBody.getUuid());
|
||||
}
|
||||
RegisterVo registerVo = new RegisterVo();
|
||||
registerVo.setNickName(username);
|
||||
registerVo.setPassword(password);
|
||||
// sysUser.setUserType(userType);
|
||||
|
||||
// boolean regFlag = userService.registerUser(sysUser, tenantId);
|
||||
userService.register(registerVo);
|
||||
recordLogininfor(tenantId, username, Constants.REGISTER, MessageUtils.message("user.register.success"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验验证码
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param code 验证码
|
||||
* @param uuid 唯一标识
|
||||
*/
|
||||
public void validateCaptcha(String tenantId, String username, String code, String uuid) {
|
||||
String verifyKey = GlobalConstants.CAPTCHA_CODE_KEY + StrUtils.blankToDefault(uuid, "");
|
||||
String captcha = RedisUtils.getCacheObject(verifyKey);
|
||||
RedisUtils.deleteObject(verifyKey);
|
||||
if (captcha == null) {
|
||||
recordLogininfor(tenantId, username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"));
|
||||
throw new CaptchaExpireException();
|
||||
}
|
||||
if (!StringUtils.equalsIgnoreCase(code, captcha)) {
|
||||
recordLogininfor(tenantId, username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"));
|
||||
throw new CaptchaException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录登录信息
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
* @param username 用户名
|
||||
* @param status 状态
|
||||
* @param message 消息内容
|
||||
* @return
|
||||
*/
|
||||
private void recordLogininfor(String tenantId, String username, String status, String message) {
|
||||
LogininforEvent logininforEvent = new LogininforEvent();
|
||||
logininforEvent.setTenantId(tenantId);
|
||||
logininforEvent.setUsername(username);
|
||||
logininforEvent.setStatus(status);
|
||||
logininforEvent.setMessage(message);
|
||||
logininforEvent.setRequest(ServletUtils.getRequest());
|
||||
SpringUtils.context().publishEvent(logininforEvent);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public class AuthUserApi {
|
||||
userVo.setDeptId(loginUser.getDeptId());
|
||||
userVo.setAvatar(user.getAvatar());
|
||||
userVo.setPhonenumber(user.getMonum());
|
||||
userVo.setSex(user.getSex());
|
||||
userVo.setGender(user.getGender());
|
||||
userInfoVo.setUser(userVo);
|
||||
userInfoVo.setPermissions(loginUser.getMenuPermission());
|
||||
userInfoVo.setRoles(loginUser.getRolePermission());
|
||||
|
||||
@@ -63,7 +63,7 @@ public class AuthUserVo implements Serializable {
|
||||
/**
|
||||
* 用户性别(0男 1女 2未知)
|
||||
*/
|
||||
private String sex;
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 头像地址
|
||||
|
||||
@@ -23,7 +23,7 @@ public class MonLoginLog {
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
private String usnam;
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 客户端
|
||||
|
||||
@@ -25,7 +25,7 @@ public class MonLoginLogApi {
|
||||
@SaCheckPermission("mon:login:query")
|
||||
@GetMapping
|
||||
public R<PageData> get() {
|
||||
Sqler sqler = new Sqler("t.id,t.usnam,t.clkey,t.loip,t.loloc,t.browser,t.os,t.sutag,t.himsg,t.lotim","mon_login_log");
|
||||
Sqler sqler = new Sqler("t.id,t.username,t.clkey,t.loip,t.loloc,t.browser,t.os,t.sutag,t.himsg,t.lotim","mon_login_log");
|
||||
sqler.addDescOrder("t.lotim");
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class MonLoginLogDao {
|
||||
Isqler isqler = new Isqler("mon_login_log");
|
||||
isqler.add("id", main.getId());
|
||||
isqler.add("tenid", main.getTenid());
|
||||
isqler.add("usnam", main.getUsnam());
|
||||
isqler.add("username", main.getUsername());
|
||||
isqler.add("clkey", main.getClkey());
|
||||
isqler.add("detyp", main.getDetyp());
|
||||
isqler.add("sutag", main.getSutag());
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ public class MonLoginLogService {
|
||||
// 封装对象
|
||||
MonLoginLog log = new MonLoginLog();
|
||||
log.setTenid(logininforEvent.getTenantId());
|
||||
log.setUsnam(logininforEvent.getUsername());
|
||||
log.setUsername(logininforEvent.getUsername());
|
||||
// if (ObjectUtils.isNotNull(client)) {
|
||||
// logininfor.setClientKey(client.getClientKey());
|
||||
// logininfor.setDeviceType(client.getDeviceType());
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package vben.base.sys.corp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 公司
|
||||
*/
|
||||
@Data
|
||||
public class SysCorp {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 分类ID
|
||||
*/
|
||||
private String catid;
|
||||
|
||||
/**
|
||||
* 公司类型
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String notes;
|
||||
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
private Integer ornum;
|
||||
|
||||
/**
|
||||
* 可用标记
|
||||
*/
|
||||
private Boolean avtag;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date crtim = new Date();
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date uptim;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private String cruid;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
private String upuid;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package vben.base.sys.corp;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import vben.common.core.domain.R;
|
||||
import vben.common.core.utils.StrUtils;
|
||||
import vben.common.jdbc.dto.PageData;
|
||||
import vben.common.jdbc.sqler.Sqler;
|
||||
import vben.common.log.annotation.Log;
|
||||
import vben.common.log.enums.BusinessType;
|
||||
|
||||
/**
|
||||
* 公司管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("sys/corp")
|
||||
@RequiredArgsConstructor
|
||||
public class SysCorpApi {
|
||||
|
||||
private final SysCorpService service;
|
||||
|
||||
/**
|
||||
* 公司分页查询
|
||||
* @param catid 公司分类ID
|
||||
* @param name 公司名称
|
||||
* @return 公司分页数据
|
||||
*/
|
||||
@SaCheckPermission("sys:corp:query")
|
||||
@GetMapping
|
||||
public R<PageData> get(Long catid, String name) {
|
||||
Sqler sqler = new Sqler("sys_corp");
|
||||
if (StrUtils.isNotBlank(name)) {
|
||||
sqler.addLike("t.name", name);
|
||||
} else if (catid!=null) {
|
||||
sqler.addEqual("t.catid", catid);
|
||||
}
|
||||
sqler.addLeftJoin("c.name catna","sys_corp_cate c","c.id=t.catid");
|
||||
sqler.addSelect("t.ornum,t.notes,t.crtim,t.uptim,t.avtag");
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
/**
|
||||
* 公司详情查询
|
||||
* @param id 公司ID
|
||||
* @return 公司对象
|
||||
*/
|
||||
@SaCheckPermission("sys:corp:query")
|
||||
@GetMapping("info/{id}")
|
||||
public R<SysCorp> info(@PathVariable String id) {
|
||||
SysCorp main = service.findById(id);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
/**
|
||||
* 公司新增
|
||||
* @param main 公司对象
|
||||
* @return 公司ID
|
||||
*/
|
||||
@Log(title = "公司管理", businessType = BusinessType.INSERT)
|
||||
@SaCheckPermission("sys:corp:edit")
|
||||
@PostMapping
|
||||
public R<String> post(@RequestBody SysCorp main) {
|
||||
service.insert(main);
|
||||
return R.ok(null,main.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 公司修改
|
||||
* @param main 公司对象
|
||||
* @return 公司ID
|
||||
*/
|
||||
@Log(title = "公司管理", businessType = BusinessType.UPDATE)
|
||||
@SaCheckPermission("sys:corp:edit")
|
||||
@PutMapping
|
||||
public R<String> put(@RequestBody SysCorp main) {
|
||||
service.update(main);
|
||||
return R.ok(null,main.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 公司删除
|
||||
* @param ids 公司ID串
|
||||
* @return 公司数量
|
||||
*/
|
||||
@Log(title = "公司管理", businessType = BusinessType.DELETE)
|
||||
@SaCheckPermission("sys:corp:delete")
|
||||
@DeleteMapping("{ids}")
|
||||
public R<Integer> delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package vben.base.sys.corp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* 公司分类
|
||||
*/
|
||||
@Data
|
||||
public class SysCorpCate {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 父ID
|
||||
*/
|
||||
private String pid;
|
||||
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
private Integer ornum;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package vben.base.sys.corp;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import vben.common.core.domain.R;
|
||||
import vben.common.jdbc.dto.Smove;
|
||||
import vben.common.jdbc.dto.Stree;
|
||||
import vben.common.log.annotation.Log;
|
||||
import vben.common.log.enums.BusinessType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 公司分类管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("sys/corpc")
|
||||
@RequiredArgsConstructor
|
||||
public class SysCorpCateApi {
|
||||
|
||||
private final SysCorpCateService service;
|
||||
|
||||
/**
|
||||
* 公司分类树状查询
|
||||
* @param id 分类ID,如传入则查询出来的树结构会排除自身及子节点
|
||||
* @return 公司树状数据
|
||||
*/
|
||||
@SaCheckPermission("sys:corpc:query")
|
||||
@GetMapping("tree")
|
||||
public R<List<Stree>> tree(String id) {
|
||||
return R.ok(service.findTreeList(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 公司分类详情查询
|
||||
* @param id 分类ID
|
||||
* @return 公司分类对象
|
||||
*/
|
||||
@SaCheckPermission("sys:corpc:query")
|
||||
@GetMapping("info/{id}")
|
||||
public R<SysCorpCate> info(@PathVariable String id) {
|
||||
SysCorpCate cate = service.findById(id);
|
||||
return R.ok(cate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 公司分类新增
|
||||
* @param cate 分类对象
|
||||
* @return 分类ID
|
||||
*/
|
||||
@Log(title = "公司分类管理", businessType = BusinessType.INSERT)
|
||||
@SaCheckPermission("sys:corpc:edit")
|
||||
@PostMapping
|
||||
public R<String> post(@RequestBody SysCorpCate cate) {
|
||||
service.insert(cate);
|
||||
return R.ok(null,cate.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 公司分类修改
|
||||
* @param cate 分类对象
|
||||
* @return 分类ID
|
||||
*/
|
||||
@Log(title = "公司分类管理", businessType = BusinessType.UPDATE)
|
||||
@SaCheckPermission("sys:corpc:edit")
|
||||
@PutMapping
|
||||
public R<String> put(@RequestBody SysCorpCate cate) {
|
||||
service.update(cate);
|
||||
return R.ok(null,cate.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 公司分类删除
|
||||
* @param id 分类ID
|
||||
*/
|
||||
@Log(title = "公司分类管理", businessType = BusinessType.DELETE)
|
||||
@SaCheckPermission("sys:corpc:delete")
|
||||
@DeleteMapping("{id}")
|
||||
public R<Void> delete(@PathVariable String id) {
|
||||
service.delete(id);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 公司分类移动
|
||||
* @param bo 移动对象
|
||||
*/
|
||||
@Log(title = "公司分类管理", businessType = BusinessType.UPDATE)
|
||||
@SaCheckPermission("sys:corpc:edit")
|
||||
@PostMapping("move")
|
||||
public R<Void> move(@RequestBody Smove bo) {
|
||||
service.move(bo);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package vben.base.sys.corp;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
import vben.common.core.utils.StrUtils;
|
||||
import vben.common.jdbc.dto.Stree;
|
||||
import vben.common.jdbc.sqler.Isqler;
|
||||
import vben.common.jdbc.sqler.JdbcHelper;
|
||||
import vben.common.jdbc.sqler.Usqler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class SysCorpCateDao {
|
||||
|
||||
public List<Stree> findTreeList(String id) {
|
||||
if(StrUtils.isBlank(id)) {
|
||||
return jdbcHelper.findStreeList("select id,name,pid from sys_corp_cate order by ornum");
|
||||
}else{
|
||||
return jdbcHelper.findStreeList("select id,name,pid from sys_corp_cate where id <> ? order by ornum",id);
|
||||
}
|
||||
}
|
||||
|
||||
public SysCorpCate findById(String id) {
|
||||
String sql = "select * from sys_corp_cate where id = ?";
|
||||
return jdbcHelper.getTp().queryForObject(sql, new BeanPropertyRowMapper<>(SysCorpCate.class), id);
|
||||
}
|
||||
|
||||
public void insert(SysCorpCate cate) {
|
||||
Isqler isqler = new Isqler("sys_corp_cate");
|
||||
isqler.add("id", cate.getId());
|
||||
isqler.add("name", cate.getName());
|
||||
isqler.add("pid", cate.getPid());
|
||||
isqler.add("ornum", cate.getOrnum());
|
||||
jdbcHelper.getTp().update(isqler.getSql(), isqler.getParams());
|
||||
}
|
||||
|
||||
public void update(SysCorpCate cate) {
|
||||
Usqler usqler = new Usqler("sys_corp_cate");
|
||||
usqler.addWhere("id=?", cate.getId());
|
||||
usqler.add("name", cate.getName());
|
||||
usqler.add("ornum", cate.getOrnum());
|
||||
usqler.add("pid", cate.getPid());
|
||||
jdbcHelper.getTp().update(usqler.getSql(), usqler.getParams());
|
||||
}
|
||||
|
||||
public void deleteById(String id) {
|
||||
String sql = "delete from sys_corp_cate where id=?";
|
||||
jdbcHelper.getTp().update(sql, id);
|
||||
}
|
||||
|
||||
public Integer getCount(String pid){
|
||||
String countSql="select count(1) from sys_corp_cate where pid=?";
|
||||
Integer count = jdbcHelper.getTp().queryForObject(countSql,Integer.class,pid);
|
||||
if(count==null){
|
||||
count=0;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
private final JdbcHelper jdbcHelper;
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package vben.base.sys.corp;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import vben.common.core.utils.IdUtils;
|
||||
import vben.common.jdbc.dto.SidOrnum;
|
||||
import vben.common.jdbc.dto.Smove;
|
||||
import vben.common.jdbc.dto.Stree;
|
||||
import vben.common.jdbc.sqler.JdbcHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@RequiredArgsConstructor
|
||||
public class SysCorpCateService {
|
||||
|
||||
public List<Stree> findTreeList(String id) {
|
||||
return cateDao.findTreeList(id);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public SysCorpCate findById(String id) {
|
||||
return cateDao.findById(id);
|
||||
}
|
||||
|
||||
public void insert(SysCorpCate cate) {
|
||||
cate.setId(IdUtils.getSnowflakeNextIdStr());
|
||||
cate.setOrnum(cateDao.getCount(cate.getPid()) + 1);
|
||||
cateDao.insert(cate);
|
||||
}
|
||||
|
||||
public void update(SysCorpCate cate) {
|
||||
cateDao.update(cate);
|
||||
}
|
||||
|
||||
public Integer delete(String id) {
|
||||
Integer size=1;
|
||||
String sql = "select id from sys_corp_cate where pid=?";
|
||||
List<String> list = jdbcHelper.getTp().queryForList(sql, String.class, id);
|
||||
for (String l : list) {
|
||||
cateDao.deleteById(l);
|
||||
size++;
|
||||
}
|
||||
cateDao.deleteById(id);
|
||||
return size;
|
||||
}
|
||||
|
||||
public void move(Smove bo) {
|
||||
SysCorpCate dragCate = cateDao.findById(bo.getDraid());
|
||||
String sql = "select id,ornum from sys_corp_cate where ornum>? and pid=?";
|
||||
List<SidOrnum> list2 = jdbcHelper.getTp().query(sql,new BeanPropertyRowMapper<>(SidOrnum.class),dragCate.getOrnum(), dragCate.getPid());
|
||||
String updateSql = "update sys_corp_cate set ornum=? where id=?";
|
||||
List<Object[]> updateList = new ArrayList<>();
|
||||
for (SidOrnum sidOrnum : list2) {
|
||||
Object[] arr = new Object[2];
|
||||
arr[0] = sidOrnum.getOrnum() - 1;
|
||||
arr[1] = sidOrnum.getId();
|
||||
updateList.add(arr);
|
||||
}
|
||||
jdbcHelper.batch(updateSql, updateList);
|
||||
if ("inner".equals(bo.getType())) {
|
||||
dragCate.setPid(bo.getDroid());
|
||||
Integer count = cateDao.getCount(bo.getDroid());
|
||||
dragCate.setOrnum(count + 1);
|
||||
} else if ("before".equals(bo.getType())) {
|
||||
SysCorpCate dropCate = cateDao.findById(bo.getDroid());
|
||||
dragCate.setPid(dropCate.getPid());
|
||||
dragCate.setOrnum(dropCate.getOrnum());
|
||||
String sql3 = "select id,ornum from sys_corp_cate where ornum>? and pid=?";
|
||||
List<SidOrnum> list3 = jdbcHelper.getTp().query(sql3, new BeanPropertyRowMapper<>(SidOrnum.class),dropCate.getOrnum(), dropCate.getPid());
|
||||
String updateSql3 = "update sys_corp_cate set ornum=? where id=?";
|
||||
List<Object[]> updateList3 = new ArrayList<>();
|
||||
for (SidOrnum sidOrnum : list3) {
|
||||
Object[] arr = new Object[2];
|
||||
arr[0] = sidOrnum.getOrnum() + 1;
|
||||
arr[1] = sidOrnum.getId();
|
||||
updateList3.add(arr);
|
||||
}
|
||||
jdbcHelper.batch(updateSql3, updateList3);
|
||||
dropCate.setOrnum(dropCate.getOrnum() + 1);
|
||||
String updateSql4 = "update sys_corp_cate set ornum=? where id=?";
|
||||
jdbcHelper.update(updateSql4, dropCate.getOrnum(), dropCate.getId());
|
||||
} else if ("after".equals(bo.getType())) {
|
||||
SysCorpCate dropCate = cateDao.findById(bo.getDroid());
|
||||
dragCate.setPid(dropCate.getPid());
|
||||
dragCate.setOrnum(dropCate.getOrnum() + 1);
|
||||
String sql3 = "select id,ornum from sys_corp_cate where ornum>? and pid=?";
|
||||
List<SidOrnum> list3 = jdbcHelper.getTp().query(sql3,new BeanPropertyRowMapper<>(SidOrnum.class),dropCate.getOrnum(), dropCate.getPid());
|
||||
String updateSql3 = "update sys_corp_cate set ornum=? where id=?";
|
||||
List<Object[]> updateList3 = new ArrayList<>();
|
||||
for (SidOrnum sidOrnum : list3) {
|
||||
Object[] arr = new Object[2];
|
||||
arr[0] = sidOrnum.getOrnum() + 1;
|
||||
arr[1] = sidOrnum.getId();
|
||||
updateList3.add(arr);
|
||||
}
|
||||
jdbcHelper.batch(updateSql3, updateList3);
|
||||
}
|
||||
update(dragCate);
|
||||
}
|
||||
|
||||
private final JdbcHelper jdbcHelper;
|
||||
|
||||
private final SysCorpCateDao cateDao;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package vben.base.sys.corp;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
import vben.common.jdbc.sqler.Isqler;
|
||||
import vben.common.jdbc.sqler.JdbcHelper;
|
||||
import vben.common.jdbc.sqler.Usqler;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class SysCorpDao {
|
||||
|
||||
public SysCorp findById(String id) {
|
||||
String sql = "select * from sys_corp where id = ?";
|
||||
return jdbcHelper.getTp().queryForObject(sql, new BeanPropertyRowMapper<>(SysCorp.class), id);
|
||||
}
|
||||
|
||||
public void insert(SysCorp corp) {
|
||||
Isqler sqler = new Isqler("sys_corp");
|
||||
sqler.add("id", corp.getId());
|
||||
sqler.add("name", corp.getName());
|
||||
sqler.add("catid", corp.getCatid());
|
||||
sqler.add("type", corp.getType());
|
||||
sqler.add("notes", corp.getNotes());
|
||||
sqler.add("ornum", corp.getOrnum());
|
||||
sqler.add("crtim", corp.getCrtim());
|
||||
sqler.add("uptim", corp.getCrtim());
|
||||
sqler.add("avtag", corp.getAvtag());
|
||||
sqler.add("label", corp.getLabel());
|
||||
sqler.add("cruid", corp.getCruid());
|
||||
sqler.add("upuid", corp.getCruid());
|
||||
jdbcHelper.getTp().update(sqler.getSql(), sqler.getParams());
|
||||
}
|
||||
|
||||
public void update(SysCorp corp) {
|
||||
Usqler sqler = new Usqler("sys_corp");
|
||||
sqler.addWhere("id=?", corp.getId());
|
||||
sqler.add("name", corp.getName());
|
||||
sqler.add("catid", corp.getCatid());
|
||||
sqler.add("type", corp.getType());
|
||||
sqler.add("notes", corp.getNotes());
|
||||
sqler.add("ornum", corp.getOrnum());
|
||||
sqler.add("uptim", corp.getUptim());
|
||||
sqler.add("avtag", corp.getAvtag());
|
||||
sqler.add("label", corp.getLabel());
|
||||
sqler.add("upuid", corp.getUpuid());
|
||||
jdbcHelper.getTp().update(sqler.getSql(), sqler.getParams());
|
||||
}
|
||||
|
||||
public Integer getCount(String pid) {
|
||||
String sql = "select count(1) from sys_corp where pid=?";
|
||||
return jdbcHelper.getTp().queryForObject(sql, Integer.class, pid);
|
||||
}
|
||||
|
||||
public void deleteById(String id) {
|
||||
String sql = "delete from sys_corp where id=?";
|
||||
jdbcHelper.getTp().update(sql, id);
|
||||
}
|
||||
|
||||
private final JdbcHelper jdbcHelper;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package vben.base.sys.corp;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import vben.base.sys.org.Org;
|
||||
import vben.base.sys.org.OrgDao;
|
||||
import vben.common.core.utils.IdUtils;
|
||||
import vben.common.jdbc.dto.PageData;
|
||||
import vben.common.jdbc.sqler.JdbcHelper;
|
||||
import vben.common.jdbc.sqler.Sqler;
|
||||
import vben.common.satoken.utils.LoginHelper;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@RequiredArgsConstructor
|
||||
public class SysCorpService {
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public SysCorp findById(String id) {
|
||||
return dao.findById(id);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public PageData findPageData(Sqler sqler) {
|
||||
return jdbcHelper.findPageData(sqler);
|
||||
}
|
||||
|
||||
public void insert(SysCorp main) {
|
||||
if (main.getId() == null) {
|
||||
main.setId("g"+IdUtils.getSnowflakeNextIdStr());
|
||||
}
|
||||
main.setCruid(LoginHelper.getUserId());
|
||||
Org org = new Org(main.getId(), main.getName(), 8);
|
||||
orgDao.insert(org);
|
||||
dao.insert(main);
|
||||
}
|
||||
|
||||
public void update(SysCorp main) {
|
||||
main.setUptim(new Date());
|
||||
main.setUpuid(LoginHelper.getUserId());
|
||||
Org org = new Org(main.getId(), main.getName(), 8);
|
||||
orgDao.update(org);
|
||||
dao.update(main);
|
||||
}
|
||||
|
||||
public int delete(String[] ids) {
|
||||
for (String id : ids) {
|
||||
dao.deleteById(id);
|
||||
orgDao.deleteById(id);
|
||||
}
|
||||
return ids.length;
|
||||
}
|
||||
|
||||
private final JdbcHelper jdbcHelper;
|
||||
|
||||
private final SysCorpDao dao;
|
||||
|
||||
private final OrgDao orgDao;
|
||||
|
||||
}
|
||||
@@ -83,23 +83,4 @@ public class SysDept {
|
||||
*/
|
||||
private String upuid;
|
||||
|
||||
/**
|
||||
* 自定义扩展字段1
|
||||
*/
|
||||
private String ex1;
|
||||
|
||||
/**
|
||||
* 自定义扩展字段2
|
||||
*/
|
||||
private String ex2;
|
||||
|
||||
/**
|
||||
* 自定义扩展字段3
|
||||
*/
|
||||
private String ex3;
|
||||
|
||||
/**
|
||||
* 自定义扩展字段4
|
||||
*/
|
||||
private String ex4;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class SysDeptApi {
|
||||
* @param id 部门ID,如传入则查询出来的树结构会排除自身及子节点
|
||||
* @return 部门树状集合
|
||||
*/
|
||||
@SaCheckPermission("sysorg:dept:query")
|
||||
@SaCheckPermission("sys:dept:query")
|
||||
@GetMapping("tree")
|
||||
public R<List<Stree>> tree(String id) {
|
||||
return R.ok(service.findTree(id));
|
||||
@@ -76,7 +76,7 @@ public class SysDeptApi {
|
||||
* @param id 部门ID
|
||||
* @return 部门对象
|
||||
*/
|
||||
@SaCheckPermission("sysorg:dept:query")
|
||||
@SaCheckPermission("sys:dept:query")
|
||||
@GetMapping("info/{id}")
|
||||
public R<SysDept> info(@PathVariable String id) {
|
||||
SysDept main = service.findById(id);
|
||||
@@ -88,7 +88,7 @@ public class SysDeptApi {
|
||||
* @param main 部门对象
|
||||
* @return 部门ID
|
||||
*/
|
||||
@SaCheckPermission("sysorg:dept:edit")
|
||||
@SaCheckPermission("sys:dept:edit")
|
||||
@PostMapping
|
||||
@Log(title = "部门管理", businessType = BusinessType.INSERT)
|
||||
public R<String> post(@RequestBody SysDept main) {
|
||||
@@ -101,7 +101,7 @@ public class SysDeptApi {
|
||||
* @param main 部门对象
|
||||
* @return 部门ID
|
||||
*/
|
||||
@SaCheckPermission("sysorg:dept:edit")
|
||||
@SaCheckPermission("sys:dept:edit")
|
||||
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R<String> put(@RequestBody SysDept main) {
|
||||
@@ -114,7 +114,7 @@ public class SysDeptApi {
|
||||
* @param ids 部门ID串
|
||||
* @return 部门数量
|
||||
*/
|
||||
@SaCheckPermission("sysorg:dept:delete")
|
||||
@SaCheckPermission("sys:dept:delete")
|
||||
@Log(title = "部门管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("{ids}")
|
||||
public R<Integer> delete(@PathVariable String[] ids) {
|
||||
@@ -125,7 +125,7 @@ public class SysDeptApi {
|
||||
* 部门移动
|
||||
* @param bo 移动BO对象
|
||||
*/
|
||||
@SaCheckPermission("sysorg:dept:edit")
|
||||
@SaCheckPermission("sys:dept:edit")
|
||||
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("move")
|
||||
public R<Void> move(@RequestBody Smove bo) {
|
||||
|
||||
@@ -37,10 +37,6 @@ public class SysDeptDao {
|
||||
sqler.add("label", sysDept.getLabel());
|
||||
sqler.add("cruid", sysDept.getCruid());
|
||||
sqler.add("upuid", sysDept.getCruid());
|
||||
sqler.add("ex1", sysDept.getEx1());
|
||||
sqler.add("ex2", sysDept.getEx2());
|
||||
sqler.add("ex3", sysDept.getEx3());
|
||||
sqler.add("ex4", sysDept.getEx4());
|
||||
jdbcHelper.getTp().update(sqler.getSql(), sqler.getParams());
|
||||
}
|
||||
|
||||
@@ -57,10 +53,6 @@ public class SysDeptDao {
|
||||
sqler.add("avtag", sysDept.getAvtag());
|
||||
sqler.add("label", sysDept.getLabel());
|
||||
sqler.add("upuid", sysDept.getUpuid());
|
||||
sqler.add("ex1", sysDept.getEx1());
|
||||
sqler.add("ex2", sysDept.getEx2());
|
||||
sqler.add("ex3", sysDept.getEx3());
|
||||
sqler.add("ex4", sysDept.getEx4());
|
||||
jdbcHelper.getTp().update(sqler.getSql(), sqler.getParams());
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class SysGroupApi {
|
||||
* @param name 群组名称
|
||||
* @return 群组分页数据
|
||||
*/
|
||||
@SaCheckPermission("sysorg:group:query")
|
||||
@SaCheckPermission("sys:group:query")
|
||||
@GetMapping
|
||||
public R<PageData> get(Long catid, String name) {
|
||||
Sqler sqler = new Sqler("sys_group");
|
||||
@@ -45,7 +45,7 @@ public class SysGroupApi {
|
||||
* @param id 群组ID
|
||||
* @return 群组对象
|
||||
*/
|
||||
@SaCheckPermission("sysorg:group:query")
|
||||
@SaCheckPermission("sys:group:query")
|
||||
@GetMapping("info/{id}")
|
||||
public R<SysGroup> info(@PathVariable String id) {
|
||||
SysGroup main = service.findById(id);
|
||||
@@ -58,7 +58,7 @@ public class SysGroupApi {
|
||||
* @return 群组ID
|
||||
*/
|
||||
@Log(title = "群组管理", businessType = BusinessType.INSERT)
|
||||
@SaCheckPermission("sysorg:group:edit")
|
||||
@SaCheckPermission("sys:group:edit")
|
||||
@PostMapping
|
||||
public R<String> post(@RequestBody SysGroup main) {
|
||||
service.insert(main);
|
||||
@@ -71,7 +71,7 @@ public class SysGroupApi {
|
||||
* @return 群组ID
|
||||
*/
|
||||
@Log(title = "群组管理", businessType = BusinessType.UPDATE)
|
||||
@SaCheckPermission("sysorg:group:edit")
|
||||
@SaCheckPermission("sys:group:edit")
|
||||
@PutMapping
|
||||
public R<String> put(@RequestBody SysGroup main) {
|
||||
service.update(main);
|
||||
@@ -84,7 +84,7 @@ public class SysGroupApi {
|
||||
* @return 群组数量
|
||||
*/
|
||||
@Log(title = "群组管理", businessType = BusinessType.DELETE)
|
||||
@SaCheckPermission("sysorg:group:delete")
|
||||
@SaCheckPermission("sys:group:delete")
|
||||
@DeleteMapping("{ids}")
|
||||
public R<Integer> delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
|
||||
@@ -26,7 +26,7 @@ public class SysGroupCateApi {
|
||||
* @param id 分类ID,如传入则查询出来的树结构会排除自身及子节点
|
||||
* @return 群组树状数据
|
||||
*/
|
||||
@SaCheckPermission("sysorg:groupc:query")
|
||||
@SaCheckPermission("sys:groupc:query")
|
||||
@GetMapping("tree")
|
||||
public R<List<Stree>> tree(String id) {
|
||||
return R.ok(service.findTreeList(id));
|
||||
@@ -37,7 +37,7 @@ public class SysGroupCateApi {
|
||||
* @param id 分类ID
|
||||
* @return 群组分类对象
|
||||
*/
|
||||
@SaCheckPermission("sysorg:groupc:query")
|
||||
@SaCheckPermission("sys:groupc:query")
|
||||
@GetMapping("info/{id}")
|
||||
public R<SysGroupCate> info(@PathVariable String id) {
|
||||
SysGroupCate cate = service.findById(id);
|
||||
@@ -50,7 +50,7 @@ public class SysGroupCateApi {
|
||||
* @return 分类ID
|
||||
*/
|
||||
@Log(title = "群组分类管理", businessType = BusinessType.INSERT)
|
||||
@SaCheckPermission("sysorg:groupc:edit")
|
||||
@SaCheckPermission("sys:groupc:edit")
|
||||
@PostMapping
|
||||
public R<String> post(@RequestBody SysGroupCate cate) {
|
||||
service.insert(cate);
|
||||
@@ -63,7 +63,7 @@ public class SysGroupCateApi {
|
||||
* @return 分类ID
|
||||
*/
|
||||
@Log(title = "群组分类管理", businessType = BusinessType.UPDATE)
|
||||
@SaCheckPermission("sysorg:groupc:edit")
|
||||
@SaCheckPermission("sys:groupc:edit")
|
||||
@PutMapping
|
||||
public R<String> put(@RequestBody SysGroupCate cate) {
|
||||
service.update(cate);
|
||||
@@ -75,7 +75,7 @@ public class SysGroupCateApi {
|
||||
* @param id 分类ID
|
||||
*/
|
||||
@Log(title = "群组分类管理", businessType = BusinessType.DELETE)
|
||||
@SaCheckPermission("sysorg:groupc:delete")
|
||||
@SaCheckPermission("sys:groupc:delete")
|
||||
@DeleteMapping("{id}")
|
||||
public R<Void> delete(@PathVariable String id) {
|
||||
service.delete(id);
|
||||
@@ -87,7 +87,7 @@ public class SysGroupCateApi {
|
||||
* @param bo 移动对象
|
||||
*/
|
||||
@Log(title = "群组分类管理", businessType = BusinessType.UPDATE)
|
||||
@SaCheckPermission("sysorg:groupc:edit")
|
||||
@SaCheckPermission("sys:groupc:edit")
|
||||
@PostMapping("move")
|
||||
public R<Void> move(@RequestBody Smove bo) {
|
||||
service.move(bo);
|
||||
|
||||
@@ -23,7 +23,7 @@ public class SysNotice {
|
||||
/**
|
||||
* 公告内容
|
||||
*/
|
||||
private String content;
|
||||
private String cont;
|
||||
|
||||
/**
|
||||
* 公告类型(1通知 2公告)
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ProfileUserVo implements Serializable {
|
||||
/**
|
||||
* 用户性别(0男 1女 2未知)
|
||||
*/
|
||||
private String sex;
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 头像地址
|
||||
|
||||
@@ -50,9 +50,9 @@ public class SysProfileApi extends BaseController {
|
||||
ProfileUserVo vo=new ProfileUserVo();
|
||||
vo.setUserId(user.getId());
|
||||
vo.setEmail(user.getEmail());
|
||||
vo.setSex(user.getSex());
|
||||
vo.setGender(user.getGender());
|
||||
vo.setDeptId(user.getDepid());
|
||||
vo.setUserName(user.getUsnam());
|
||||
vo.setUserName(user.getUsername());
|
||||
vo.setUserType(user.getType()+"");
|
||||
vo.setNickName(user.getName());
|
||||
vo.setPhonenumber(user.getMonum());
|
||||
@@ -76,9 +76,7 @@ public class SysProfileApi extends BaseController {
|
||||
SysUser user = userService.findById(LoginHelper.getUserId());
|
||||
user.setEmail(profile.getEmail());
|
||||
user.setName(profile.getNickName());
|
||||
user.setNinam(profile.getNickName());
|
||||
user.setSex(profile.getSex());
|
||||
user.setSex(profile.getSex());
|
||||
user.setGender(profile.getGender());
|
||||
user.setMonum(profile.getPhonenumber());
|
||||
userService.update(user);
|
||||
return R.ok();
|
||||
|
||||
@@ -36,6 +36,6 @@ public class SysUserProfileBo {
|
||||
/**
|
||||
* 用户性别(0男 1女 2未知)
|
||||
*/
|
||||
private String sex;
|
||||
private String gender;
|
||||
|
||||
}
|
||||
|
||||
@@ -18,14 +18,34 @@ public class SysUser {
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
* 姓名(昵称)
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
* 用户名(账号)
|
||||
*/
|
||||
private String ninam;
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String monum;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
@@ -47,31 +67,6 @@ public class SysUser {
|
||||
*/
|
||||
private String job;
|
||||
|
||||
/**
|
||||
* 登录名
|
||||
*/
|
||||
private String usnam;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String pacod;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String monum;
|
||||
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
@@ -138,24 +133,25 @@ public class SysUser {
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
//---------------------im补充--
|
||||
/**
|
||||
* 自定义扩展字段1
|
||||
* 直接可加还是需要同意后再加
|
||||
*/
|
||||
private String ex1;
|
||||
private Boolean jotyp;
|
||||
|
||||
/**
|
||||
* 自定义扩展字段2
|
||||
* 地区
|
||||
*/
|
||||
private String ex2;
|
||||
private String arnam;
|
||||
|
||||
/**
|
||||
* 自定义扩展字段3
|
||||
* 地区
|
||||
*/
|
||||
private String ex3;
|
||||
private String arcod;
|
||||
|
||||
/**
|
||||
* 自定义扩展字段4
|
||||
* 最后离开时间
|
||||
*/
|
||||
private String ex4;
|
||||
private Date oftim;
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import cn.hutool.crypto.digest.BCrypt;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import vben.base.sys.user.bo.IdAvtagBo;
|
||||
import vben.base.sys.user.bo.IdPacodBo;
|
||||
import vben.base.sys.user.bo.IdPasswordBo;
|
||||
import vben.common.core.domain.R;
|
||||
import vben.common.core.utils.StrUtils;
|
||||
import vben.common.jdbc.dto.PageData;
|
||||
@@ -27,25 +27,23 @@ public class SysUserApi {
|
||||
* 用户分页查询
|
||||
* @param depid 部门ID
|
||||
* @param name 用户姓名
|
||||
* @param usnam 用户账号
|
||||
* @param ninam 用户昵称
|
||||
* @param username 用户账号
|
||||
* @param monum 用户手机号
|
||||
* @return 用户分页数据
|
||||
*/
|
||||
@SaCheckPermission("sysorg:user:query")
|
||||
@SaCheckPermission("sys:user:query")
|
||||
@GetMapping
|
||||
public R<PageData> get(String depid, String name, String usnam, String ninam, String monum) {
|
||||
public R<PageData> get(String depid, String name, String username, String monum) {
|
||||
Sqler sqler = new Sqler("sys_user");
|
||||
if (StrUtils.isNotBlank(name) || StrUtils.isNotBlank(usnam) || StrUtils.isNotBlank(ninam) || StrUtils.isNotBlank(monum)) {
|
||||
if (StrUtils.isNotBlank(name) || StrUtils.isNotBlank(username) || StrUtils.isNotBlank(monum)) {
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addLike("t.usnam", usnam);
|
||||
sqler.addLike("t.ninam", ninam);
|
||||
sqler.addLike("t.username", username);
|
||||
sqler.addLike("t.monum", monum);
|
||||
} else if (depid!=null) {
|
||||
sqler.addEqual("t.depid", depid);
|
||||
}
|
||||
sqler.addLeftJoin("d.name depna","sys_dept d","d.id=t.depid");
|
||||
sqler.addSelect("t.crtim,t.uptim,t.notes,t.avtag,t.monum,t.usnam");
|
||||
sqler.addSelect("t.crtim,t.uptim,t.notes,t.avtag,t.monum,t.username");
|
||||
sqler.addOrder("t.ornum");
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
@@ -55,7 +53,7 @@ public class SysUserApi {
|
||||
* @param id 用户ID
|
||||
* @return 用户对象
|
||||
*/
|
||||
@SaCheckPermission("sysorg:user:query")
|
||||
@SaCheckPermission("sys:user:query")
|
||||
@GetMapping("info/{id}")
|
||||
public R<SysUser> info(@PathVariable String id) {
|
||||
SysUser main = service.findById(id);
|
||||
@@ -68,7 +66,7 @@ public class SysUserApi {
|
||||
* @return 用户ID
|
||||
*/
|
||||
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
||||
@SaCheckPermission("sysorg:user:edit")
|
||||
@SaCheckPermission("sys:user:edit")
|
||||
@PostMapping
|
||||
public R<String> post(@RequestBody SysUser main) {
|
||||
service.insert(main);
|
||||
@@ -81,7 +79,7 @@ public class SysUserApi {
|
||||
* @return 用户ID
|
||||
*/
|
||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@SaCheckPermission("sysorg:user:edit")
|
||||
@SaCheckPermission("sys:user:edit")
|
||||
@PutMapping
|
||||
public R<String> put(@RequestBody SysUser main) {
|
||||
service.update(main);
|
||||
@@ -94,7 +92,7 @@ public class SysUserApi {
|
||||
* @return 用户数量
|
||||
*/
|
||||
@Log(title = "用户管理", businessType = BusinessType.DELETE)
|
||||
@SaCheckPermission("sysorg:user:delete")
|
||||
@SaCheckPermission("sys:user:delete")
|
||||
@DeleteMapping("{ids}")
|
||||
public R<Integer> delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
@@ -105,7 +103,7 @@ public class SysUserApi {
|
||||
* @param bo 用户ID与是否可用组合对象
|
||||
*/
|
||||
@Log(title = "用户管理", businessType = BusinessType.OTHER)
|
||||
@SaCheckPermission("sysorg:user:avtag")
|
||||
@SaCheckPermission("sys:user:avtag")
|
||||
@PutMapping("avtag")
|
||||
public R<Void> avtag(@RequestBody IdAvtagBo bo) {
|
||||
service.changeAvatg(bo);
|
||||
@@ -118,10 +116,10 @@ public class SysUserApi {
|
||||
*/
|
||||
//@ApiEncrypt
|
||||
@Log(title = "用户管理", businessType = BusinessType.OTHER)
|
||||
@SaCheckPermission("sysorg:user:pacod")
|
||||
@PutMapping("pacod")
|
||||
public R<Void> pacod(@RequestBody IdPacodBo bo) {
|
||||
service.resetPassword(bo.getId(), BCrypt.hashpw(bo.getPacod()));
|
||||
@SaCheckPermission("sys:user:password")
|
||||
@PutMapping("password")
|
||||
public R<Void> password(@RequestBody IdPasswordBo bo) {
|
||||
service.resetPassword(bo.getId(), BCrypt.hashpw(bo.getPassword()));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,12 +26,12 @@ public class SysUserDao {
|
||||
}
|
||||
|
||||
public void resetPassword(String id, String password) {
|
||||
String sql = "update sys_user set pacod = ? where id = ?";
|
||||
String sql = "update sys_user set password = ? where id = ?";
|
||||
jdbcHelper.update(sql, password, id);
|
||||
}
|
||||
|
||||
public String findPassword(String id) {
|
||||
String sql = "select pacod from sys_user where id=?";
|
||||
String sql = "select password from sys_user where id=?";
|
||||
return jdbcHelper.getTp().queryForObject(sql, String.class, id);
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ public class SysUserDao {
|
||||
}
|
||||
|
||||
public void updateLogin(MonLoginLog log) {
|
||||
String sql = "update sys_user set loip = ? , lotim = ? where usnam = ?";
|
||||
jdbcHelper.update(sql, log.getLoip(), log.getLotim(), log.getUsnam());
|
||||
String sql = "update sys_user set loip = ? , lotim = ? where username = ?";
|
||||
jdbcHelper.update(sql, log.getLoip(), log.getLotim(), log.getUsername());
|
||||
}
|
||||
|
||||
|
||||
@@ -98,6 +98,8 @@ public class SysUserDao {
|
||||
Isqler sqler = new Isqler("sys_user");
|
||||
sqler.add("id", user.getId());
|
||||
sqler.add("name", user.getName());
|
||||
sqler.add("username", user.getUsername());
|
||||
sqler.add("password", user.getPassword());
|
||||
sqler.add("depid", user.getDepid());
|
||||
sqler.add("tier", user.getTier());
|
||||
sqler.add("notes", user.getNotes());
|
||||
@@ -108,17 +110,15 @@ public class SysUserDao {
|
||||
sqler.add("upuid", user.getCruid());
|
||||
sqler.add("avtag", user.getAvtag());
|
||||
sqler.add("label", user.getLabel());
|
||||
sqler.add("usnam", user.getUsnam());
|
||||
sqler.add("monum", user.getMonum());
|
||||
sqler.add("email", user.getEmail());
|
||||
sqler.add("pacod", user.getPacod());
|
||||
sqler.add("sex", user.getSex());
|
||||
sqler.add("gender", user.getGender());
|
||||
sqler.add("avatar", user.getAvatar());
|
||||
sqler.add("type", user.getType());
|
||||
sqler.add("ex1", user.getEx1());
|
||||
sqler.add("ex2", user.getEx2());
|
||||
sqler.add("ex3", user.getEx3());
|
||||
sqler.add("ex4", user.getEx4());
|
||||
sqler.add("jotyp", user.getJotyp());
|
||||
sqler.add("arnam", user.getArnam());
|
||||
sqler.add("arcod", user.getArcod());
|
||||
sqler.add("oftim", user.getOftim());
|
||||
jdbcHelper.getTp().update(sqler.getSql(), sqler.getParams());
|
||||
}
|
||||
|
||||
@@ -126,6 +126,7 @@ public class SysUserDao {
|
||||
Usqler sqler = new Usqler("sys_user");
|
||||
sqler.addWhere("id=?", user.getId());
|
||||
sqler.add("name", user.getName());
|
||||
sqler.add("username", user.getUsername());
|
||||
sqler.add("depid", user.getDepid());
|
||||
sqler.add("tier", user.getTier());
|
||||
sqler.add("notes", user.getNotes());
|
||||
@@ -134,15 +135,14 @@ public class SysUserDao {
|
||||
sqler.add("upuid", user.getUpuid());
|
||||
sqler.add("avtag", user.getAvtag());
|
||||
sqler.add("label", user.getLabel());
|
||||
sqler.add("usnam", user.getUsnam());
|
||||
sqler.add("monum", user.getMonum());
|
||||
sqler.add("email", user.getEmail());
|
||||
sqler.add("sex", user.getSex());
|
||||
sqler.add("gender", user.getGender());
|
||||
sqler.add("type", user.getType());
|
||||
sqler.add("ex1", user.getEx1());
|
||||
sqler.add("ex2", user.getEx2());
|
||||
sqler.add("ex3", user.getEx3());
|
||||
sqler.add("ex4", user.getEx4());
|
||||
sqler.add("jotyp", user.getJotyp());
|
||||
sqler.add("arnam", user.getArnam());
|
||||
sqler.add("arcod", user.getArcod());
|
||||
sqler.add("oftim", user.getOftim());
|
||||
jdbcHelper.getTp().update(sqler.getSql(), sqler.getParams());
|
||||
}
|
||||
|
||||
@@ -156,8 +156,8 @@ public class SysUserDao {
|
||||
return jdbcHelper.getTp().queryForObject(sql, Integer.class, monum) > 0;
|
||||
}
|
||||
|
||||
public SysUser findByUsnam(String username) {
|
||||
String sql = "select t.*,o.name depna from sys_user t left join sys_org o on o.id=t.depid where t.usnam = ?";
|
||||
public SysUser findByUsername(String username) {
|
||||
String sql = "select t.*,o.name depna from sys_user t left join sys_org o on o.id=t.depid where t.username = ?";
|
||||
SysUser user;
|
||||
try {
|
||||
user = jdbcHelper.getTp().queryForObject(sql, new BeanPropertyRowMapper<>(SysUser.class), username);
|
||||
|
||||
@@ -52,17 +52,19 @@ public class SysUserService {
|
||||
}
|
||||
// String salt = RandomUtil.randomString(4);
|
||||
// String chatNo = IdUtils.simpleUUID();
|
||||
String id="u"+IdUtils.getSnowflakeNextIdStr();
|
||||
SysUser user = new SysUser()
|
||||
.setId(IdUtils.getSnowflakeNextIdStr())
|
||||
.setId(id)
|
||||
.setName(nickName)
|
||||
.setUsnam(nickName)
|
||||
.setUsername(nickName)
|
||||
// .setChnum(chatNo)
|
||||
// .setGender(GenderEnum.MALE)
|
||||
// .setPortrait(ApiConstant.DEFAULT_PORTRAIT)
|
||||
.setMonum(phone)
|
||||
// .setPacod(password)
|
||||
.setPacod(BCrypt.hashpw(password))
|
||||
.setPassword(BCrypt.hashpw(password))
|
||||
.setAvtag(true)
|
||||
.setDepid("d1000")
|
||||
.setTier("_d1000_"+id+"_")
|
||||
.setCrtim(DateUtils.date());
|
||||
try {
|
||||
userDao.insert(user);
|
||||
@@ -86,7 +88,7 @@ public class SysUserService {
|
||||
main.setTier(tier + main.getId() + "_");
|
||||
}
|
||||
}
|
||||
main.setPacod(BCrypt.hashpw(main.getPacod()));
|
||||
main.setPassword(BCrypt.hashpw(main.getPassword()));
|
||||
Org org = new Org(main.getId(), main.getName(), 2);
|
||||
orgDao.insert(org);
|
||||
userDao.insert(main);
|
||||
|
||||
+2
-2
@@ -3,10 +3,10 @@ package vben.base.sys.user.bo;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class IdPacodBo {
|
||||
public class IdPasswordBo {
|
||||
|
||||
public String id;
|
||||
|
||||
public String pacod;
|
||||
public String password;
|
||||
|
||||
}
|
||||
@@ -107,7 +107,7 @@ public class GenUtils
|
||||
// }
|
||||
// // 类型&性别字段设置下拉框
|
||||
// else if (StringUtils.endsWithIgnoreCase(columnName, "type")
|
||||
// || StringUtils.endsWithIgnoreCase(columnName, "sex"))
|
||||
// || StringUtils.endsWithIgnoreCase(columnName, "gender"))
|
||||
// {
|
||||
// column.setHtmlType(GenConstants.HTML_SELECT);
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user