代码提交

This commit is contained in:
luozhun 2024-09-03 10:51:15 +08:00
parent 8f2feca49b
commit 1a490bb581
33 changed files with 803 additions and 23 deletions

View File

@ -60,6 +60,10 @@ public class MessageException extends RuntimeException {
this.message = resultCode.getMessage(); this.message = resultCode.getMessage();
} }
public MessageException() {
}
@Override @Override
public String toString() { public String toString() {
return StrUtil.format("业务错误:错误代码:{},错误内容:{}", Objects.isNull(this.code) ? 500 : this.code, this.message); return StrUtil.format("业务错误:错误代码:{},错误内容:{}", Objects.isNull(this.code) ? 500 : this.code, this.message);

View File

@ -1,5 +1,6 @@
package com.changhu.common.pojo.vo; package com.changhu.common.pojo.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
/** /**
@ -9,7 +10,10 @@ import lombok.Data;
*/ */
@Data @Data
public class TokenInfo { public class TokenInfo {
@Schema(description = "token的名字")
private String name; private String name;
@Schema(description = "token的值")
private String value; private String value;
public TokenInfo(String name, String value) { public TokenInfo(String name, String value) {

View File

@ -23,9 +23,6 @@ public class WebConfig implements WebMvcConfigurer {
private final List<String> whiteList = new ArrayList<>(); private final List<String> whiteList = new ArrayList<>();
public WebConfig() { public WebConfig() {
//todo 要删除的
whiteList.add("/managementSuperUser/**");
whiteList.add("/common/**"); whiteList.add("/common/**");
whiteList.add("/test/**"); whiteList.add("/test/**");
whiteList.add("/login"); whiteList.add("/login");

View File

@ -1,6 +1,8 @@
package com.changhu.enums; package com.changhu.enums;
import com.changhu.enums.handler.AbstractLoginHandler; import com.changhu.enums.handler.AbstractLoginHandler;
import com.changhu.enums.handler.ManagementPoliceUnitLogin;
import com.changhu.enums.handler.ManagementSecurityUnitLogin;
import com.changhu.enums.handler.ManagementSuperLogin; import com.changhu.enums.handler.ManagementSuperLogin;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
@ -13,13 +15,12 @@ import lombok.Getter;
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum ClientType { public enum ClientType {
MANAGEMENT_SUPER("management_super", "超级后台", ManagementSuperLogin.instance), MANAGEMENT_SUPER("超级后台", ManagementSuperLogin.instance),
MANAGEMENT_POLICE("management_police", "公安后台", ManagementSuperLogin.instance), MANAGEMENT_POLICE("公安后台", ManagementPoliceUnitLogin.instance),
MANAGEMENT_SECURITY("management_security", "保安后台", ManagementSuperLogin.instance), MANAGEMENT_SECURITY("保安后台", ManagementSecurityUnitLogin.instance),
MINI_PROGRAM("mini_program", "微信小程序", ManagementSuperLogin.instance), MINI_PROGRAM("微信小程序", ManagementSuperLogin.instance),
; ;
private final String value;
private final String remark; private final String remark;
private final AbstractLoginHandler loginHandler; private final AbstractLoginHandler loginHandler;
} }

View File

@ -0,0 +1,78 @@
package com.changhu.enums.handler;
import cn.dev33.satoken.stp.SaTokenInfo;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson2.JSONObject;
import com.changhu.common.db.enums.IsEnable;
import com.changhu.common.enums.ResultCode;
import com.changhu.common.exception.MessageException;
import com.changhu.common.pojo.vo.TokenInfo;
import com.changhu.common.utils.RsaUtil;
import com.changhu.common.utils.UserUtil;
import com.changhu.common.utils.ValidatorUtil;
import com.changhu.module.management.pojo.entity.ManagementPoliceUnitUser;
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.support.mybatisplus.pojo.entity.BaseEntity;
/**
* @author 20252
* @createTime 2024/9/2 下午4:52
* @desc ManagementPoliceUnitLogin...
*/
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();
private ManagementPoliceUnitLogin() {
}
@Override
public TokenInfo login(JSONObject jsonObject) {
ManagementPoliceUnitLoginParams managementPoliceUnitLoginParams = jsonObject.to(ManagementPoliceUnitLoginParams.class);
ValidatorUtil.manual(managementPoliceUnitLoginParams);
String accountOrTelephone = managementPoliceUnitLoginParams.getAccountOrTelephone();
String password = RsaUtil.decrypt(managementPoliceUnitLoginParams.getPassword());
//查看 账号/手机号 是否存在
ManagementPoliceUnitUser managementPoliceUnitUser = policeUnitUserService.lambdaQuery()
.eq(ManagementPoliceUnitUser::getAccount, accountOrTelephone)
.or()
.eq(ManagementPoliceUnitUser::getTelephone, accountOrTelephone)
.oneOpt()
.orElseThrow(() -> new MessageException(ResultCode.USER_NOT_FOUND));
//判断用户是否禁用
if (managementPoliceUnitUser.getIsEnable().equals(IsEnable.FALSE)) {
throw new MessageException(ResultCode.USER_IS_DISABLE);
}
//判断单位是否禁用
IsEnable unitEnable = policeUnitService.lambdaQuery()
.eq(BaseEntity::getSnowFlakeId, managementPoliceUnitUser.getPoliceUnitId())
.oneOpt()
.map(PoliceUnit::getIsEnable)
.orElseThrow(() -> new MessageException("单位不存在"));
if (unitEnable.equals(IsEnable.FALSE)) {
throw new MessageException("单位被禁用");
}
//判断密码是否正确
if (!UserUtil.verifyPassWord(password, managementPoliceUnitUser.getSalt(), managementPoliceUnitUser.getPassword())) {
throw new MessageException(ResultCode.PASSWORD_ERROR);
}
//登录
SaTokenInfo saTokenInfo = UserUtil.loginAndTokenInfo(managementPoliceUnitUser.getSnowFlakeId());
//返回token
return new TokenInfo(saTokenInfo.getTokenName(), saTokenInfo.getTokenValue());
}
}

View File

@ -0,0 +1,77 @@
package com.changhu.enums.handler;
import cn.dev33.satoken.stp.SaTokenInfo;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson2.JSONObject;
import com.changhu.common.db.enums.IsEnable;
import com.changhu.common.enums.ResultCode;
import com.changhu.common.exception.MessageException;
import com.changhu.common.pojo.vo.TokenInfo;
import com.changhu.common.utils.RsaUtil;
import com.changhu.common.utils.UserUtil;
import com.changhu.common.utils.ValidatorUtil;
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.service.ManagementSecurityUnitUserService;
import com.changhu.module.management.service.SecurityUnitService;
import com.changhu.pojo.params.ManagementSecurityUnitLoginParams;
import com.changhu.support.mybatisplus.pojo.entity.BaseEntity;
/**
* @author 20252
* @createTime 2024/9/2 下午5:48
* @desc ManagementSecurityUnitLogin...
*/
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();
private ManagementSecurityUnitLogin() {
}
@Override
public TokenInfo login(JSONObject jsonObject) {
ManagementSecurityUnitLoginParams loginParams = jsonObject.to(ManagementSecurityUnitLoginParams.class);
ValidatorUtil.manual(loginParams);
String accountOrTelephone = loginParams.getAccountOrTelephone();
String password = RsaUtil.decrypt(loginParams.getPassword());
//查看 账号/手机号 是否存在
ManagementSecurityUnitUser managementSecurityUnitUser = securityUnitUserService.lambdaQuery()
.eq(ManagementSecurityUnitUser::getAccount, accountOrTelephone)
.or()
.eq(ManagementSecurityUnitUser::getTelephone, accountOrTelephone)
.oneOpt()
.orElseThrow(() -> new MessageException(ResultCode.ERROR));
//判断用户是否禁用
if (managementSecurityUnitUser.getIsEnable().equals(IsEnable.FALSE)) {
throw new MessageException(ResultCode.USER_IS_DISABLE);
}
//判断单位是否禁用
IsEnable unitEnable = securityUnitService.lambdaQuery()
.eq(BaseEntity::getSnowFlakeId, managementSecurityUnitUser.getSecurityUnitId())
.oneOpt()
.map(SecurityUnit::getIsEnable)
.orElseThrow(() -> new MessageException("单位不存在"));
if (unitEnable.equals(IsEnable.FALSE)) {
throw new MessageException("单位被禁用");
}
//判断密码是否正确
if (!UserUtil.verifyPassWord(password, managementSecurityUnitUser.getSalt(), managementSecurityUnitUser.getPassword())) {
throw new MessageException(ResultCode.PASSWORD_ERROR);
}
//登录
SaTokenInfo saTokenInfo = UserUtil.loginAndTokenInfo(managementSecurityUnitUser.getSnowFlakeId());
//返回token
return new TokenInfo(saTokenInfo.getTokenName(), saTokenInfo.getTokenValue());
}
}

View File

@ -38,7 +38,7 @@ public class ManagementSuperLogin extends AbstractLoginHandler {
ManagementSuperUser user = managementSuperUserService.lambdaQuery() ManagementSuperUser user = managementSuperUserService.lambdaQuery()
.eq(ManagementSuperUser::getTelephone, telephone) .eq(ManagementSuperUser::getTelephone, telephone)
.oneOpt() .oneOpt()
.orElseThrow(() -> new MessageException("用户不存在")); .orElseThrow(() -> new MessageException(ResultCode.USER_NOT_FOUND));
//判断密码是否正确 //判断密码是否正确
if (!UserUtil.verifyPassWord(password, user.getSalt(), user.getPassword())) { if (!UserUtil.verifyPassWord(password, user.getSalt(), user.getPassword())) {

View File

@ -0,0 +1,16 @@
package com.changhu.module.management.controller;
import com.changhu.common.annotation.JsonBody;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* @author 20252
* @createTime 2024/9/3 上午10:17
* @desc EnterprisesUnitController...
*/
@Tag(name = "企事业单位")
@JsonBody
@RequestMapping("/enterprisesUnit")
public class EnterprisesUnitController {
}

View File

@ -3,6 +3,7 @@ package com.changhu.module.management.controller;
import com.changhu.common.annotation.JsonBody; import com.changhu.common.annotation.JsonBody;
import com.changhu.module.management.pojo.params.IndexCheckPassParams; import com.changhu.module.management.pojo.params.IndexCheckPassParams;
import com.changhu.module.management.pojo.params.IndexCheckStatusParams; import com.changhu.module.management.pojo.params.IndexCheckStatusParams;
import com.changhu.module.management.pojo.params.IndexDisableOrEnableParams;
import com.changhu.module.management.pojo.vo.UnitCheckStatusVo; import com.changhu.module.management.pojo.vo.UnitCheckStatusVo;
import com.changhu.module.management.service.IndexService; import com.changhu.module.management.service.IndexService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@ -37,4 +38,10 @@ public class IndexController {
public UnitCheckStatusVo getCheckStatus(@RequestBody @Valid IndexCheckStatusParams params) { public UnitCheckStatusVo getCheckStatus(@RequestBody @Valid IndexCheckStatusParams params) {
return indexService.getCheckStatus(params); return indexService.getCheckStatus(params);
} }
@Operation(summary = "启用或禁用状态")
@PostMapping("/disableOrEnable")
public void disableOrEnable(@RequestBody @Valid IndexDisableOrEnableParams params) {
indexService.disableOrEnable(params);
}
} }

View File

@ -0,0 +1,14 @@
package com.changhu.module.management.controller;
import com.changhu.common.annotation.JsonBody;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* @author 20252
* @createTime 2024/9/3 上午10:21
* @desc ManagementPoliceUnitUserController...
*/
@JsonBody
@RequestMapping("/managementPoliceUnitUser")
public class ManagementPoliceUnitUserController {
}

View File

@ -0,0 +1,28 @@
package com.changhu.module.management.controller;
import com.changhu.common.annotation.JsonBody;
import com.changhu.module.management.pojo.params.ManagementSecurityUnitUserSaveOrUpdateParams;
import com.changhu.module.management.service.ManagementSecurityUnitUserService;
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;
/**
* @author 20252
* @createTime 2024/9/3 上午10:22
* @desc ManagementSecurityUnitUserController...
*/
@JsonBody
@RequestMapping("/managementSecurityUnitUser")
public class ManagementSecurityUnitUserController {
@Autowired
private ManagementSecurityUnitUserService managementSecurityUnitUserService;
@PostMapping("/saveOrUpdate")
public void saveOrUpdate(@RequestBody @Valid ManagementSecurityUnitUserSaveOrUpdateParams saveOrUpdateParams) {
managementSecurityUnitUserService.saveOrUpdate(saveOrUpdateParams);
}
}

View File

@ -25,4 +25,11 @@ public abstract class AbstractUnitTypeHandler {
* @return 审核状态 * @return 审核状态
*/ */
public abstract UnitCheckStatusVo getCheckStatus(String onlyCode); public abstract UnitCheckStatusVo getCheckStatus(String onlyCode);
/**
* 启用或者禁用状态
*
* @param unitId 单位id
*/
public abstract void disableOrEnable(Long unitId);
} }

View File

@ -4,6 +4,7 @@ import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import com.changhu.common.db.enums.CheckStatus; import com.changhu.common.db.enums.CheckStatus;
import com.changhu.common.db.enums.IsEnable;
import com.changhu.common.db.enums.IsOrNot; import com.changhu.common.db.enums.IsOrNot;
import com.changhu.common.db.enums.Sex; import com.changhu.common.db.enums.Sex;
import com.changhu.common.enums.ResultCode; import com.changhu.common.enums.ResultCode;
@ -11,6 +12,7 @@ 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;
@ -103,4 +105,25 @@ public class PoliceUnitTypeHandler extends AbstractUnitTypeHandler {
} }
return unitCheckStatusVo; return unitCheckStatusVo;
} }
@Override
public void disableOrEnable(Long unitId) {
PoliceUnit policeUnit = policeUnitService.lambdaQuery()
.eq(BaseEntity::getSnowFlakeId, unitId)
.oneOpt()
.orElseThrow(() -> new MessageException(ResultCode.DATA_NOT_FOUND));
//取反
IsEnable isEnable = switch (policeUnit.getIsEnable()) {
case TRUE -> IsEnable.FALSE;
case FALSE -> IsEnable.TRUE;
};
boolean update = policeUnitService.lambdaUpdate()
.set(PoliceUnit::getIsEnable, isEnable)
.eq(BaseEntity::getSnowFlakeId, unitId)
.update();
if (!update) {
throw new MessageException();
}
}
} }

View File

@ -105,4 +105,25 @@ public class SecurityUnitTypeHandler extends AbstractUnitTypeHandler {
return unitCheckStatusVo; return unitCheckStatusVo;
} }
@Override
public void disableOrEnable(Long unitId) {
SecurityUnit securityUnit = securityUnitService.lambdaQuery()
.eq(BaseEntity::getSnowFlakeId, unitId)
.oneOpt()
.orElseThrow(() -> new MessageException(ResultCode.DATA_NOT_FOUND));
//取反
IsEnable isEnable = switch (securityUnit.getIsEnable()) {
case TRUE -> IsEnable.FALSE;
case FALSE -> IsEnable.TRUE;
};
boolean update = securityUnitService.lambdaUpdate()
.set(SecurityUnit::getIsEnable, isEnable)
.eq(BaseEntity::getSnowFlakeId, unitId)
.update();
if (!update) {
throw new MessageException();
}
}
} }

