项目初始化
This commit is contained in:
parent
1419a05f01
commit
7ebf02161b
@ -2,6 +2,7 @@ package com.cdzy.staff.component;
|
|||||||
|
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import com.cdzy.staff.model.dto.StaffInfo;
|
import com.cdzy.staff.model.dto.StaffInfo;
|
||||||
|
import com.cdzy.staff.model.entity.EbikeOperatorStaff;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -15,7 +16,8 @@ public class TenantInterceptor implements HandlerInterceptor {
|
|||||||
, @NotNull HttpServletResponse response, @NotNull Object handler) throws Exception {
|
, @NotNull HttpServletResponse response, @NotNull Object handler) throws Exception {
|
||||||
|
|
||||||
//通过 request 去获取租户 ID
|
//通过 request 去获取租户 ID
|
||||||
if (StpUtil.isLogin()) {
|
boolean login = StpUtil.isLogin();
|
||||||
|
if (login) {
|
||||||
Long tenantId = getTenantIdByReuqest(request);
|
Long tenantId = getTenantIdByReuqest(request);
|
||||||
//设置租户ID到 request 的 attribute
|
//设置租户ID到 request 的 attribute
|
||||||
request.setAttribute("tenantId", tenantId);
|
request.setAttribute("tenantId", tenantId);
|
||||||
@ -27,7 +29,7 @@ public class TenantInterceptor implements HandlerInterceptor {
|
|||||||
Long getTenantIdByReuqest(HttpServletRequest request) {
|
Long getTenantIdByReuqest(HttpServletRequest request) {
|
||||||
String token = request.getHeader("Authorization");
|
String token = request.getHeader("Authorization");
|
||||||
String id = (String) StpUtil.getLoginIdByToken(token);
|
String id = (String) StpUtil.getLoginIdByToken(token);
|
||||||
StaffInfo staffDto = (StaffInfo) StpUtil.getSessionByLoginId(id).get(id);
|
EbikeOperatorStaff staffDto = (EbikeOperatorStaff) StpUtil.getSessionByLoginId(id).get(id);
|
||||||
return staffDto.getStaff().getOperatorId();
|
return staffDto.getOperatorId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@ public class EbikeOperatorStaffController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 运营商员工登录。
|
* 运营商员工添加。
|
||||||
*
|
*
|
||||||
* @param staffVo 登录信息
|
* @param staffVo 登录信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
package com.cdzy.staff.model.dto;
|
package com.cdzy.staff.model.dto;
|
||||||
|
|
||||||
import com.cdzy.staff.model.entity.EbikeOperatorStaff;
|
import com.cdzy.staff.model.entity.EbikeOperatorStaff;
|
||||||
import com.cdzy.staff.model.entity.EbikePermission;
|
|
||||||
import com.cdzy.staff.model.entity.EbikeRole;
|
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
|||||||
@ -48,7 +48,13 @@ public class EbikeRole implements Serializable {
|
|||||||
@Column(onUpdateValue = "now()")
|
@Column(onUpdateValue = "now()")
|
||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
@Column(isLogicDelete = true)
|
@Column(onInsertValue = "false")
|
||||||
private Boolean isDeleted;
|
private Boolean sysAdmin;
|
||||||
|
|
||||||
|
@Column(onInsertValue = "false")
|
||||||
|
private Boolean operatorAdmin;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,6 +46,8 @@ public class EbikeOperatorStaffServiceImpl extends ServiceImpl<EbikeOperatorStaf
|
|||||||
throw new EbikeException("密码错误");
|
throw new EbikeException("密码错误");
|
||||||
} else {
|
} else {
|
||||||
StpUtil.login(ebikeOperatorStaff.getStaffId());
|
StpUtil.login(ebikeOperatorStaff.getStaffId());
|
||||||
|
//TODO:查询员工详情填充
|
||||||
|
StpUtil.getSession().set(String.valueOf(ebikeOperatorStaff.getStaffId()), ebikeOperatorStaff);
|
||||||
return StpUtil.getTokenValueByLoginId(ebikeOperatorStaff.getStaffId());
|
return StpUtil.getTokenValueByLoginId(ebikeOperatorStaff.getStaffId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,7 @@ spring:
|
|||||||
sql:
|
sql:
|
||||||
init:
|
init:
|
||||||
platform: postgis
|
platform: postgis
|
||||||
mode: always
|
mode: never
|
||||||
schema-locations: classpath:db/init.sql
|
schema-locations: classpath:db/init.sql
|
||||||
data-locations: classpath:db/data.sql
|
data-locations: classpath:db/data.sql
|
||||||
jackson:
|
jackson:
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
INSERT INTO "public"."ebike_operator" VALUES (311460622768435200, '卓景出行', '四川省成都市西部智谷B区', '15008231529', NULL, '2025-08-09 00:14:44.550027', NULL, NULL, 'f');
|
INSERT INTO "public"."ebike_operator" VALUES (311460622768435200, '卓景出行', '四川省成都市西部智谷B区', '15008231529', NULL, '2025-08-09 00:14:44.550027', NULL, NULL, 'f');
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO "public"."ebike_operator_staff" VALUES (1, 'admin', 'b98b43d0eef6480daf4bdb7793aa8b7d557c85bdac52e4f814c5e9ba424baa6f:mT5Y0iBQJg9YtHUW38whlw==', 312523146360233984, 311460622768435200, 1, NULL, NULL, '2025-08-11 22:38:56.561597', NULL, NULL, 'f', 'mT5Y0iBQJg9YtHUW38whlw==');
|
INSERT INTO "public"."ebike_operator_staff" VALUES (320131029184712704, 'admin', 'b98b43d0eef6480daf4bdb7793aa8b7d557c85bdac52e4f814c5e9ba424baa6f:mT5Y0iBQJg9YtHUW38whlw==', 312523146360233984, 311460622768435200, 1, NULL, NULL, '2025-08-11 22:38:56.561597', NULL, NULL, 'f', 'mT5Y0iBQJg9YtHUW38whlw==');
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO "public"."ebike_role" VALUES (312523146360233984, '超级管理员', 311460622768435200, '系统默认角色', NULL, '2025-08-11 22:36:51.219978', NULL, NULL, 'f', 't', 'f');
|
INSERT INTO "public"."ebike_role" VALUES (312523146360233984, '超级管理员', 311460622768435200, '系统默认角色', NULL, '2025-08-11 22:36:51.219978', NULL, NULL, 'f', 't', 'f');
|
||||||
|
|||||||
24
ebike-staff/src/test/java/com/cdzy/staff/RoleTest.java
Normal file
24
ebike-staff/src/test/java/com/cdzy/staff/RoleTest.java
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package com.cdzy.staff;
|
||||||
|
|
||||||
|
import com.cdzy.common.utils.SHA256WithSaltUtil;
|
||||||
|
import com.cdzy.staff.mapper.EbikeRoleMapper;
|
||||||
|
import com.cdzy.staff.model.entity.EbikeRole;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
@SpringBootTest(classes = EbikeStaffApplication.class)
|
||||||
|
public class RoleTest {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
EbikeRoleMapper roleMapper;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() {
|
||||||
|
EbikeRole role = new EbikeRole();
|
||||||
|
role.setRoleName("role");
|
||||||
|
role.setOperatorId(311460622768435200L);
|
||||||
|
roleMapper.insert(role);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user