This commit is contained in:
TimSpan 2024-09-05 10:45:50 +08:00
commit 7bf0c49319
38 changed files with 835 additions and 340 deletions

View File

@ -147,6 +147,30 @@
<artifactId>sa-token-redis</artifactId> <artifactId>sa-token-redis</artifactId>
<version>${sa.token.version}</version> <version>${sa.token.version}</version>
</dependency> </dependency>
<!-- Sa-Token 整合 jwt -->
<dependency>
<groupId>cn.dev33</groupId>
<artifactId>sa-token-jwt</artifactId>
<version>${sa.token.version}</version>
<exclusions>
<exclusion>
<groupId>cn.hutool</groupId>
<artifactId>hutool-core</artifactId>
</exclusion>
<exclusion>
<groupId>cn.hutool</groupId>
<artifactId>hutool-crypto</artifactId>
</exclusion>
<exclusion>
<groupId>cn.hutool</groupId>
<artifactId>hutool-json</artifactId>
</exclusion>
<exclusion>
<groupId>cn.hutool</groupId>
<artifactId>hutool-jwt</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- mysql 驱动 注:最新版本的MySQL Connector/J已经迁移到了符合反转DNS规范的Maven坐标 因此您需要按照新的坐标来引用该依赖。根据错误消息中提供的信息将mysql:mysql-connector-java替换为com.mysql:mysql-connector-j版本保持不变。--> <!-- mysql 驱动 注:最新版本的MySQL Connector/J已经迁移到了符合反转DNS规范的Maven坐标 因此您需要按照新的坐标来引用该依赖。根据错误消息中提供的信息将mysql:mysql-connector-java替换为com.mysql:mysql-connector-j版本保持不变。-->
<dependency> <dependency>
<groupId>com.mysql</groupId> <groupId>com.mysql</groupId>

View File

@ -0,0 +1,28 @@
package com.changhu.common.annotation;
import com.changhu.enums.ClientType;
import org.springframework.web.bind.annotation.RestController;
import java.lang.annotation.*;
/**
* @author 20252
* @createTime 2024/9/4 下午4:01
* @desc CheckClientType...
*/
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@RestController
public @interface CheckClientType {
/**
* 是否需要校验客户端类型
*/
boolean value() default true;
/**
* 需要的客户端类型
*/
ClientType clientType() default ClientType.NONE;
}

View File

@ -1,5 +1,6 @@
package com.changhu.common.utils; package com.changhu.common.utils;
import cn.dev33.satoken.stp.SaLoginConfig;
import cn.dev33.satoken.stp.SaTokenInfo; import cn.dev33.satoken.stp.SaTokenInfo;
import cn.dev33.satoken.stp.StpUtil; import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
@ -7,6 +8,7 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil; import cn.hutool.crypto.SecureUtil;
import com.changhu.common.enums.ResultCode; import com.changhu.common.enums.ResultCode;
import com.changhu.common.exception.MessageException; import com.changhu.common.exception.MessageException;
import com.changhu.enums.ClientType;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.util.Optional; import java.util.Optional;
@ -43,6 +45,29 @@ public class UserUtil {
return getTokenInfo(); return getTokenInfo();
} }
public static SaTokenInfo loginAndTokenInfo(Long userId, ClientType clientType, Long unitId) {
StpUtil.login(userId, SaLoginConfig.setExtra("clientType", clientType).setExtra("unitId", unitId));
return getTokenInfo();
}
/**
* 获取客户端类型
*/
public static ClientType getClientType() {
Object clientType = StpUtil.getExtra("clientType");
if (clientType instanceof String ct) {
return ClientType.valueOf(ct);
}
return null;
}
/**
* 获取单位id
*/
public static Long getUnitId() {
return Long.parseLong(StpUtil.getExtra("unitId") + "");
}
/** /**
* 用户登出 * 用户登出
*/ */

View File

@ -2,6 +2,7 @@ package com.changhu.config;
import cn.dev33.satoken.interceptor.SaInterceptor; import cn.dev33.satoken.interceptor.SaInterceptor;
import cn.dev33.satoken.stp.StpUtil; import cn.dev33.satoken.stp.StpUtil;
import com.changhu.support.interceptor.ClientTypeInterceptor;
import com.changhu.support.interceptor.JsonBodyInterceptor; import com.changhu.support.interceptor.JsonBodyInterceptor;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -49,6 +50,8 @@ public class WebConfig implements WebMvcConfigurer {
.excludePathPatterns(whiteList); .excludePathPatterns(whiteList);
// 注册jsonBody 拦截器 用于标识是否需要JsonResult返回 // 注册jsonBody 拦截器 用于标识是否需要JsonResult返回
registry.addInterceptor(new JsonBodyInterceptor()); registry.addInterceptor(new JsonBodyInterceptor());
// 注册clientType 拦截器 用于校验当前用户是否匹配操作客户端
registry.addInterceptor(new ClientTypeInterceptor());
} }
@Override @Override

View File