View File

@ -0,0 +1,15 @@
package com.changhu.module.management.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.changhu.module.management.pojo.entity.EnterprisesUnit;
import org.apache.ibatis.annotations.Mapper;
/**
* enterprises_unit (企事业单位) 固化类
* author: luozhun
* desc 由groovy脚本自动生成
*/
@Mapper
public interface EnterprisesUnitMapper extends BaseMapper<EnterprisesUnit> {
}

View File

@ -0,0 +1,81 @@
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.extension.handlers.Fastjson2TypeHandler;
import com.changhu.module.management.pojo.model.ContactPersonInfo;
import com.changhu.support.mybatisplus.pojo.entity.BaseEntity;
import lombok.Data;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import lombok.EqualsAndHashCode;
import com.baomidou.mybatisplus.annotation.TableName;
/**
* 企事业单位 实体类
* author: luozhun
* desc 由groovy脚本自动生成
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@EqualsAndHashCode(callSuper = true)
@TableName(autoResultMap = true)
public class EnterprisesUnit extends BaseEntity implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 所属公安机关id
*/
private Long policeUnitId;
/**
* 名称
*/
private String name;
/**
*
*/
private String province;
/**
*
*/
private String city;
/**
* /
*/
private String districts;
/**
* 街道
*/
private String street;
/**
* 详细地址
*/
private String address;
/**
* 联系人
*/
@TableField(typeHandler = Fastjson2TypeHandler.class)
private ContactPersonInfo contactPersonInfo;
/**
* 备注
*/
private String remark;
}

