项目初始化

This commit is contained in:
attiya 2025-09-01 22:57:47 +08:00
parent 1419a05f01
commit 7ebf02161b
8 changed files with 42 additions and 10 deletions

View File

@ -2,6 +2,7 @@ package com.cdzy.staff.component;
import cn.dev33.satoken.stp.StpUtil;
import com.cdzy.staff.model.dto.StaffInfo;
import com.cdzy.staff.model.entity.EbikeOperatorStaff;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jetbrains.annotations.NotNull;
@ -15,7 +16,8 @@ public class TenantInterceptor implements HandlerInterceptor {
, @NotNull HttpServletResponse response, @NotNull Object handler) throws Exception {
//通过 request 去获取租户 ID
if (StpUtil.isLogin()) {
boolean login = StpUtil.isLogin();
if (login) {
Long tenantId = getTenantIdByReuqest(request);
//设置租户ID到 request attribute
request.setAttribute("tenantId", tenantId);
@ -27,7 +29,7 @@ public class TenantInterceptor implements HandlerInterceptor {
Long getTenantIdByReuqest(HttpServletRequest request) {
String token = request.getHeader("Authorization");
String id = (String) StpUtil.getLoginIdByToken(token);
StaffInfo staffDto = (StaffInfo) StpUtil.getSessionByLoginId(id).get(id);
return staffDto.getStaff().getOperatorId();
EbikeOperatorStaff staffDto = (EbikeOperatorStaff) StpUtil.getSessionByLoginId(id).get(id);
return staffDto.getOperatorId();
}
}

View File

@ -46,7 +46,7 @@ public class EbikeOperatorStaffController {
}
/**
* 运营商员工登录
* 运营商员工添加
*
* @param staffVo 登录信息
* @return 结果

View File

@ -1,8 +1,6 @@
package com.cdzy.staff.model.dto;
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.Data;

View File

@ -48,7 +48,13 @@ public class EbikeRole implements Serializable {
@Column(onUpdateValue = "now()")
private LocalDateTime updateTime;
@Column(isLogicDelete = true)
private Boolean isDeleted;
@Column(onInsertValue = "false")
private Boolean sysAdmin;
@Column(onInsertValue = "false")
private Boolean operatorAdmin;
}

View File

@ -46,6 +46,8 @@ public class EbikeOperatorStaffServiceImpl extends ServiceImpl<EbikeOperatorStaf
throw new EbikeException("密码错误");
} else {
StpUtil.login(ebikeOperatorStaff.getStaffId());
//TODO查询员工详情填充
StpUtil.getSession().set(String.valueOf(ebikeOperatorStaff.getStaffId()), ebikeOperatorStaff);
return StpUtil.getTokenValueByLoginId(ebikeOperatorStaff.getStaffId());
}
}

View File

@ -11,7 +11,7 @@ spring:
sql:
init:
platform: postgis
mode: always
mode: never
schema-locations: classpath:db/init.sql
data-locations: classpath:db/data.sql
jackson:

View File

@ -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_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');

View 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);
}
}