@ -15,6 +15,7 @@ import lombok.Getter;
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum ClientType { public enum ClientType {
NONE("未定义", null),
MANAGEMENT_SUPER("超级后台", ManagementSuperLogin.instance), MANAGEMENT_SUPER("超级后台", ManagementSuperLogin.instance),
MANAGEMENT_POLICE("公安后台", ManagementPoliceUnitLogin.instance), MANAGEMENT_POLICE("公安后台", ManagementPoliceUnitLogin.instance),
MANAGEMENT_SECURITY("保安后台", ManagementSecurityUnitLogin.instance), MANAGEMENT_SECURITY("保安后台", ManagementSecurityUnitLogin.instance),

View File

@ -1,8 +1,8 @@
package com.changhu.enums.handler; package com.changhu.enums.handler;
import cn.dev33.satoken.stp.SaTokenInfo; import cn.dev33.satoken.stp.SaTokenInfo;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.extension.toolkit.Db;
import com.changhu.common.db.enums.IsEnable; import com.changhu.common.db.enums.IsEnable;
import com.changhu.common.enums.ResultCode; import com.changhu.common.enums.ResultCode;
import com.changhu.common.exception.MessageException; import com.changhu.common.exception.MessageException;
@ -10,10 +10,9 @@ import com.changhu.common.pojo.vo.TokenInfo;
import com.changhu.common.utils.RsaUtil; import com.changhu.common.utils.RsaUtil;
import com.changhu.common.utils.UserUtil; import com.changhu.common.utils.UserUtil;
import com.changhu.common.utils.ValidatorUtil; import com.changhu.common.utils.ValidatorUtil;
import com.changhu.enums.ClientType;
import com.changhu.module.management.pojo.entity.ManagementPoliceUnitUser; import com.changhu.module.management.pojo.entity.ManagementPoliceUnitUser;
import com.changhu.module.management.pojo.entity.PoliceUnit; import com.changhu.module.management.pojo.entity.PoliceUnit;
import com.changhu.module.management.service.ManagementPoliceUnitUserService;
import com.changhu.module.management.service.PoliceUnitService;
import com.changhu.pojo.params.ManagementPoliceUnitLoginParams; import com.changhu.pojo.params.ManagementPoliceUnitLoginParams;
import com.changhu.support.mybatisplus.pojo.entity.BaseEntity; import com.changhu.support.mybatisplus.pojo.entity.BaseEntity;
@ -24,9 +23,6 @@ import com.changhu.support.mybatisplus.pojo.entity.BaseEntity;
*/ */
public class ManagementPoliceUnitLogin extends AbstractLoginHandler { public class ManagementPoliceUnitLogin extends AbstractLoginHandler {
private final ManagementPoliceUnitUserService policeUnitUserService = SpringUtil.getBean(ManagementPoliceUnitUserService.class);
private final PoliceUnitService policeUnitService = SpringUtil.getBean(PoliceUnitService.class);
public static final ManagementPoliceUnitLogin instance = new ManagementPoliceUnitLogin(); public static final ManagementPoliceUnitLogin instance = new ManagementPoliceUnitLogin();
private ManagementPoliceUnitLogin() { private ManagementPoliceUnitLogin() {
@ -42,7 +38,7 @@ public class ManagementPoliceUnitLogin extends AbstractLoginHandler {
String password = RsaUtil.decrypt(managementPoliceUnitLoginParams.getPassword()); String password = RsaUtil.decrypt(managementPoliceUnitLoginParams.getPassword());
//查看 账号/手机号 是否存在 //查看 账号/手机号 是否存在
ManagementPoliceUnitUser managementPoliceUnitUser = policeUnitUserService.lambdaQuery() ManagementPoliceUnitUser managementPoliceUnitUser = Db.lambdaQuery(ManagementPoliceUnitUser.class)
.eq(ManagementPoliceUnitUser::getAccount, accountOrTelephone) .eq(ManagementPoliceUnitUser::getAccount, accountOrTelephone)
.or() .or()
.eq(ManagementPoliceUnitUser::getTelephone, accountOrTelephone) .eq(ManagementPoliceUnitUser::getTelephone, accountOrTelephone)
@ -55,7 +51,7 @@ public class ManagementPoliceUnitLogin extends AbstractLoginHandler {
} }
//判断单位是否禁用 //判断单位是否禁用
IsEnable unitEnable = policeUnitService.lambdaQuery() IsEnable unitEnable = Db.lambdaQuery(PoliceUnit.class)
.eq(BaseEntity::getSnowFlakeId, managementPoliceUnitUser.getPoliceUnitId()) .eq(BaseEntity::getSnowFlakeId, managementPoliceUnitUser.getPoliceUnitId())
.oneOpt() .oneOpt()
.map(PoliceUnit::getIsEnable) .map(PoliceUnit::getIsEnable)
@ -71,7 +67,11 @@ public class ManagementPoliceUnitLogin extends AbstractLoginHandler {
} }
//登录 //登录
SaTokenInfo saTokenInfo = UserUtil.loginAndTokenInfo(managementPoliceUnitUser.getSnowFlakeId()); SaTokenInfo saTokenInfo = UserUtil.loginAndTokenInfo(
managementPoliceUnitUser.getSnowFlakeId(),
ClientType.MANAGEMENT_POLICE,
managementPoliceUnitUser.getPoliceUnitId()
);
//返回token //返回token
return new TokenInfo(saTokenInfo.getTokenName(), saTokenInfo.getTokenValue()); return new TokenInfo(saTokenInfo.getTokenName(), saTokenInfo.getTokenValue());
} }

View File

@ -1,8 +1,8 @@
package com.changhu.enums.handler; package com.changhu.enums.handler;
import cn.dev33.satoken.stp.SaTokenInfo; import cn.dev33.satoken.stp.SaTokenInfo;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.extension.toolkit.Db;
import com.changhu.common.db.enums.IsEnable; import com.changhu.common.db.enums.IsEnable;
import com.changhu.common.enums.ResultCode; import com.changhu.common.enums.ResultCode;
import com.changhu.common.exception.MessageException; import com.changhu.common.exception.MessageException;
@ -10,11 +10,9 @@ import com.changhu.common.pojo.vo.TokenInfo;
import com.changhu.common.utils.RsaUtil; import com.changhu.common.utils.RsaUtil;
import com.changhu.common.utils.UserUtil; import com.changhu.common.utils.UserUtil;
import com.changhu.common.utils.ValidatorUtil; import com.changhu.common.utils.ValidatorUtil;
import com.changhu.enums.ClientType;
import com.changhu.module.management.pojo.entity.ManagementSecurityUnitUser; import com.changhu.module.management.pojo.entity.ManagementSecurityUnitUser;
import com.changhu.module.management.pojo.entity.PoliceUnit;
import com.changhu.module.management.pojo.entity.SecurityUnit; import com.changhu.module.management.pojo.entity.SecurityUnit;
import com.changhu.module.management.service.ManagementSecurityUnitUserService;
import com.changhu.module.management.service.SecurityUnitService;
import com.changhu.pojo.params.ManagementSecurityUnitLoginParams; import com.changhu.pojo.params.ManagementSecurityUnitLoginParams;
import com.changhu.support.mybatisplus.pojo.entity.BaseEntity; import com.changhu.support.mybatisplus.pojo.entity.BaseEntity;
@ -25,9 +23,6 @@ import com.changhu.support.mybatisplus.pojo.entity.BaseEntity;
*/ */
public class ManagementSecurityUnitLogin extends AbstractLoginHandler { public class ManagementSecurityUnitLogin extends AbstractLoginHandler {
private final ManagementSecurityUnitUserService securityUnitUserService = SpringUtil.getBean(ManagementSecurityUnitUserService.class);
private final SecurityUnitService securityUnitService = SpringUtil.getBean(SecurityUnitService.class);
public static final ManagementSecurityUnitLogin instance = new ManagementSecurityUnitLogin(); public static final ManagementSecurityUnitLogin instance = new ManagementSecurityUnitLogin();
private ManagementSecurityUnitLogin() { private ManagementSecurityUnitLogin() {
@ -42,7 +37,7 @@ public class ManagementSecurityUnitLogin extends AbstractLoginHandler {
String password = RsaUtil.decrypt(loginParams.getPassword()); String password = RsaUtil.decrypt(loginParams.getPassword());
//查看 账号/手机号 是否存在 //查看 账号/手机号 是否存在
ManagementSecurityUnitUser managementSecurityUnitUser = securityUnitUserService.lambdaQuery() ManagementSecurityUnitUser managementSecurityUnitUser = Db.lambdaQuery(ManagementSecurityUnitUser.class)
.eq(ManagementSecurityUnitUser::getAccount, accountOrTelephone) .eq(ManagementSecurityUnitUser::getAccount, accountOrTelephone)
.or() .or()
.eq(ManagementSecurityUnitUser::getTelephone, accountOrTelephone) .eq(ManagementSecurityUnitUser::getTelephone, accountOrTelephone)
@ -55,7 +50,7 @@ public class ManagementSecurityUnitLogin extends AbstractLoginHandler {
} }
//判断单位是否禁用 //判断单位是否禁用
IsEnable unitEnable = securityUnitService.lambdaQuery() IsEnable unitEnable = Db.lambdaQuery(SecurityUnit.class)
.eq(BaseEntity::getSnowFlakeId, managementSecurityUnitUser.getSecurityUnitId()) .eq(BaseEntity::getSnowFlakeId, managementSecurityUnitUser.getSecurityUnitId())
.oneOpt() .oneOpt()
.map(SecurityUnit::getIsEnable) .map(SecurityUnit::getIsEnable)
@ -70,7 +65,11 @@ public class ManagementSecurityUnitLogin extends AbstractLoginHandler {
} }
//登录 //登录
SaTokenInfo saTokenInfo = UserUtil.loginAndTokenInfo(managementSecurityUnitUser.getSnowFlakeId()); SaTokenInfo saTokenInfo = UserUtil.loginAndTokenInfo(
managementSecurityUnitUser.getSnowFlakeId(),
ClientType.MANAGEMENT_SECURITY,
managementSecurityUnitUser.getSecurityUnitId()
);
//返回token //返回token
return new TokenInfo(saTokenInfo.getTokenName(), saTokenInfo.getTokenValue()); return new TokenInfo(saTokenInfo.getTokenName(), saTokenInfo.getTokenValue());
} }

View File

@ -1,16 +1,16 @@
package com.changhu.enums.handler; package com.changhu.enums.handler;
import cn.dev33.satoken.stp.SaTokenInfo; import cn.dev33.satoken.stp.SaTokenInfo;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.extension.toolkit.Db;
import com.changhu.common.enums.ResultCode; import com.changhu.common.enums.ResultCode;
import com.changhu.common.exception.MessageException; import com.changhu.common.exception.MessageException;
import com.changhu.common.pojo.vo.TokenInfo; import com.changhu.common.pojo.vo.TokenInfo;
import com.changhu.common.utils.RsaUtil; import com.changhu.common.utils.RsaUtil;
import com.changhu.common.utils.UserUtil; import com.changhu.common.utils.UserUtil;
import com.changhu.common.utils.ValidatorUtil; import com.changhu.common.utils.ValidatorUtil;
import com.changhu.enums.ClientType;
import com.changhu.module.management.pojo.entity.ManagementSuperUser; import com.changhu.module.management.pojo.entity.ManagementSuperUser;
import com.changhu.module.management.service.ManagementSuperUserService;
import com.changhu.pojo.params.ManagementSuperLoginParams; import com.changhu.pojo.params.ManagementSuperLoginParams;
/** /**
@ -20,8 +20,6 @@ import com.changhu.pojo.params.ManagementSuperLoginParams;
*/ */
public class ManagementSuperLogin extends AbstractLoginHandler { public class ManagementSuperLogin extends AbstractLoginHandler {
private static final ManagementSuperUserService managementSuperUserService = SpringUtil.getBean(ManagementSuperUserService.class);
public static final ManagementSuperLogin instance = new ManagementSuperLogin(); public static final ManagementSuperLogin instance = new ManagementSuperLogin();
private ManagementSuperLogin() { private ManagementSuperLogin() {
@ -35,7 +33,7 @@ public class ManagementSuperLogin extends AbstractLoginHandler {
String password = RsaUtil.decrypt(loginParams.getPassword()); String password = RsaUtil.decrypt(loginParams.getPassword());
//用户是否存在 //用户是否存在
ManagementSuperUser user = managementSuperUserService.lambdaQuery() ManagementSuperUser user = Db.lambdaQuery(ManagementSuperUser.class)
.eq(ManagementSuperUser::getTelephone, telephone) .eq(ManagementSuperUser::getTelephone, telephone)
.oneOpt() .oneOpt()
.orElseThrow(() -> new MessageException(ResultCode.USER_NOT_FOUND)); .orElseThrow(() -> new MessageException(ResultCode.USER_NOT_FOUND));
@ -45,7 +43,10 @@ public class ManagementSuperLogin extends AbstractLoginHandler {
throw new MessageException(ResultCode.PASSWORD_ERROR); throw new MessageException(ResultCode.PASSWORD_ERROR);
} }
//登录 //登录
SaTokenInfo saTokenInfo = UserUtil.loginAndTokenInfo(user.getSnowFlakeId()); SaTokenInfo saTokenInfo = UserUtil.loginAndTokenInfo(
user.getSnowFlakeId(),
ClientType.MANAGEMENT_SUPER,
null);
//返回token //返回token
return new TokenInfo(saTokenInfo.getTokenName(), saTokenInfo.getTokenValue()); return new TokenInfo(saTokenInfo.getTokenName(), saTokenInfo.getTokenValue());
} }

View File

@ -2,9 +2,7 @@ package com.changhu.module.management.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.changhu.common.annotation.JsonBody; import com.changhu.common.annotation.JsonBody;
import com.changhu.common.pojo.vo.TreeNodeVo; import com.changhu.common.exception.MessageException;
import com.changhu.common.utils.JavaClassToTsUtil;
import com.changhu.mapper.AdministrativeDivisionMapper;
import com.changhu.module.management.pojo.params.EnterprisesUnitSaveOrUpdateParams; import com.changhu.module.management.pojo.params.EnterprisesUnitSaveOrUpdateParams;
import com.changhu.module.management.pojo.queryParams.EnterprisesUnitPagerQueryParams; import com.changhu.module.management.pojo.queryParams.EnterprisesUnitPagerQueryParams;
import com.changhu.module.management.pojo.vo.EnterprisesUnitPagerVo; import com.changhu.module.management.pojo.vo.EnterprisesUnitPagerVo;
@ -14,12 +12,11 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;
/** /**
* @author 20252 * @author 20252
* @createTime 2024/9/3 上午10:17 * @createTime 2024/9/3 上午10:17
@ -45,8 +42,13 @@ public class EnterprisesUnitController {
enterprisesUnitService.saveOrUpdate(params); enterprisesUnitService.saveOrUpdate(params);
} }
public static void main(String[] args) { @Operation(summary = "根据id删除")
System.out.println(JavaClassToTsUtil.parse(EnterprisesUnitSaveOrUpdateParams.class)); @DeleteMapping("/deleteById")
public void deleteById(@RequestBody Long enterprisesUnitId) {
boolean b = enterprisesUnitService.removeById(enterprisesUnitId);
if (!b) {
throw new MessageException();
}
} }
} }

View File

@ -1,14 +1,54 @@
package com.changhu.module.management.controller; package com.changhu.module.management.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.changhu.common.annotation.CheckClientType;
import com.changhu.common.annotation.JsonBody; import com.changhu.common.annotation.JsonBody;
import com.changhu.enums.ClientType;
import com.changhu.module.management.pojo.params.ManagementPoliceUserSaveOrUpdateParams;
import com.changhu.module.management.pojo.queryParams.ManagementPoliceUnitUserPagerQueryParams;
import com.changhu.module.management.pojo.vo.ManagementPoliceUnitUserPagerVo;
import com.changhu.module.management.service.ManagementPoliceUnitUserService;
import com.changhu.support.mybatisplus.pojo.params.PageParams;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
/** /**
* @author 20252 * @author 20252
* @createTime 2024/9/3 上午10:21 * @createTime 2024/9/3 上午10:21
* @desc ManagementPoliceUnitUserController... * @desc ManagementPoliceUnitUserController...
*/ */
@Tag(name = "后台-公安用户")
@JsonBody @JsonBody
@CheckClientType(clientType = ClientType.MANAGEMENT_POLICE)
@RequestMapping("/managementPoliceUnitUser") @RequestMapping("/managementPoliceUnitUser")
public class ManagementPoliceUnitUserController { public class ManagementPoliceUnitUserController {
@Autowired
private ManagementPoliceUnitUserService managementPoliceUnitUserService;
@Operation(summary = "新增或保存")
@PostMapping("/saveOrUpdate")
public void saveOrUpdate(@RequestBody @Valid ManagementPoliceUserSaveOrUpdateParams params) {
managementPoliceUnitUserService.saveOrUpdate(params);
}
@Operation(summary = "分页查询")
@PostMapping("/pager")
public Page<ManagementPoliceUnitUserPagerVo> pager(@RequestBody PageParams<ManagementPoliceUnitUserPagerQueryParams, ManagementPoliceUnitUserPagerVo> queryParams) {
return managementPoliceUnitUserService.pager(queryParams);
}
@Operation(summary = "根据id删除")
@PostMapping("/deleteById")
public void deleteById(@RequestParam @Schema(description = "后台公安用户id") Long managementPoliceUnitUserId) {
managementPoliceUnitUserService.deleteById(managementPoliceUnitUserId);
}
} }

View File

@ -1,19 +1,20 @@
package com.changhu.module.management.controller; package com.changhu.module.management.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.changhu.common.annotation.CheckClientType;
import com.changhu.common.annotation.JsonBody; import com.changhu.common.annotation.JsonBody;
import com.changhu.enums.ClientType;
import com.changhu.module.management.pojo.params.ManagementSecurityUnitUserSaveOrUpdateParams; import com.changhu.module.management.pojo.params.ManagementSecurityUnitUserSaveOrUpdateParams;
import com.changhu.module.management.pojo.queryParams.ManagementSecurityUnitUserPagerQueryParams; import com.changhu.module.management.pojo.queryParams.ManagementSecurityUnitUserPagerQueryParams;
import com.changhu.module.management.pojo.vo.ManagementSecurityUnitUserPagerVo; import com.changhu.module.management.pojo.vo.ManagementSecurityUnitUserPagerVo;
import com.changhu.module.management.service.ManagementSecurityUnitUserService; import com.changhu.module.management.service.ManagementSecurityUnitUserService;
import com.changhu.support.mybatisplus.pojo.params.PageParams; import com.changhu.support.mybatisplus.pojo.params.PageParams;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
/** /**
* @author 20252 * @author 20252
@ -23,6 +24,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
@Tag(name = "后台-保安用户") @Tag(name = "后台-保安用户")
@JsonBody @JsonBody
@RequestMapping("/managementSecurityUnitUser") @RequestMapping("/managementSecurityUnitUser")
@CheckClientType(clientType = ClientType.MANAGEMENT_SECURITY)
public class ManagementSecurityUnitUserController { public class ManagementSecurityUnitUserController {
@Autowired @Autowired
@ -39,4 +41,9 @@ public class ManagementSecurityUnitUserController {
public Page<ManagementSecurityUnitUserPagerVo> pager(@RequestBody PageParams<ManagementSecurityUnitUserPagerQueryParams, ManagementSecurityUnitUserPagerVo> queryParams) { public Page<ManagementSecurityUnitUserPagerVo> pager(@RequestBody PageParams<ManagementSecurityUnitUserPagerQueryParams, ManagementSecurityUnitUserPagerVo> queryParams) {
return managementSecurityUnitUserService.pager(queryParams); return managementSecurityUnitUserService.pager(queryParams);
} }
@DeleteMapping("/deleteById")
public void deleteById(@RequestParam @Schema(description = "后台保安用户id") Long managementSecurityUnitUserId) {
managementSecurityUnitUserService.deleteById(managementSecurityUnitUserId);
}
} }

View File

@ -12,7 +12,6 @@ import com.changhu.common.exception.MessageException;
import com.changhu.common.utils.UserUtil; import com.changhu.common.utils.UserUtil;
import com.changhu.module.management.pojo.entity.ManagementPoliceUnitUser; import com.changhu.module.management.pojo.entity.ManagementPoliceUnitUser;
import com.changhu.module.management.pojo.entity.PoliceUnit; import com.changhu.module.management.pojo.entity.PoliceUnit;
import com.changhu.module.management.pojo.entity.SecurityUnit;
import com.changhu.module.management.pojo.vo.UnitCheckStatusVo; import com.changhu.module.management.pojo.vo.UnitCheckStatusVo;
import com.changhu.module.management.service.ManagementPoliceUnitUserService; import com.changhu.module.management.service.ManagementPoliceUnitUserService;
import com.changhu.module.management.service.PoliceUnitService; import com.changhu.module.management.service.PoliceUnitService;

View File

@ -1,8 +1,14 @@
package com.changhu.module.management.mapper; package com.changhu.module.management.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.changhu.module.management.pojo.entity.ManagementPoliceUnitUser; import com.changhu.module.management.pojo.entity.ManagementPoliceUnitUser;
import com.changhu.module.management.pojo.queryParams.ManagementPoliceUnitUserPagerQueryParams;
import com.changhu.module.management.pojo.vo.ManagementPoliceUnitUserPagerVo;
import com.changhu.support.mybatisplus.annotation.DataScope;
import com.changhu.support.mybatisplus.handler.permission.management.ManagementPoliceUnitUserPagerPermissionHandler;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/** /**
* management_police_user (后台-公安单位用户表) 固化类 * management_police_user (后台-公安单位用户表) 固化类
@ -12,4 +18,14 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface ManagementPoliceUnitUserMapper extends BaseMapper<ManagementPoliceUnitUser> { public interface ManagementPoliceUnitUserMapper extends BaseMapper<ManagementPoliceUnitUser> {
/**
* 分页查询
*
* @param page 分页参数
* @param params 查询参数
* @return 结果
*/
@DataScope(permissionHandler = ManagementPoliceUnitUserPagerPermissionHandler.class)
Page<ManagementPoliceUnitUserPagerVo> pager(@Param("page") Page<ManagementPoliceUnitUserPagerVo> page,
@Param("params") ManagementPoliceUnitUserPagerQueryParams params);
} }

View File

@ -1,18 +1,18 @@
package com.changhu.module.management.pojo.entity; package com.changhu.module.management.pojo.entity;
import java.io.Serial;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.Fastjson2TypeHandler; import com.baomidou.mybatisplus.extension.handlers.Fastjson2TypeHandler;
import com.changhu.module.management.pojo.model.ContactPersonInfo; import com.changhu.module.management.pojo.model.ContactPersonInfo;
import com.changhu.support.mybatisplus.pojo.entity.BaseEntity; import com.changhu.support.mybatisplus.pojo.entity.BaseEntity;
import lombok.Data;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
import lombok.EqualsAndHashCode;
import com.baomidou.mybatisplus.annotation.TableName; import java.io.Serial;
import java.io.Serializable;
/** /**

View File

@ -0,0 +1,39 @@
package com.changhu.module.management.pojo.params;
import com.changhu.common.db.enums.IsEnable;
import com.changhu.common.db.enums.Sex;
import com.changhu.common.validator.annotation.IsMobile;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
/**
* @author 20252
* @createTime 2024/9/4 下午3:04
* @desc ManagementPoliceUserSaveOrUpdateParams...
*/
@Data
public class ManagementPoliceUserSaveOrUpdateParams {
@Schema(description = "id")
private Long snowFlakeId;
@NotNull(message = "名称不能为空")
@Schema(description = "名称")
private String name;
@NotNull(message = "性别不能为空")
@Schema(description = "性别")
private Sex sex;
@IsMobile
@NotBlank(message = "手机号不能为空")
@Schema(description = "手机号")
private String telephone;
@NotNull(message = "是否启用不能为空")
@Schema(description = "是否启用")
private IsEnable isEnable;
}

View File

@ -3,15 +3,11 @@ package com.changhu.module.management.pojo.params;
import com.changhu.common.db.enums.IsEnable; import com.changhu.common.db.enums.IsEnable;
import com.changhu.common.db.enums.Sex; import com.changhu.common.db.enums.Sex;
import com.changhu.common.validator.annotation.IsMobile; import com.changhu.common.validator.annotation.IsMobile;
import com.changhu.module.management.pojo.model.ContactPersonInfo;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* @author 20252 * @author 20252
* @createTime 2024/9/3 上午10:26 * @createTime 2024/9/3 上午10:26

View File

@ -0,0 +1,20 @@
package com.changhu.module.management.pojo.queryParams;
import com.changhu.common.db.enums.Sex;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* @author 20252
* @createTime 2024/9/4 下午3:22
* @desc ManagementPoliceUnitUserPagerQueryParams...
*/
@Data
public class ManagementPoliceUnitUserPagerQueryParams {
@Schema(description = "名字")
private String name;
@Schema(description = "手机号")
private String telephone;
@Schema(description = "性别")
private Sex sex;
}

View File

@ -0,0 +1,46 @@
package com.changhu.module.management.pojo.vo;
import com.changhu.common.db.enums.IsEnable;
import com.changhu.common.db.enums.IsOrNot;
import com.changhu.common.db.enums.Sex;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @author 20252
* @createTime 2024/9/3 上午10:59
* @desc ManagementSecurityUnitUserPagerVo...
*/
@Data
public class ManagementPoliceUnitUserPagerVo {
@Schema(description = "id")
private Long snowFlakeId;
@Schema(description = "名称")
private String name;
@Schema(description = "性别")
private Sex sex;
@Schema(description = "性别")
private String account;
@Schema(description = "手机号")
private String telephone;
@Schema(description = "是否启用")
private IsEnable isEnable;
@Schema(description = "是否是超管")
private IsOrNot isAdmin;
@Schema(description = "创建人")
private String createUserName;
@Schema(description = "创建时间")
private LocalDateTime createTime;
}

View File

@ -1,7 +1,12 @@
package com.changhu.module.management.service; package com.changhu.module.management.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.changhu.module.management.pojo.entity.ManagementPoliceUnitUser; import com.changhu.module.management.pojo.entity.ManagementPoliceUnitUser;
import com.changhu.module.management.pojo.params.ManagementPoliceUserSaveOrUpdateParams;
import com.changhu.module.management.pojo.queryParams.ManagementPoliceUnitUserPagerQueryParams;
import com.changhu.module.management.pojo.vo.ManagementPoliceUnitUserPagerVo;
import com.changhu.support.mybatisplus.pojo.params.PageParams;
/** /**
* management_police_user (后台-公安单位用户表) 服务类 * management_police_user (后台-公安单位用户表) 服务类
@ -10,4 +15,25 @@ import com.changhu.module.management.pojo.entity.ManagementPoliceUnitUser;
*/ */
public interface ManagementPoliceUnitUserService extends IService<ManagementPoliceUnitUser> { public interface ManagementPoliceUnitUserService extends IService<ManagementPoliceUnitUser> {
/**
* 新增或者保持
*
* @param params 参数
*/
void saveOrUpdate(ManagementPoliceUserSaveOrUpdateParams params);
/**
* 分页查询
*
* @param queryParams 查询参数
* @return 结果
*/
Page<ManagementPoliceUnitUserPagerVo> pager(PageParams<ManagementPoliceUnitUserPagerQueryParams, ManagementPoliceUnitUserPagerVo> queryParams);
/**
* 根据id删除
*
* @param managementPoliceUnitUserId 后台公安用户id
*/
void deleteById(Long managementPoliceUnitUserId);
} }

View File

@ -29,4 +29,11 @@ public interface ManagementSecurityUnitUserService extends IService<ManagementSe
* @return 分页结果 * @return 分页结果
*/ */
Page<ManagementSecurityUnitUserPagerVo> pager(PageParams<ManagementSecurityUnitUserPagerQueryParams, ManagementSecurityUnitUserPagerVo> queryParams); Page<ManagementSecurityUnitUserPagerVo> pager(PageParams<ManagementSecurityUnitUserPagerQueryParams, ManagementSecurityUnitUserPagerVo> queryParams);
/**
* 根据id删除
*
* @param managementSecurityUnitUserId 后台保安用户id
*/
void deleteById(Long managementSecurityUnitUserId);
} }

View File

@ -1,10 +1,26 @@
package com.changhu.module.management.service.impl; package com.changhu.module.management.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.changhu.common.enums.ResultCode;
import com.changhu.common.exception.MessageException;
import com.changhu.common.utils.UserUtil;
import com.changhu.enums.ClientType;
import com.changhu.module.management.mapper.ManagementPoliceUnitUserMapper; import com.changhu.module.management.mapper.ManagementPoliceUnitUserMapper;
import com.changhu.module.management.pojo.entity.ManagementPoliceUnitUser; import com.changhu.module.management.pojo.entity.ManagementPoliceUnitUser;
import com.changhu.module.management.pojo.params.ManagementPoliceUserSaveOrUpdateParams;
import com.changhu.module.management.pojo.queryParams.ManagementPoliceUnitUserPagerQueryParams;
import com.changhu.module.management.pojo.vo.ManagementPoliceUnitUserPagerVo;
import com.changhu.module.management.service.ManagementPoliceUnitUserService; import com.changhu.module.management.service.ManagementPoliceUnitUserService;
import com.changhu.support.mybatisplus.pojo.entity.BaseEntity;
import com.changhu.support.mybatisplus.pojo.params.PageParams;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/** /**
* management_police_user (后台-公安单位用户表) 服务实现类 * management_police_user (后台-公安单位用户表) 服务实现类
@ -14,4 +30,57 @@ import org.springframework.stereotype.Service;
@Service @Service
public class ManagementPoliceUnitUserServiceImpl extends ServiceImpl<ManagementPoliceUnitUserMapper, ManagementPoliceUnitUser> implements ManagementPoliceUnitUserService { public class ManagementPoliceUnitUserServiceImpl extends ServiceImpl<ManagementPoliceUnitUserMapper, ManagementPoliceUnitUser> implements ManagementPoliceUnitUserService {
@Transactional(rollbackFor = Exception.class)
@Override
public void saveOrUpdate(ManagementPoliceUserSaveOrUpdateParams params) {
//查看手机号是否存在
boolean exists = this.lambdaQuery()
.eq(ManagementPoliceUnitUser::getTelephone, params.getTelephone())
.exists();
if (exists) {
throw new MessageException("该手机号已存在");
}
ManagementPoliceUnitUser managementPoliceUnitUser = BeanUtil.copyProperties(params, ManagementPoliceUnitUser.class);
//新增 补全信息
if (managementPoliceUnitUser.getSnowFlakeId() == null) {
String account = RandomUtil.randomString(6);
boolean accExits = this.lambdaQuery().eq(ManagementPoliceUnitUser::getAccount, account).exists();
if (accExits) {
throw new MessageException("生成的账号已存在 请重新提交生成");
}
//生成账号
managementPoliceUnitUser.setAccount(account);
//补全单位
managementPoliceUnitUser.setPoliceUnitId(UserUtil.getUnitId());
//生成密码
String passWordEncrypt = UserUtil.passWordEncrypt(UserUtil.DEFAULT_PASSWORD);
List<String> saltAndPassWord = StrUtil.split(passWordEncrypt, "$$");
managementPoliceUnitUser.setSalt(saltAndPassWord.get(0));
managementPoliceUnitUser.setPassword(saltAndPassWord.get(1));
}
this.saveOrUpdate(managementPoliceUnitUser);
}
@Override
public Page<ManagementPoliceUnitUserPagerVo> pager(PageParams<ManagementPoliceUnitUserPagerQueryParams, ManagementPoliceUnitUserPagerVo> queryParams) {
return baseMapper.pager(queryParams.getPage(), queryParams.getParams());
}
@Override
public void deleteById(Long managementPoliceUnitUserId) {
Long unitId = UserUtil.getUnitId();
Long l = this.lambdaQuery()
.eq(BaseEntity::getSnowFlakeId, managementPoliceUnitUserId)
.oneOpt()
.map(ManagementPoliceUnitUser::getPoliceUnitId)
.orElseThrow(() -> new MessageException(ResultCode.USER_NOT_FOUND));
if (!unitId.equals(l)) {
throw new MessageException("单位不匹配,无权操作");
}
boolean b = this.removeById(managementPoliceUnitUserId);
if (!b) {
throw new MessageException();
}
}
} }

View File

@ -5,14 +5,18 @@ import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.changhu.common.enums.ResultCode;
import com.changhu.common.exception.MessageException; import com.changhu.common.exception.MessageException;
import com.changhu.common.utils.UserUtil; import com.changhu.common.utils.UserUtil;
import com.changhu.enums.ClientType;
import com.changhu.module.management.mapper.ManagementSecurityUnitUserMapper; import com.changhu.module.management.mapper.ManagementSecurityUnitUserMapper;
import com.changhu.module.management.pojo.entity.ManagementPoliceUnitUser;
import com.changhu.module.management.pojo.entity.ManagementSecurityUnitUser; import com.changhu.module.management.pojo.entity.ManagementSecurityUnitUser;
import com.changhu.module.management.pojo.params.ManagementSecurityUnitUserSaveOrUpdateParams; import com.changhu.module.management.pojo.params.ManagementSecurityUnitUserSaveOrUpdateParams;
import com.changhu.module.management.pojo.queryParams.ManagementSecurityUnitUserPagerQueryParams; import com.changhu.module.management.pojo.queryParams.ManagementSecurityUnitUserPagerQueryParams;
import com.changhu.module.management.pojo.vo.ManagementSecurityUnitUserPagerVo; import com.changhu.module.management.pojo.vo.ManagementSecurityUnitUserPagerVo;
import com.changhu.module.management.service.ManagementSecurityUnitUserService; import com.changhu.module.management.service.ManagementSecurityUnitUserService;
import com.changhu.support.mybatisplus.pojo.entity.BaseEntity;
import com.changhu.support.mybatisplus.pojo.params.PageParams; import com.changhu.support.mybatisplus.pojo.params.PageParams;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -37,6 +41,7 @@ public class ManagementSecurityUnitUserServiceImpl extends ServiceImpl<Managemen
if (exists) { if (exists) {
throw new MessageException("该手机号已存在"); throw new MessageException("该手机号已存在");
} }
ManagementSecurityUnitUser managementSecurityUnitUser = BeanUtil.copyProperties(saveOrUpdateParams, ManagementSecurityUnitUser.class); ManagementSecurityUnitUser managementSecurityUnitUser = BeanUtil.copyProperties(saveOrUpdateParams, ManagementSecurityUnitUser.class);
//新增 需要补全一些信息 //新增 需要补全一些信息
if (managementSecurityUnitUser.getSnowFlakeId() == null) { if (managementSecurityUnitUser.getSnowFlakeId() == null) {
@ -49,6 +54,11 @@ public class ManagementSecurityUnitUserServiceImpl extends ServiceImpl<Managemen
} }
//生成账号 //生成账号
managementSecurityUnitUser.setAccount(account); managementSecurityUnitUser.setAccount(account);
if (!ClientType.MANAGEMENT_SECURITY.equals(UserUtil.getClientType())) {
throw new MessageException("客户端类型不对");
}
//补全单位
managementSecurityUnitUser.setSecurityUnitId(UserUtil.getUnitId());
//生成密码 //生成密码
String passWordEncrypt = UserUtil.passWordEncrypt(UserUtil.DEFAULT_PASSWORD); String passWordEncrypt = UserUtil.passWordEncrypt(UserUtil.DEFAULT_PASSWORD);
List<String> saltAndPassWord = StrUtil.split(passWordEncrypt, "$$"); List<String> saltAndPassWord = StrUtil.split(passWordEncrypt, "$$");
@ -62,4 +72,21 @@ public class ManagementSecurityUnitUserServiceImpl extends ServiceImpl<Managemen
public Page<ManagementSecurityUnitUserPagerVo> pager(PageParams<ManagementSecurityUnitUserPagerQueryParams, ManagementSecurityUnitUserPagerVo> queryParams) { public Page<ManagementSecurityUnitUserPagerVo> pager(PageParams<ManagementSecurityUnitUserPagerQueryParams, ManagementSecurityUnitUserPagerVo> queryParams) {
return baseMapper.pager(queryParams.getPage(), queryParams.getParams()); return baseMapper.pager(queryParams.getPage(), queryParams.getParams());
} }
@Override
public void deleteById(Long managementSecurityUnitUserId) {
Long unitId = UserUtil.getUnitId();
Long l = this.lambdaQuery()
.eq(BaseEntity::getSnowFlakeId, managementSecurityUnitUserId)
.oneOpt()
.map(ManagementSecurityUnitUser::getSecurityUnitId)
.orElseThrow(() -> new MessageException(ResultCode.USER_NOT_FOUND));
if (!unitId.equals(l)) {
throw new MessageException("单位不匹配,无权操作");
}
boolean b = this.removeById(managementSecurityUnitUserId);
if (!b) {
throw new MessageException();
}
}
} }

View File

@ -36,7 +36,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler(Throwable.class) @ExceptionHandler(Throwable.class)
public JsonResult<String> throwableHandler(Throwable throwable) { public JsonResult<String> throwableHandler(Throwable throwable) {
String errorLabel = "系统错误:" + ExceptionUtil.getMessage(throwable); String errorLabel = "系统错误:" + ExceptionUtil.getMessage(throwable);
log.error("系统错误:{}", ExceptionUtil.stacktraceToString(throwable)); log.error("系统错误:", throwable);
return JsonResult.custom(ResultCode.ERROR.getCode(), errorLabel); return JsonResult.custom(ResultCode.ERROR.getCode(), errorLabel);
} }

View File

@ -0,0 +1,54 @@
package com.changhu.support.interceptor;
import com.changhu.common.annotation.CheckClientType;
import com.changhu.common.exception.MessageException;
import com.changhu.common.utils.UserUtil;
import com.changhu.enums.ClientType;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jetbrains.annotations.NotNull;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
/**
* @author 20252
* @createTime 2024/9/4 下午4:00
* @desc ClientTypeInterceptor...
*/
public class ClientTypeInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(@NotNull HttpServletRequest request,
@NotNull HttpServletResponse response,
@NotNull Object handler) {
if (handler instanceof HandlerMethod handlerMethod) {
boolean b = false;
ClientType ct = null;
CheckClientType clazzJsonBody = handlerMethod.getBeanType().getAnnotation(CheckClientType.class);
CheckClientType methodJsonBody = handlerMethod.getMethodAnnotation(CheckClientType.class);
if (clazzJsonBody != null) {
if (methodJsonBody == null) {
b = true;
ct = clazzJsonBody.clientType();
} else if (methodJsonBody.value()) {
b = true;
ct = methodJsonBody.clientType();
}
} else {
if (methodJsonBody != null && methodJsonBody.value()) {
b = true;
ct = methodJsonBody.clientType();
}
}
if (b) {
if (!ct.equals(UserUtil.getClientType())) {
throw new MessageException("客户端类型不对");
}
}
}
return true;
}
}

View File

@ -0,0 +1,29 @@
package com.changhu.support.mybatisplus.handler.permission.management;
import com.changhu.common.utils.UserUtil;
import com.changhu.support.mybatisplus.handler.permission.AbstractDataPermissionHandler;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.LongValue;
import net.sf.jsqlparser.expression.operators.relational.EqualsTo;
import net.sf.jsqlparser.schema.Column;
import net.sf.jsqlparser.schema.Table;
/**
* @author 20252
* @createTime 2024/9/4 下午3:29
* @desc ManagementPoliceUnitUserPagerPermissionHandler...
*/
public class ManagementPoliceUnitUserPagerPermissionHandler implements AbstractDataPermissionHandler {
@Override
public Expression apply(Table table, Expression where, String mappedStatementId) {
if ("mpuu".equals(table.getAlias().getName())) {
return sqlFragment();
}
return null;
}
@Override
public Expression sqlFragment() {
return new EqualsTo(new Column("mpuu.police_unit_id"), new LongValue(UserUtil.getUnitId()));
}
}

View File

@ -1,12 +1,7 @@
package com.changhu.support.mybatisplus.handler.permission.management; package com.changhu.support.mybatisplus.handler.permission.management;
import com.baomidou.mybatisplus.extension.toolkit.Db;
import com.changhu.common.enums.ResultCode;
import com.changhu.common.exception.MessageException;
import com.changhu.common.utils.UserUtil; import com.changhu.common.utils.UserUtil;
import com.changhu.module.management.pojo.entity.ManagementSecurityUnitUser;
import com.changhu.support.mybatisplus.handler.permission.AbstractDataPermissionHandler; import com.changhu.support.mybatisplus.handler.permission.AbstractDataPermissionHandler;
import com.changhu.support.mybatisplus.pojo.entity.BaseEntity;
import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.LongValue; import net.sf.jsqlparser.expression.LongValue;
import net.sf.jsqlparser.expression.operators.relational.EqualsTo; import net.sf.jsqlparser.expression.operators.relational.EqualsTo;
@ -29,12 +24,6 @@ public class ManagementSecurityUnitUserPagerPermissionHandler implements Abstrac
@Override @Override
public Expression sqlFragment() { public Expression sqlFragment() {
//查出当前用户 return new EqualsTo(new Column("msuu.security_unit_id"), new LongValue(UserUtil.getUnitId()));
ManagementSecurityUnitUser managementSecurityUnitUser = Db.lambdaQuery(ManagementSecurityUnitUser.class)
.select(BaseEntity::getSnowFlakeId, ManagementSecurityUnitUser::getSecurityUnitId)
.eq(BaseEntity::getSnowFlakeId, UserUtil.getUserId())
.oneOpt()
.orElseThrow(() -> new MessageException(ResultCode.USER_NOT_FOUND));
return new EqualsTo(new Column("msuu.security_unit_id"), new LongValue(managementSecurityUnitUser.getSecurityUnitId()));
} }
} }