View File

@ -0,0 +1,22 @@
package com.changhu.module.management.pojo.params;
import com.changhu.module.management.enums.UnitOptType;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
/**
* @author 20252
* @createTime 2024/9/3 上午9:28
* @desc IndexDisableOrEnableParams...
*/
@Data
public class IndexDisableOrEnableParams {
@Schema(description = "单位id")
@NotNull(message = "单位id不能为空")
private Long unitId;
@Schema(description = "单位类型")
@NotNull(message = "单位类型不能为空")
private UnitOptType unitOptType;
}

View File

@ -0,0 +1,45 @@
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 com.changhu.module.management.pojo.model.ContactPersonInfo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.util.List;
/**
* @author 20252
* @createTime 2024/9/3 上午10:26
* @desc ManagementSecurityUnitUserSaveOrUpdateParams...
*/
@Data
public class ManagementSecurityUnitUserSaveOrUpdateParams {
@Schema(description = "id")
private Long snowFlakeId;
@NotBlank(message = "名称不能为空")
@Schema(description = "名称")
private String name;
@Schema(description = "性别")
@NotNull(message = "性别不能为空")
private Sex sex;
@IsMobile
@NotBlank(message = "手机号不能为空")
private String telephone;
@NotNull(message = "启用状态不能为空")
@Schema(description = "启用状态")
private IsEnable isEnable;
@Schema(description = "备注")
private String remark;
}

View File

@ -0,0 +1,13 @@
package com.changhu.module.management.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.changhu.module.management.pojo.entity.EnterprisesUnit;
/**
* enterprises_unit (企事业单位) 服务类
* author: luozhun
* desc 由groovy脚本自动生成
*/
public interface EnterprisesUnitService extends IService<EnterprisesUnit>{
}

View File

@ -2,6 +2,7 @@ package com.changhu.module.management.service;
import com.changhu.module.management.pojo.params.IndexCheckPassParams; import com.changhu.module.management.pojo.params.IndexCheckPassParams;
import com.changhu.module.management.pojo.params.IndexCheckStatusParams; import com.changhu.module.management.pojo.params.IndexCheckStatusParams;
import com.changhu.module.management.pojo.params.IndexDisableOrEnableParams;
import com.changhu.module.management.pojo.vo.UnitCheckStatusVo; import com.changhu.module.management.pojo.vo.UnitCheckStatusVo;
/** /**
@ -25,4 +26,11 @@ public interface IndexService {
* @return 结果 * @return 结果
*/ */
UnitCheckStatusVo getCheckStatus(IndexCheckStatusParams params); UnitCheckStatusVo getCheckStatus(IndexCheckStatusParams params);
/**
* 启用或者禁用单位
*
* @param params 参数
*/
void disableOrEnable(IndexDisableOrEnableParams params);
} }