View File

@ -1,8 +1,11 @@
package com.changhu.support.satoken; package com.changhu.support.satoken;
import cn.dev33.satoken.dao.SaTokenDaoRedis; import cn.dev33.satoken.dao.SaTokenDaoRedis;
import cn.dev33.satoken.jwt.StpLogicJwtForSimple;
import cn.dev33.satoken.stp.StpLogic;
import jakarta.annotation.PostConstruct; import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -29,4 +32,12 @@ public class SaTokenConfig {
this.saTokenDaoRedis.stringRedisTemplate = this.stringRedisTemplate; this.saTokenDaoRedis.stringRedisTemplate = this.stringRedisTemplate;
this.saTokenDaoRedis.objectRedisTemplate = this.redisTemplate; this.saTokenDaoRedis.objectRedisTemplate = this.redisTemplate;
} }
/**
* Sa-Token 整合 jwt (Simple 简单模式)
*/
@Bean
public StpLogic getStpLogicJwt() {
return new StpLogicJwtForSimple();
}
} }

View File

@ -138,6 +138,8 @@ sa-token:
is-log: true is-log: true
# 是否尝试从 cookie 里读取 token # 是否尝试从 cookie 里读取 token
is-read-cookie: false is-read-cookie: false
# jwt秘钥
jwt-secret-key: a29216f8-cd60-4e96-89c5-ab6012159052
project: project:
env: dev env: dev

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.changhu.module.management.mapper.ManagementPoliceUnitUserMapper">
<select id="pager" resultType="com.changhu.module.management.pojo.vo.ManagementPoliceUnitUserPagerVo">
select
mpuu.*,
mpuu2.name as 'createUserName'
from management_police_unit_user mpuu
left join management_police_unit_user mpuu2 on mpuu.create_by = mpuu2.snow_flake_id
where
mpuu.delete_flag = 0
<if test="params.name!=null and params.name!=''">
and mpuu.name like concat('%',#{params.name},'%')
</if>
<if test="params.telephone!=null and params.telephone!=''">
and mpuu.telephone like concat('%',#{params.telephone},'%')
</if>
<if test="params.sex!=null">
and mpuu.sex = #{params.sex.value}
</if>
order by mpuu.create_time desc
</select>
</mapper>

View File

@ -5,7 +5,7 @@ VITE_DROP_CONSOLE=false
# axios # axios
VITE_APP_BASE_API=/api VITE_APP_BASE_API=/api
VITE_APP_PROXY_URL=http://172.10.10.151:8765 VITE_APP_PROXY_URL=http://172.10.10.93:8765
# rsa 公钥 # rsa 公钥
VITE_APP_RSA_PUBLIC_KEY=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDJps/EXxxSpEM1Ix4R0NWIOBciHCr7P7coDT8tNKfelgR7txcJOqHCO/MIWe7T04aHQTcpQxqx9hMca7dbqz8TZpz9jvLzE/6ZonVKxHsoFnNlHMp1/CPAJ9f6D9wYicum2KltJkmQ0g//D9W2zPCYoGOmSRFcZx/KEBa4EM53jQIDAQAB VITE_APP_RSA_PUBLIC_KEY=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDJps/EXxxSpEM1Ix4R0NWIOBciHCr7P7coDT8tNKfelgR7txcJOqHCO/MIWe7T04aHQTcpQxqx9hMca7dbqz8TZpz9jvLzE/6ZonVKxHsoFnNlHMp1/CPAJ9f6D9wYicum2KltJkmQ0g//D9W2zPCYoGOmSRFcZx/KEBa4EM53jQIDAQAB

View File

@ -3,7 +3,10 @@ import {SystemMenu} from "@/types/config";
export const ROUTER_WHITE_LIST: string[] = ['/login', '/test','/enterprise']; export const ROUTER_WHITE_LIST: string[] = ['/login', '/test','/enterprise'];
export const CLIENT_TYPE:string = "MANAGEMENT_SECURITY"; export const CLIENT_TYPE:string = "MANAGEMENT_SECURITY";
export const UNIT_TYPE = {
security: 'SECURITY_UNIT',
police: 'POLICE_UNIT'
}
export const SYSTEM_MENUS: SystemMenu[] = [ export const SYSTEM_MENUS: SystemMenu[] = [
{ {
title: '首页', title: '首页',

View File

@ -10,3 +10,4 @@ export interface SystemMenu {
component?: RouteComponent; component?: RouteComponent;
children?: SystemMenu[]; children?: SystemMenu[];
} }

View File

@ -8,7 +8,7 @@ export interface BgManagementPagerQueryParams extends BaseTableRowRecord{
/** 行政区划编码 **/ /** 行政区划编码 **/
administrativeDivisionCodes?: string[]; administrativeDivisionCodes?: string[];
/** 是否启用 **/ /** 是否启用 **/
isEnable?: number; isEnable?: BaseEnum<number>;
/** 审核状态 **/ /** 审核状态 **/
checkStatus?: number; checkStatus?: number;
/** 账号 **/ /** 账号 **/
@ -18,5 +18,15 @@ export interface BgManagementPagerQueryParams extends BaseTableRowRecord{
createTime?:string, createTime?:string,
snowFlakeId?:string, snowFlakeId?:string,
remark?:string, remark?:string,
isAdmin?:BaseEnum<number | string>
}
export interface FromItem {
snowFlakeId?: string,
name: string,
sex: number,
telephone: string,
isEnable: BaseEnum<number>,
remark?: string,
} }

View File

@ -1,264 +1,11 @@
<template> <template>
<div> <div>test</div>
<TableProMax
ref="tableRef"
:request-api="reqApi"
:columns="columns"
:searchFormOptions="searchFormOptions"
:scroll="{x}"
>
<template #tableHeader>
<a-space>
<a-button type="primary" @click="addUserManagement">新增用户</a-button>
</a-space>
</template>
</TableProMax>
<a-modal
v-model:open="visible"
:title="title"
@ok="submit"
@cancel="closeModal"
>
<FormProMax ref="formRef" v-model:value="formParams" :form-item-options="formItemOptions"/>
</a-modal>
</div>
</template> </template>
<script setup lang="ts">
<script setup lang="tsx">
import TableProMax from "@/components/table/TableProMax.vue";
import {TableProMaxProps} from "@/types/components/table";
import api from "@/axios";
import {ref} from "vue";
import {ComponentExposed} from "vue-component-type-helpers";
import {dictSelectNodes} from "@/config/dict.ts";
import {BgManagementPagerQueryParams} from "@/types/views/bgManagement.ts";
import FormProMax from "@/components/form/FormProMax.vue";
import {FormProMaxItemOptions} from "@/types/components/form";
import {FormExpose} from "ant-design-vue/es/form/Form";
import {message} from "ant-design-vue";
import {} from '@/hooks/useTableProMax.ts'
type TableProps = TableProMaxProps<BgManagementPagerQueryParams>
const tableRef = ref<ComponentExposed<typeof TableProMax>>(null!)
// table
const reqApi: TableProps['requestApi'] = (params) => api.post('/managementSecurityUnitUser/pager', params) //
const columns: TableProps['columns'] = [
{
dataIndex: 'account',
title: '账号',
width: 100,
ellipsis: true
},
{
dataIndex: 'name',
title: '名称',
width: 200,
ellipsis: true
}, {
dataIndex: 'sex',
title: '性别',
customRender: ({text}) => <a-tag>{text?.label}</a-tag>,
width: 150
}, {
dataIndex: 'telephone',
title: '手机号码',
width: 150,
ellipsis: true
},
{
dataIndex: 'createTime',
title: '创建时间',
width: 200,
ellipsis: true,
},
{
dataIndex: 'snowFlakeId',
title: '社区唯一编码',
width: 200,
ellipsis: true
}, {
dataIndex: 'remark',
title: '备注',
width: 200,
ellipsis: true
}, {
dataIndex: 'isEnable',
title: '是否启用',
customRender: ({text}) => <a-tag color={text?.extData?.color}>{text?.label}</a-tag>,
width: 150
}, {
dataIndex: 'opt',
title: '操作',
fixed: "right",
customRender({record}) {
return <a-space>
<a-button class={record.isEnable.value === 0 ? 'btn-danger' : 'btn-success'} onClick={async () => {
const resp = await api.post('/management/disableOrEnable', {
unitId: record.snowFlakeId,
unitOptType: UNIT_TYPE.security
})
message.success(resp.message)
await tableRef.value?.requestGetTableData()
}}>
{record.isEnable.value === 0 ? '禁用' : '启用'}
</a-button>
<a-button>
删除
</a-button>
<a-button onClick={async () => {
visible.value = true
title.value = "编辑用户"
formParams.value.snowFlakeId = record.snowFlakeId
formParams.value.name = record.name,
formParams.value.sex = record.sex.value,
formParams.value. telephone = record.telephone,
formParams.value.isEnable = record.isEnable?.value,
formParams.value.remark = record.remark
}}>
编辑
</a-button>
</a-space>
}
},
]
const x: number = columns.reduce((a, b) => a + (b.width as number), 0)
const searchFormOptions: TableProps["searchFormOptions"] = {
name: {
type: 'input',
label: '名称'
}, sex: {
type: 'select',
label: '性别',
options: [
{
value: null,
label: '全部'
}, ...dictSelectNodes('Sex')
]
},
telephone: {
type: 'input',
label: '手机号'
},
isEnable: {
type: 'select',
label: '是否启用',
options: [
{
value: null,
label: '全部'
}, ...dictSelectNodes('IsEnable')
]
}
}
const visible = ref(false)
const title = ref('新增用户')
const formRef = ref<FormExpose>(null)
const formParams = ref<{
snowFlakeId?: string,
name: string,
sex: number,
telephone: string,
isEnable: boolean,
remark?: string,
}>({
name: '',
sex: null,
telephone: '',
isEnable: null,
})
interface FromItem {
snowFlakeId?: string,
name: string,
sex: number,
telephone: string,
isEnable: boolean,
remark?: string,
}
const formItemOptions = ref<FormProMaxItemOptions<FromItem>>({
name:{
type:'input',
label:'姓名',
required:true,
},
sex:{
type:'radioGroup',
label:'性别',
options: dictSelectNodes('Sex'),
required:true,
},
telephone:{
type:'input',
label:'手机号',
required:true,
},
isEnable:{
type:'radioGroup',
label:'启用状态',
options: dictSelectNodes('IsEnable'),
required:true,
},
remark:{
type:'inputTextArea',
label:'备注',
}
})
const submit = async () => {
await formRef.value.validate()
const snowFlakeId = ref('')
if(title.value === '新增用户'){
snowFlakeId.value = ''
}else{
snowFlakeId.value = formParams.value.snowFlakeId
}
const managementSecurityUnitUserSaveOrUpdateParams = {
snowFlakeId:snowFlakeId.value,
name:formParams.value.name,
sex:formParams.value.sex,
telephone:formParams.value.telephone,
isEnable:formParams.value.isEnable,
remark:formParams.value.remark
}
const resp = await api.post('/managementSecurityUnitUser/saveOrUpdate',managementSecurityUnitUserSaveOrUpdateParams)
message.success(resp.message)
close()
}
const close = ()=>{
tableRef.value?.requestGetTableData()
visible.value = false
closeModal()
}
const closeModal = () => {
formParams.value = {
name:'',
sex:null,
telephone:'',
isEnable:null,
remark:''
}
visible.value = false
// formRef.value.
console.log('取消')
}
//Form
const addUserManagement = () => {
visible.value = true
title.value = ''
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
</style> </style>

View File

@ -1,12 +1,248 @@
<template> <template>
<div>用户管理</div> <div>
<TableProMax
ref="tableRef"
:request-api="reqApi"
:columns="columns"
:searchFormOptions="searchFormOptions"
:scroll="{x}"
>
<template #tableHeader>
<a-space>
<a-button type="primary" @click="addUserManagement">新增用户</a-button>
</a-space>
</template>
</TableProMax>
<a-modal
v-model:open="visible"
:title="title"
@ok="submit"
@cancel="closeModal"
>
<FormProMax ref="formRef" v-model:value="formParams" :form-item-options="formItemOptions"/>
</a-modal>
</div>
</template> </template>
<script setup lang="ts">
<script setup lang="tsx">
import TableProMax from "@/components/table/TableProMax.vue";
import {TableProMaxProps} from "@/types/components/table";
import api from "@/axios";
import {ref} from "vue";
import {ComponentExposed} from "vue-component-type-helpers";
import {dictSelectNodes} from "@/config/dict.ts";
import {BgManagementPagerQueryParams, FromItem} from "@/types/views/bgManagement.ts";
import FormProMax from "@/components/form/FormProMax.vue";
import {FormProMaxItemOptions} from "@/types/components/form";
import {FormExpose} from "ant-design-vue/es/form/Form";
import {message} from "ant-design-vue";
type TableProps = TableProMaxProps<BgManagementPagerQueryParams>
const tableRef = ref<ComponentExposed<typeof TableProMax>>(null!)
// table
const reqApi: TableProps['requestApi'] = (params) => api.post('/managementSecurityUnitUser/pager', params) //
const columns: TableProps['columns'] = [
{
dataIndex: 'account',
title: '账号',
width: 100,
ellipsis: true
},
{
dataIndex: 'name',
title: '名称',
width: 200,
ellipsis: true
}, {
dataIndex: 'sex',
title: '性别',
customRender: ({text}) => <a-tag>{text?.label}</a-tag>,
width: 150
}, {
dataIndex: 'telephone',
title: '手机号码',
width: 150,
ellipsis: true
},
{
dataIndex: 'createTime',
title: '创建时间',
width: 200,
ellipsis: true,
},
{
dataIndex: 'remark',
title: '备注',
width: 200,
ellipsis: true
}, {
dataIndex: 'isEnable',
title: '是否启用',
customRender: ({text}) => <a-tag color={text?.extData?.color}>{text?.label}</a-tag>,
width: 150
}, {
dataIndex: 'opt',
title: '操作',
fixed: "right",
customRender({record}) {
return (
record.isAdmin.value === 1?
<a-space>
<a-button type="primary" danger>
<a-popconfirm
title="确认删除账号吗?"
onConfirm={async () => {
const resp = await api.delete('/managementSecurityUnitUser/deleteById', {
managementSecurityUnitUserId: record.snowFlakeId,
})
message.success(resp.message)
await tableRef.value?.requestGetTableData()
}}>
删除
</a-popconfirm>
</a-button>
<a-button type="primary" onClick={async () => {
visible.value = true
title.value = "编辑用户"
formParams.value.snowFlakeId = record.snowFlakeId
formParams.value.name = record.name,
formParams.value.sex = record.sex.value,
formParams.value.telephone = record.telephone,
formParams.value.isEnable = record.isEnable?.value,
formParams.value.remark = record.remark
}}>
编辑
</a-button>
</a-space>
:
<i></i>
)
}
},
]
const x: number = columns.reduce((a, b) => a + (b.width as number), 0)
const searchFormOptions: TableProps["searchFormOptions"] = {
name: {
type: 'input',
label: '名称'
}, sex: {
type: 'select',
label: '性别',
options: [
{
value: null,
label: '全部'
}, ...dictSelectNodes('Sex')
]
},
telephone: {
type: 'input',
label: '手机号'
},
isEnable: {
type: 'select',
label: '是否启用',
options: [
{
value: null,
label: '全部'
}, ...dictSelectNodes('IsEnable')
]
}
}
const visible = ref(false)
const title = ref('新增用户')
const formRef = ref<FormExpose>(null)
const formParams = ref<{
snowFlakeId?: string,
name: string,
sex: number,
telephone: string,
isEnable: any,
remark?: string,
}>({
name: '',
sex: 0,
telephone: '',
isEnable: 0,
})
const formItemOptions = ref<FormProMaxItemOptions<FromItem>>({
name: {
type: 'input',
label: '姓名',
required: true,
},
sex: {
type: 'radioGroup',
label: '性别',
options: dictSelectNodes('Sex'),
required: true,
},
telephone: {
type: 'input',
label: '手机号',
required: true,
},
isEnable: {
type: 'radioGroup',
label: '启用状态',
options: dictSelectNodes('IsEnable'),
required: true,
},
remark: {
type: 'inputTextArea',
label: '备注',
}
})
const submit = async () => {
await formRef.value.validate()
const snowFlakeId = ref('')
if (title.value === '新增用户') {
snowFlakeId.value = ''
} else {
snowFlakeId.value = formParams.value.snowFlakeId
}
const managementSecurityUnitUserSaveOrUpdateParams = {
snowFlakeId: snowFlakeId.value,
name: formParams.value.name,
sex: formParams.value.sex,
telephone: formParams.value.telephone,
isEnable: formParams.value.isEnable,
remark: formParams.value.remark
}
const resp = await api.post('/managementSecurityUnitUser/saveOrUpdate', managementSecurityUnitUserSaveOrUpdateParams)
message.success(resp.message)
close()
}
const close = () => {
tableRef.value?.requestGetTableData()
visible.value = false
closeModal()
}
const closeModal = () => {
formParams.value = {
name: '',
sex: 0,
telephone: '',
isEnable: 0,
remark: ''
}
visible.value = false
}
//Form
const addUserManagement = () => {
visible.value = true
title.value = ''
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
</style> </style>

View File

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<script type="module" src="/src/assets/iconfont/iconfont.js"></script> <script type="module" src="/src/assets/iconfont/iconfont.js"></script>
<title>Vite + Vue + TS</title> <title>超级后台</title>
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>

View File

@ -24,7 +24,7 @@ import {dictSelectNodes} from "@/config/dict.ts";
import {message, Modal} from "ant-design-vue"; import {message, Modal} from "ant-design-vue";
import {UNIT_TYPE} from "@/config"; import {UNIT_TYPE} from "@/config";
import {PageParams} from "@/types/hooks/useTableProMax.ts"; import {PageParams} from "@/types/hooks/useTableProMax.ts";
import {submitSimpleFormModal} from "@/components/tsx/ModalPro.tsx"; import {submitSimpleFormModal, deleteDataModal} from "@/components/tsx/ModalPro.tsx";
import useSelectAndTreeNodeVos from "@/hooks/useSelectAndTreeNodeVos.ts"; import useSelectAndTreeNodeVos from "@/hooks/useSelectAndTreeNodeVos.ts";
type TableProps = TableProMaxProps<PoliceUnitPagerVo, PoliceUnitPagerQueryParams> type TableProps = TableProMaxProps<PoliceUnitPagerVo, PoliceUnitPagerQueryParams>
@ -103,13 +103,17 @@ const columns: TableProps['columns'] = [
}, },
} }
] ]
const searchFormOptions: TableProps["searchFormOptions"] = { const searchFormOptions = ref<TableProps["searchFormOptions"]>({
name: { name: {
type: 'input', type: 'input',
label: '名称' label: '名称'
}, code: { }, code: {
type: 'input', type: 'input',
label: '代码' label: '代码'
}, administrativeDivisionCodes: {
type: 'cascader',
label: '行政区划',
options: administrativeDivisionTree
}, isEnable: { }, isEnable: {
type: 'select', type: 'select',
label: '是否启用', label: '是否启用',
@ -129,7 +133,7 @@ const searchFormOptions: TableProps["searchFormOptions"] = {
}, ...dictSelectNodes('CheckStatus') }, ...dictSelectNodes('CheckStatus')
] ]
} }
} })
type _TableProps = TableProMaxProps<EnterprisesUnitPagerVo, EnterprisesUnitPagerQueryParams>; type _TableProps = TableProMaxProps<EnterprisesUnitPagerVo, EnterprisesUnitPagerQueryParams>;
const showEnterprisesUnit = (policeUnitPagerVo: PoliceUnitPagerVo) => { const showEnterprisesUnit = (policeUnitPagerVo: PoliceUnitPagerVo) => {
@ -226,6 +230,14 @@ const showEnterprisesUnit = (policeUnitPagerVo: PoliceUnitPagerVo) => {
})} })}
>编辑 >编辑
</a-button> </a-button>
<a-button class="btn-danger" onClick={() => deleteDataModal(record.name, async () => {
const resp = await api.delete('/enterprisesUnit/deleteById', {
enterprisesUnitId: record.snowFlakeId
})
message.success(resp.message)
await _tableRef.value?.requestGetTableData()
})}>删除
</a-button>
</a-space> </a-space>
} }
] ]