View File

@ -2,6 +2,7 @@ package com.changhu.module.management.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.changhu.module.management.pojo.entity.ManagementSecurityUnitUser; import com.changhu.module.management.pojo.entity.ManagementSecurityUnitUser;
import com.changhu.module.management.pojo.params.ManagementSecurityUnitUserSaveOrUpdateParams;
/** /**
* management_security_unit_user (后台-保安单位用户表) 服务类 * management_security_unit_user (后台-保安单位用户表) 服务类
@ -10,4 +11,10 @@ import com.changhu.module.management.pojo.entity.ManagementSecurityUnitUser;
*/ */
public interface ManagementSecurityUnitUserService extends IService<ManagementSecurityUnitUser> { public interface ManagementSecurityUnitUserService extends IService<ManagementSecurityUnitUser> {
/**
* 新增或者修改
*
* @param saveOrUpdateParams 参数
*/
void saveOrUpdate(ManagementSecurityUnitUserSaveOrUpdateParams saveOrUpdateParams);
} }

View File

@ -0,0 +1,17 @@
package com.changhu.module.management.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.changhu.module.management.mapper.EnterprisesUnitMapper;
import com.changhu.module.management.pojo.entity.EnterprisesUnit;
import com.changhu.module.management.service.EnterprisesUnitService;
import org.springframework.stereotype.Service;
/**
* enterprises_unit (企事业单位) 服务实现类
* author: luozhun
* desc 由groovy脚本自动生成
*/
@Service
public class EnterprisesUnitServiceImpl extends ServiceImpl<EnterprisesUnitMapper, EnterprisesUnit> implements EnterprisesUnitService {
}

View File

@ -2,6 +2,7 @@ package com.changhu.module.management.service.impl;
import com.changhu.module.management.pojo.params.IndexCheckPassParams; import com.changhu.module.management.pojo.params.IndexCheckPassParams;
import com.changhu.module.management.pojo.params.IndexCheckStatusParams; import com.changhu.module.management.pojo.params.IndexCheckStatusParams;
import com.changhu.module.management.pojo.params.IndexDisableOrEnableParams;
import com.changhu.module.management.pojo.vo.UnitCheckStatusVo; import com.changhu.module.management.pojo.vo.UnitCheckStatusVo;
import com.changhu.module.management.service.IndexService; import com.changhu.module.management.service.IndexService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -26,4 +27,11 @@ public class IndexServiceImpl implements IndexService {
.getHandler() .getHandler()
.getCheckStatus(params.getOnlyCode()); .getCheckStatus(params.getOnlyCode());
} }
@Override
public void disableOrEnable(IndexDisableOrEnableParams params) {
params.getUnitOptType()
.getHandler()
.disableOrEnable(params.getUnitId());
}
} }

View File

@ -1,10 +1,19 @@
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.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.changhu.common.exception.MessageException;
import com.changhu.common.utils.UserUtil;
import com.changhu.module.management.mapper.ManagementSecurityUnitUserMapper; import com.changhu.module.management.mapper.ManagementSecurityUnitUserMapper;
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.service.ManagementSecurityUnitUserService; import com.changhu.module.management.service.ManagementSecurityUnitUserService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/** /**
* management_security_unit_user (后台-保安单位用户表) 服务实现类 * management_security_unit_user (后台-保安单位用户表) 服务实现类
@ -14,4 +23,34 @@ import org.springframework.stereotype.Service;
@Service @Service
public class ManagementSecurityUnitUserServiceImpl extends ServiceImpl<ManagementSecurityUnitUserMapper, ManagementSecurityUnitUser> implements ManagementSecurityUnitUserService { public class ManagementSecurityUnitUserServiceImpl extends ServiceImpl<ManagementSecurityUnitUserMapper, ManagementSecurityUnitUser> implements ManagementSecurityUnitUserService {
@Transactional(rollbackFor = Exception.class)
@Override
public void saveOrUpdate(ManagementSecurityUnitUserSaveOrUpdateParams saveOrUpdateParams) {
//查看手机号是否已存在
boolean exists = this.lambdaQuery()
.eq(ManagementSecurityUnitUser::getTelephone, saveOrUpdateParams.getTelephone())
.exists();
if (exists) {
throw new MessageException("该手机号已存在");
}
ManagementSecurityUnitUser managementSecurityUnitUser = BeanUtil.copyProperties(saveOrUpdateParams, ManagementSecurityUnitUser.class);
//新增 需要补全一些信息
if (managementSecurityUnitUser.getSnowFlakeId() == null) {
String account = RandomUtil.randomString(6);
boolean accExits = this.lambdaQuery()
.eq(ManagementSecurityUnitUser::getAccount, account)
.exists();
if (accExits) {
throw new MessageException("生成的账号已存在 请重新提交生成");
}
//生成账号
managementSecurityUnitUser.setAccount(account);
//生成密码
String passWordEncrypt = UserUtil.passWordEncrypt(UserUtil.DEFAULT_PASSWORD);
List<String> saltAndPassWord = StrUtil.split(passWordEncrypt, "$$");
managementSecurityUnitUser.setSalt(saltAndPassWord.get(0));
managementSecurityUnitUser.setPassword(saltAndPassWord.get(1));
}
this.saveOrUpdate(managementSecurityUnitUser);
}
} }

View File

@ -0,0 +1,19 @@
package com.changhu.pojo.params;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
/**
* @author 20252
* @createTime 2024/9/2 下午4:53
* @desc ManagementPoliceUnitLoginParams...
*/
@Data
public class ManagementPoliceUnitLoginParams {
@NotBlank(message = "账号/手机号不能为空")
private String accountOrTelephone;
@NotBlank(message = "密码不能为空")
private String password;
}

View File

@ -0,0 +1,19 @@
package com.changhu.pojo.params;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
/**
* @author 20252
* @createTime 2024/9/2 下午4:53
* @desc ManagementPoliceUnitLoginParams...
*/
@Data
public class ManagementSecurityUnitLoginParams {
@NotBlank(message = "账号/手机号不能为空")
private String accountOrTelephone;
@NotBlank(message = "密码不能为空")
private String password;
}

View File

@ -0,0 +1,162 @@
/* 扩展ant design pro按钮组件颜色 */
$--my-antd-important: !important;
.btn-danger {
color: #ffffff;
background-color: #F5222D;
border-color: #F5222D;
&:hover, &:focus {
color: #ffffff $--my-antd-important;
background-color: #ff4d4f $--my-antd-important;
border-color: #ff4d4f $--my-antd-important;
}
&:active, &.active {
color: #ffffff $--my-antd-important;
background-color: #cf1322 $--my-antd-important;
border-color: #cf1322 $--my-antd-important;
}
}
.btn-volcano {
color: #ffffff;
background-color: #FA541C;
border-color: #FA541C;
&:hover, &:focus {
color: #ffffff $--my-antd-important;
background-color: #ff7a45 $--my-antd-important;
border-color: #ff7a45 $--my-antd-important;
}
&:active, &.active {
color: #ffffff $--my-antd-important;
background-color: #d4380d $--my-antd-important;
border-color: #d4380d $--my-antd-important;
}
}
.btn-warn {
color: #ffffff;
background-color: #FAAD14;
border-color: #FAAD14;
&:hover, &:focus {
color: #ffffff $--my-antd-important;
background-color: #ffc53d $--my-antd-important;
border-color: #ffc53d $--my-antd-important;
}
&:active, &.active {
color: #ffffff $--my-antd-important;
background-color: #d48806 $--my-antd-important;
border-color: #d48806 $--my-antd-important;
}
}
.btn-success {
color: #ffffff;
background-color: #52C41A;
border-color: #52C41A;
&:hover, &:focus {
color: #ffffff $--my-antd-important;
background-color: #73d13d $--my-antd-important;
border-color: #73d13d $--my-antd-important;
}
&:active, &.active {
color: #ffffff $--my-antd-important;
background-color: #389e0d $--my-antd-important;
border-color: #389e0d $--my-antd-important;
}
}
.button-color-cyan {
color: #ffffff;
background-color: #13C2C2;
border-color: #13C2C2;
&:hover, &:focus {
color: #ffffff $--my-antd-important;
background-color: #36cfc9 $--my-antd-important;
border-color: #36cfc9 $--my-antd-important;
}
&:active, &.active {
color: #ffffff $--my-antd-important;
background-color: #08979c $--my-antd-important;
border-color: #08979c $--my-antd-important;
}
}
.btn-daybreak {
color: #ffffff;
background-color: #1890FF;
border-color: #1890FF;
&:hover, &:focus {
color: #ffffff $--my-antd-important;
background-color: #096dd9 $--my-antd-important;
border-color: #096dd9 $--my-antd-important;
}
&:active, &.active {
color: #ffffff $--my-antd-important;
background-color: #40a9ff $--my-antd-important;
border-color: #40a9ff $--my-antd-important;
}
}
.button-color-geekblue {
color: #ffffff;
background-color: #2F54EB;
border-color: #2F54EB;
&:hover, &:focus {
color: #ffffff $--my-antd-important;
background-color: #1d39c4 $--my-antd-important;
border-color: #1d39c4 $--my-antd-important;
}
&:active, &.active {
color: #ffffff $--my-antd-important;
background-color: #597ef7 $--my-antd-important;
border-color: #597ef7 $--my-antd-important;
}
}
.btn-purple {
color: #ffffff;
background-color: #722ED1;
border-color: #722ED1;
&:hover, &:focus {
color: #ffffff $--my-antd-important;
background-color: #9254de $--my-antd-important;
border-color: #9254de $--my-antd-important;
}
&:active, &.active {
color: #ffffff $--my-antd-important;
background-color: #531dab $--my-antd-important;
border-color: #531dab $--my-antd-important;
}
}
.table-row-warn td {
background-color: #fefca6;
}
.table-row-danger td {
background-color: #f79988;
}
.table-row-success td {
background-color: #b6fcbe;
}
.ant-table-summary td {
background: #edeff6;
}