View File

@ -81,21 +81,24 @@ const columns: TableProps['columns'] = [
title: '操作', title: '操作',
fixed: "right", fixed: "right",
customRender({record}) { customRender({record}) {
if (record.checkStatus.value === 1) {
return <a-space>
<a-popconfirm
title="确认审核通过嘛?"
onConfirm={async () => {
const resp = await api.post('/management/checkPass', {
checkDataId: record.snowFlakeId,
unitOptType: UNIT_TYPE.security
})
message.success(resp.message)
await tableRef.value?.requestGetTableData()
}}>
<a-button type="primary">审核通过
</a-button>
</a-popconfirm>
</a-space>
}
return <a-space> return <a-space>
{record.checkStatus.value === 1 && <a-popconfirm
title="确认审核通过嘛?"
onConfirm={async () => {
const resp = await api.post('/management/checkPass', {
checkDataId: record.snowFlakeId,
unitOptType: UNIT_TYPE.security
})
message.success(resp.message)
await tableRef.value?.requestGetTableData()
}}>
<a-button type="primary">审核通过
</a-button>
</a-popconfirm>
}
<a-button <a-button
class={record.isEnable.value === 0 ? 'btn-danger' : 'btn-success'} class={record.isEnable.value === 0 ? 'btn-danger' : 'btn-success'}
onClick={async () => { onClick={async () => {