View File

@ -7,11 +7,11 @@ type DictType =
| 'IsOrNot' | 'IsOrNot'
| 'Sex' | 'Sex'
export const initEnums = () => { export const initDict = () => {
api.get<Record<DictType, SelectNodeVo<any>[]>>('/common/enums').then(resp => { api.get<Record<DictType, SelectNodeVo<any>[]>>('/common/enums').then(resp => {
sessionStorage.setItem('dictMap', JSON.stringify(resp.data)) sessionStorage.setItem('dictMap', JSON.stringify(resp.data))
}) })
} }
export const enumSelectNodes = <T>(enumType: DictType): SelectNodeVo<T>[] => JSON.parse(sessionStorage.getItem('dictMap') as string)?.[enumType] || [] export const dictSelectNodes = <T>(dictType: DictType): SelectNodeVo<T>[] => JSON.parse(sessionStorage.getItem('dictMap') as string)?.[dictType] || []

View File

@ -2,6 +2,10 @@ import {SystemMenu} from "@/types/config";
export const CLIENT_TYPE = "MANAGEMENT_SUPER"; export const CLIENT_TYPE = "MANAGEMENT_SUPER";
export const ROUTER_WHITE_LIST: string[] = ['/login', '/test']; export const ROUTER_WHITE_LIST: string[] = ['/login', '/test'];
export const UNIT_TYPE = {
security: 'SECURITY_UNIT',
police: 'POLICE_UNIT'
}
export const SYSTEM_MENUS: SystemMenu[] = [ export const SYSTEM_MENUS: SystemMenu[] = [
{ {
@ -28,6 +32,12 @@ export const SYSTEM_MENUS: SystemMenu[] = [
path: '/securityUnit', path: '/securityUnit',
type: 'menu', type: 'menu',
component: () => import('@/views/unitManage/securityUnit/index.vue') component: () => import('@/views/unitManage/securityUnit/index.vue')
}, {
title: '企事业单位',
name: 'enterprisesUnit',
path: '/enterprisesUnit',
type: 'menu',
component: () => import('@/views/unitManage/enterprisesUnit/index.vue')
} }
] ]
} }

View File

@ -4,15 +4,17 @@ import '@/reset.css'
// 公共样式 // 公共样式
import '@/assets/scss/common.scss' import '@/assets/scss/common.scss'
//ant design 扩展样式
import '@/assets/scss/myAntD.scss'
// iconfont css // iconfont css
import "@/assets/iconfont/iconfont.css"; import "@/assets/iconfont/iconfont.css";
// vue Router // vue Router
import router from "@/router"; import router from "@/router";
// pinia stores // pinia stores
import pinia from "@/stores"; import pinia from "@/stores";
import {initEnums} from "@/config/dict.ts"; import {initDict} from "@/config/dict.ts";
initEnums(); initDict();
const vueApp = createApp(App); const vueApp = createApp(App);

View File

@ -0,0 +1,13 @@
<template>
<div>
企事业单位管理
</div>
</template>
<script setup lang="ts">
</script>
<style scoped lang="scss">
</style>

View File

@ -16,8 +16,9 @@ import {ComponentExposed} from "vue-component-type-helpers";
import {TableProMaxProps} from "@/types/components/table"; import {TableProMaxProps} from "@/types/components/table";
import {PoliceUnitPagerQueryParams, PoliceUnitPagerVo} from "@/types/views/unitManage/policeUnit.ts"; import {PoliceUnitPagerQueryParams, PoliceUnitPagerVo} from "@/types/views/unitManage/policeUnit.ts";
import api from "@/axios"; import api from "@/axios";
import {enumSelectNodes} from "@/config/dict.ts"; import {dictSelectNodes} from "@/config/dict.ts";
import {message} from "ant-design-vue"; import {message} from "ant-design-vue";
import {UNIT_TYPE} from "@/config";
type TableProps = TableProMaxProps<PoliceUnitPagerVo, PoliceUnitPagerQueryParams> type TableProps = TableProMaxProps<PoliceUnitPagerVo, PoliceUnitPagerQueryParams>
@ -61,7 +62,7 @@ const columns: TableProps['columns'] = [
onConfirm={async () => { onConfirm={async () => {
const resp = await api.post('/management/checkPass', { const resp = await api.post('/management/checkPass', {
checkDataId: record.snowFlakeId, checkDataId: record.snowFlakeId,
unitOptType: 'POLICE_UNIT' unitOptType: UNIT_TYPE.police
}) })
message.success(resp.message) message.success(resp.message)
await tableRef.value?.requestGetTableData() await tableRef.value?.requestGetTableData()
@ -70,7 +71,17 @@ const columns: TableProps['columns'] = [
</a-button> </a-button>
</a-popconfirm> </a-popconfirm>
} }
{record.isEnable.value === 0 ? <a-button danger>禁用</a-button> : <a-button></a-button>} <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.police
})
message.success(resp.message)
await tableRef.value?.requestGetTableData()
}}
>{record.isEnable.value === 0 ? '禁用' : '启用'}</a-button>
</a-space> </a-space>
}, },
} }
@ -89,7 +100,7 @@ const searchFormOptions: TableProps["searchFormOptions"] = {
{ {
value: null, value: null,
label: '全部' label: '全部'
}, ...enumSelectNodes('IsEnable') }, ...dictSelectNodes('IsEnable')
] ]
}, checkStatus: { }, checkStatus: {
type: 'select', type: 'select',
@ -98,7 +109,7 @@ const searchFormOptions: TableProps["searchFormOptions"] = {
{ {
value: null, value: null,
label: '全部' label: '全部'
}, ...enumSelectNodes('CheckStatus') }, ...dictSelectNodes('CheckStatus')
] ]
} }
} }

View File

@ -17,8 +17,10 @@ import {SecurityUnitPagerQueryParams, SecurityUnitPagerVo} from "@/types/views/u
import api from "@/axios"; import api from "@/axios";
import {ref} from "vue"; import {ref} from "vue";
import {ComponentExposed} from "vue-component-type-helpers"; import {ComponentExposed} from "vue-component-type-helpers";
import {enumSelectNodes} from "@/config/dict.ts"; import {dictSelectNodes} from "@/config/dict.ts";
import {message} from "ant-design-vue"; import {message} from "ant-design-vue";
import {UNIT_TYPE} from "@/config";
type TableProps = TableProMaxProps<SecurityUnitPagerVo, SecurityUnitPagerQueryParams> type TableProps = TableProMaxProps<SecurityUnitPagerVo, SecurityUnitPagerQueryParams>
@ -85,7 +87,7 @@ const columns: TableProps['columns'] = [
onConfirm={async () => { onConfirm={async () => {
const resp = await api.post('/management/checkPass', { const resp = await api.post('/management/checkPass', {
checkDataId: record.snowFlakeId, checkDataId: record.snowFlakeId,
unitOptType: 'SECURITY_UNIT' unitOptType: UNIT_TYPE.security
}) })
message.success(resp.message) message.success(resp.message)
await tableRef.value?.requestGetTableData() await tableRef.value?.requestGetTableData()
@ -94,7 +96,17 @@ const columns: TableProps['columns'] = [
</a-button> </a-button>
</a-popconfirm> </a-popconfirm>
} }
{record.isEnable.value === 0 ? <a-button danger>禁用</a-button> : <a-button></a-button>} <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-space> </a-space>
}, },
width: 200 width: 200
@ -115,7 +127,7 @@ const searchFormOptions: TableProps["searchFormOptions"] = {
{ {
value: null, value: null,
label: '全部' label: '全部'
}, ...enumSelectNodes('IsEnable') }, ...dictSelectNodes('IsEnable')
] ]
}, checkStatus: { }, checkStatus: {
type: 'select', type: 'select',
@ -124,7 +136,7 @@ const searchFormOptions: TableProps["searchFormOptions"] = {
{ {
value: null, value: null,
label: '全部' label: '全部'
}, ...enumSelectNodes('CheckStatus') }, ...dictSelectNodes('CheckStatus')
] ]
} }
} }