企事业单位 服务项目 小程序注册及登录
This commit is contained in:
parent
3c461b4853
commit
6f0c121dea
|
@ -1,10 +1,8 @@
|
|||
package com.changhu.common.annotation;
|
||||
|
||||
import com.changhu.enums.ClientType;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 20252
|
||||
|
|
|
@ -9,7 +9,6 @@ import cn.hutool.crypto.SecureUtil;
|
|||
import com.changhu.common.annotation.UserType;
|
||||
import com.changhu.common.enums.ResultCode;
|
||||
import com.changhu.common.exception.MessageException;
|
||||
import com.changhu.enums.ClientType;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Optional;
|
||||
|
@ -59,7 +58,7 @@ public class UserUtil {
|
|||
if (clientType instanceof String ct) {
|
||||
return UserType.valueOf(ct);
|
||||
}
|
||||
return null;
|
||||
throw new MessageException("获取不到用户类型");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,8 +2,8 @@ package com.changhu.config;
|
|||
|
||||
import cn.dev33.satoken.interceptor.SaInterceptor;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.changhu.support.interceptor.UserTypeInterceptor;
|
||||
import com.changhu.support.interceptor.JsonBodyInterceptor;
|
||||
import com.changhu.support.interceptor.UserTypeInterceptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
|
@ -28,7 +28,6 @@ public class WebConfig implements WebMvcConfigurer {
|
|||
whiteList.add("/test/**");
|
||||
whiteList.add("/login");
|
||||
whiteList.add("/logout");
|
||||
whiteList.add("/management/getCheckStatus");
|
||||
whiteList.add("/favicon.ico");
|
||||
//druid console
|
||||
whiteList.add("/druid/**");
|
||||
|
@ -38,8 +37,10 @@ public class WebConfig implements WebMvcConfigurer {
|
|||
whiteList.add("/swagger-resources");
|
||||
whiteList.add("/**webjars/**");
|
||||
whiteList.add("/v3/**");
|
||||
//平台信息
|
||||
whiteList.add("/platformSetting/getPlatformInfo");
|
||||
//获取企业注册审核状态
|
||||
whiteList.add("/management/getCheckStatus");
|
||||
//微信小程序注册
|
||||
whiteList.add("/miniProgramUser/register");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.changhu.common.pojo.vo.SelectNodeVo;
|
|||
import com.changhu.common.pojo.vo.TreeNodeVo;
|
||||
import com.changhu.pojo.params.PoliceUnitRegisterParams;
|
||||
import com.changhu.pojo.params.SecurityUnitRegisterParams;
|
||||
import com.changhu.pojo.queryParams.QueryUnitListByIdentityQueryParams;
|
||||
import com.changhu.service.AdministrativeDivisionService;
|
||||
import com.changhu.service.CommonService;
|
||||
import com.changhu.support.minio.service.MinioService;
|
||||
|
@ -59,6 +60,12 @@ public class CommonController {
|
|||
return administrativeDivisionService.tree(level);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据父编码查询子级行政区划")
|
||||
@GetMapping("/administrativeDivisionByParentCode")
|
||||
public List<TreeNodeVo<String>> administrativeDivisionByParentCode(@Schema(description = "父编码") @RequestParam(defaultValue = "0") String parentCode) {
|
||||
return administrativeDivisionService.administrativeDivisionByParentCode(parentCode);
|
||||
}
|
||||
|
||||
@Operation(summary = "保安单位注册")
|
||||
@PostMapping("/securityUnitRegister")
|
||||
public JsonResult<Void> securityUnitRegister(@RequestBody @Valid SecurityUnitRegisterParams params) {
|
||||
|
@ -78,6 +85,14 @@ public class CommonController {
|
|||
return minioService.getResignedObjectUrl(bucketName, objectName);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据身份查询单位列表")
|
||||
@PostMapping("/queryUnitListByIdentity")
|
||||
public List<SelectNodeVo<Long>> queryUnitListByIdentity(@RequestBody QueryUnitListByIdentityQueryParams queryParams) {
|
||||
return commonService.queryUnitListByIdentity(queryParams);
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "字典数据")
|
||||
@GetMapping("/enums")
|
||||
public Map<String, List<SelectNodeVo<?>>> enums() {
|
||||
return enumsResult;
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package com.changhu.enums;
|
||||
|
||||
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.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
|
@ -18,7 +15,7 @@ public enum ClientType {
|
|||
MANAGEMENT_SUPER("超级后台", ManagementSuperLogin.instance),
|
||||
MANAGEMENT_POLICE("公安后台", ManagementPoliceUnitLogin.instance),
|
||||
MANAGEMENT_SECURITY("保安后台", ManagementSecurityUnitLogin.instance),
|
||||
MINI_PROGRAM("微信小程序", ManagementSuperLogin.instance),
|
||||
MINI_PROGRAM("微信小程序", MiniProgramUserLogin.instance),
|
||||
;
|
||||
|
||||
private final String remark;
|
||||
|
|
|
@ -11,7 +11,6 @@ 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.enums.ClientType;
|
||||
import com.changhu.module.management.pojo.entity.ManagementSecurityUnitUser;
|
||||
import com.changhu.module.management.pojo.entity.SecurityUnit;
|
||||
import com.changhu.pojo.params.ManagementSecurityUnitLoginParams;
|
||||
|
|
|
@ -10,7 +10,6 @@ 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.enums.ClientType;
|
||||
import com.changhu.module.management.pojo.entity.ManagementSuperUser;
|
||||
import com.changhu.pojo.params.ManagementSuperLoginParams;
|
||||
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
package com.changhu.enums.handler;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
||||
import cn.dev33.satoken.stp.SaTokenInfo;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.toolkit.Db;
|
||||
import com.changhu.common.annotation.UserType;
|
||||
import com.changhu.common.enums.ResultCode;
|
||||
import com.changhu.common.exception.MessageException;
|
||||
import com.changhu.common.pojo.vo.TokenInfo;
|
||||
import com.changhu.common.utils.UserUtil;
|
||||
import com.changhu.common.utils.ValidatorUtil;
|
||||
import com.changhu.module.miniProgram.pojo.entity.MiniProgramUser;
|
||||
import com.changhu.pojo.params.MiniProgramUserLoginParams;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
|
||||
/**
|
||||
* @author 20252
|
||||
* @createTime 2024/9/10 上午10:00
|
||||
* @desc MiniProgramUserLogin...
|
||||
*/
|
||||
public class MiniProgramUserLogin extends AbstractLoginHandler {
|
||||
|
||||
public static final MiniProgramUserLogin instance = new MiniProgramUserLogin();
|
||||
|
||||
private MiniProgramUserLogin() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TokenInfo login(JSONObject jsonObject) {
|
||||
MiniProgramUserLoginParams loginParams = jsonObject.to(MiniProgramUserLoginParams.class);
|
||||
ValidatorUtil.manual(loginParams);
|
||||
String code = loginParams.getCode();
|
||||
|
||||
String openId;
|
||||
final WxMaService wxMaService = SpringUtil.getBean(WxMaService.class);
|
||||
|
||||
try {
|
||||
WxMaJscode2SessionResult sessionInfo = wxMaService.getUserService().getSessionInfo(code);
|
||||
openId = sessionInfo.getOpenid();
|
||||
} catch (WxErrorException e) {
|
||||
throw new MessageException(e.getMessage());
|
||||
}
|
||||
|
||||
MiniProgramUser miniProgramUser = Db.lambdaQuery(MiniProgramUser.class)
|
||||
.eq(MiniProgramUser::getOpenId, openId)
|
||||
.oneOpt()
|
||||
.orElseThrow(() -> new MessageException(ResultCode.USER_NOT_FOUND));
|
||||
|
||||
UserType userType = switch (miniProgramUser.getIdentity()) {
|
||||
case POLICE -> UserType.MINI_PROGRAM_POLICE;
|
||||
case PROJECT_MANAGER -> UserType.MINI_PROGRAM_PROJECT_MANAGE;
|
||||
};
|
||||
|
||||
//登录
|
||||
SaTokenInfo saTokenInfo = UserUtil.loginAndTokenInfo(
|
||||
miniProgramUser.getSnowFlakeId(),
|
||||
userType,
|
||||
miniProgramUser.getUnitId());
|
||||
//返回token
|
||||
return new TokenInfo(saTokenInfo.getTokenName(), saTokenInfo.getTokenValue());
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package com.changhu.module.management.controller;
|
||||
|
||||
import com.changhu.common.annotation.JsonBody;
|
||||
import com.changhu.module.management.pojo.params.IndexCheckPassParams;
|
||||
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.service.IndexService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author 20252
|
||||
* @createTime 2024/9/2 上午9:48
|
||||
* @desc IndexController...
|
||||
*/
|
||||
@Tag(name = "后台-通用接口")
|
||||
@JsonBody
|
||||
@RequestMapping("/management")
|
||||
public class IndexController {
|
||||
|
||||
@Autowired
|
||||
private IndexService indexService;
|
||||
|
||||
@Operation(summary = "审核通过")
|
||||
@PostMapping("/checkPass")
|
||||
public void checkPass(@RequestBody @Valid IndexCheckPassParams params) {
|
||||
indexService.checkPass(params);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取审核状态")
|
||||
@PostMapping("/getCheckStatus")
|
||||
public UnitCheckStatusVo getCheckStatus(@RequestBody @Valid IndexCheckStatusParams params) {
|
||||
return indexService.getCheckStatus(params);
|
||||
}
|
||||
|
||||
@Operation(summary = "启用或禁用状态")
|
||||
@PostMapping("/disableOrEnable")
|
||||
public void disableOrEnable(@RequestBody @Valid IndexDisableOrEnableParams params) {
|
||||
indexService.disableOrEnable(params);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package com.changhu.module.management.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.changhu.common.annotation.CheckUserType;
|
||||
import com.changhu.common.annotation.JsonBody;
|
||||
import com.changhu.common.annotation.UserType;
|
||||
import com.changhu.module.management.pojo.params.IndexCheckPassParams;
|
||||
import com.changhu.module.management.pojo.params.IndexCheckStatusParams;
|
||||
import com.changhu.module.management.pojo.params.IndexDisableOrEnableParams;
|
||||
import com.changhu.module.management.pojo.queryParams.UnitMiniProgramUserPagerQueryParams;
|
||||
import com.changhu.module.management.pojo.vo.UnitCheckStatusVo;
|
||||
import com.changhu.module.management.pojo.vo.UnitMiniProgramUserPagerVo;
|
||||
import com.changhu.module.management.service.ManagementService;
|
||||
import com.changhu.support.mybatisplus.pojo.params.PageParams;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author 20252
|
||||
* @createTime 2024/9/2 上午9:48
|
||||
* @desc IndexController...
|
||||
*/
|
||||
@Tag(name = "后台-通用接口")
|
||||
@JsonBody
|
||||
@RequestMapping("/management")
|
||||
public class ManagementController {
|
||||
|
||||
@Autowired
|
||||
private ManagementService managementService;
|
||||
|
||||
@Operation(summary = "审核通过")
|
||||
@PostMapping("/checkPass")
|
||||
public void checkPass(@RequestBody @Valid IndexCheckPassParams params) {
|
||||
managementService.checkPass(params);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取审核状态")
|
||||
@PostMapping("/getCheckStatus")
|
||||
public UnitCheckStatusVo getCheckStatus(@RequestBody @Valid IndexCheckStatusParams params) {
|
||||
return managementService.getCheckStatus(params);
|
||||
}
|
||||
|
||||
@Operation(summary = "启用或禁用状态")
|
||||
@PostMapping("/disableOrEnable")
|
||||
public void disableOrEnable(@RequestBody @Valid IndexDisableOrEnableParams params) {
|
||||
managementService.disableOrEnable(params);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询单位下的小程序用户")
|
||||
@PostMapping("/miniProgramUserPager")
|
||||
@CheckUserType(userTypes = {UserType.MANAGEMENT_POLICE, UserType.MANAGEMENT_SECURITY})
|
||||
public Page<UnitMiniProgramUserPagerVo> miniProgramUserPager(@RequestBody PageParams<UnitMiniProgramUserPagerQueryParams, UnitMiniProgramUserPagerVo> queryParams) {
|
||||
return managementService.miniProgramUserPager(queryParams);
|
||||
}
|
||||
|
||||
@Operation(summary = "审核通过小程序用户")
|
||||
@PostMapping("/passMiniProgramUser")
|
||||
public void passMiniProgramUser(@RequestBody @Valid IndexDisableOrEnableParams params) {
|
||||
managementService.passMiniProgramUser(params);
|
||||
}
|
||||
|
||||
@Operation(summary = "禁用或启用小程序用户")
|
||||
@PostMapping("/disableOrEnableMiniProgramUser")
|
||||
public void disableOrEnableMiniProgramUser(@RequestBody @Valid IndexDisableOrEnableParams params) {
|
||||
managementService.disableOrEnableMiniProgramUser(params);
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.changhu.common.annotation.CheckUserType;
|
||||
import com.changhu.common.annotation.JsonBody;
|
||||
import com.changhu.common.annotation.UserType;
|
||||
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;
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.changhu.common.annotation.CheckUserType;
|
||||
import com.changhu.common.annotation.JsonBody;
|
||||
import com.changhu.common.annotation.UserType;
|
||||
import com.changhu.enums.ClientType;
|
||||
import com.changhu.module.management.pojo.params.ManagementSecurityUnitUserSaveOrUpdateParams;
|
||||
import com.changhu.module.management.pojo.queryParams.ManagementSecurityUnitUserPagerQueryParams;
|
||||
import com.changhu.module.management.pojo.vo.ManagementSecurityUnitUserPagerVo;
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.changhu.common.annotation.CheckUserType;
|
||||
import com.changhu.common.annotation.JsonBody;
|
||||
import com.changhu.common.annotation.UserType;
|
||||
import com.changhu.enums.ClientType;
|
||||
import com.changhu.module.management.pojo.queryParams.PoliceEnterprisesUnitPagerQueryParams;
|
||||
import com.changhu.module.management.pojo.queryParams.PoliceUnitPagerQueryParams;
|
||||
import com.changhu.module.management.pojo.vo.PoliceEnterprisesUnitPagerVo;
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.changhu.common.annotation.CheckUserType;
|
|||
import com.changhu.common.annotation.JsonBody;
|
||||
import com.changhu.common.annotation.UserType;
|
||||
import com.changhu.common.pojo.vo.SelectNodeVo;
|
||||
import com.changhu.enums.ClientType;
|
||||
import com.changhu.module.management.pojo.params.SecurityUnitSaveOrUpdateParams;
|
||||
import com.changhu.module.management.pojo.queryParams.SecurityUnitPagerQueryParams;
|
||||
import com.changhu.module.management.pojo.vo.SecurityUnitPagerVo;
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.changhu.common.annotation.CheckUserType;
|
|||
import com.changhu.common.annotation.JsonBody;
|
||||
import com.changhu.common.annotation.UserType;
|
||||
import com.changhu.common.exception.MessageException;
|
||||
import com.changhu.enums.ClientType;
|
||||
import com.changhu.module.management.pojo.params.ServiceProjectSaveOrUpdateParams;
|
||||
import com.changhu.module.management.pojo.queryParams.ServiceProjectPagerQueryParams;
|
||||
import com.changhu.module.management.pojo.vo.ServiceProjectPagerVo;
|
||||
|
@ -24,6 +23,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
@Tag(name = "服务项目")
|
||||
@JsonBody
|
||||
@RequestMapping("/serviceProject")
|
||||
@CheckUserType(userTypes = UserType.MANAGEMENT_SECURITY)
|
||||
public class ServiceProjectController {
|
||||
|
||||
@Autowired
|
||||
|
@ -31,14 +31,12 @@ public class ServiceProjectController {
|
|||
|
||||
@Operation(summary = "分页查询")
|
||||
@PostMapping("/pager")
|
||||
@CheckUserType(userTypes = UserType.MANAGEMENT_SECURITY)
|
||||
public Page<ServiceProjectPagerVo> pager(@RequestBody PageParams<ServiceProjectPagerQueryParams, ServiceProjectPagerVo> queryParams) {
|
||||
return serviceProjectService.pager(queryParams);
|
||||
}
|
||||
|
||||
@Operation(summary = "新增或者保存")
|
||||
@PostMapping("/saveOrUpdate")
|
||||
@CheckUserType(userTypes = UserType.MANAGEMENT_SECURITY)
|
||||
public void saveOrUpdate(@RequestBody ServiceProjectSaveOrUpdateParams params) {
|
||||
serviceProjectService.saveOrUpdate(params);
|
||||
}
|
||||
|
|
|
@ -32,4 +32,18 @@ public abstract class AbstractUnitTypeHandler {
|
|||
* @param unitId 单位id
|
||||
*/
|
||||
public abstract void disableOrEnable(Long unitId);
|
||||
|
||||
/**
|
||||
* 审核通过单位内的小程序用户
|
||||
*
|
||||
* @param miniProgramUserId 小程序用户id
|
||||
*/
|
||||
public abstract void passMiniProgramUser(Long miniProgramUserId);
|
||||
|
||||
/**
|
||||
* 启用或禁用小程序用户
|
||||
*
|
||||
* @param miniProgramUserId 小程序用户id
|
||||
*/
|
||||
public abstract void disableOrEnableMiniProgramUser(Long miniProgramUserId);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ public class PoliceUnitTypeHandler extends AbstractUnitTypeHandler {
|
|||
private final ManagementPoliceUnitUserService policeUnitUserService = SpringUtil.getBean(ManagementPoliceUnitUserService.class);
|
||||
|
||||
@Override
|
||||
|
||||
public void pass(Long checkDataId) {
|
||||
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
|
||||
TransactionStatus status = transactionManager.getTransaction(def);
|
||||
|
@ -125,4 +124,14 @@ public class PoliceUnitTypeHandler extends AbstractUnitTypeHandler {
|
|||
throw new MessageException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void passMiniProgramUser(Long miniProgramUserId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableOrEnableMiniProgramUser(Long miniProgramUserId) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ import com.changhu.module.management.pojo.entity.SecurityUnit;
|
|||
import com.changhu.module.management.pojo.vo.UnitCheckStatusVo;
|
||||
import com.changhu.module.management.service.ManagementSecurityUnitUserService;
|
||||
import com.changhu.module.management.service.SecurityUnitService;
|
||||
import com.changhu.module.miniProgram.pojo.entity.MiniProgramUser;
|
||||
import com.changhu.module.miniProgram.service.MiniProgramUserService;
|
||||
import com.changhu.support.mybatisplus.pojo.entity.BaseEntity;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
|
@ -34,6 +36,8 @@ public class SecurityUnitTypeHandler extends AbstractUnitTypeHandler {
|
|||
|
||||
private final ManagementSecurityUnitUserService securityUnitUserService = SpringUtil.getBean(ManagementSecurityUnitUserService.class);
|
||||
|
||||
private final MiniProgramUserService miniProgramUserService = SpringUtil.getBean(MiniProgramUserService.class);
|
||||
|
||||
@Override
|
||||
public void pass(Long checkDataId) {
|
||||
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
|
||||
|
@ -126,4 +130,38 @@ public class SecurityUnitTypeHandler extends AbstractUnitTypeHandler {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void passMiniProgramUser(Long miniProgramUserId) {
|
||||
boolean update = miniProgramUserService.lambdaUpdate()
|
||||
.set(MiniProgramUser::getCheckStatus, CheckStatus.checked)
|
||||
.eq(BaseEntity::getSnowFlakeId, miniProgramUserId)
|
||||
.update();
|
||||
if (!update) {
|
||||
throw new MessageException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableOrEnableMiniProgramUser(Long miniProgramUserId) {
|
||||
MiniProgramUser miniProgramUser = miniProgramUserService.lambdaQuery()
|
||||
.eq(BaseEntity::getSnowFlakeId, miniProgramUserId)
|
||||
.oneOpt()
|
||||
.orElseThrow(() -> new MessageException(ResultCode.DATA_NOT_FOUND));
|
||||
|
||||
//取反
|
||||
IsEnable isEnable = switch (miniProgramUser.getIsEnable()) {
|
||||
case TRUE -> IsEnable.FALSE;
|
||||
case FALSE -> IsEnable.TRUE;
|
||||
};
|
||||
|
||||
boolean update = miniProgramUserService.lambdaUpdate()
|
||||
.set(MiniProgramUser::getIsEnable, isEnable)
|
||||
.eq(BaseEntity::getSnowFlakeId, miniProgramUserId)
|
||||
.update();
|
||||
if (!update) {
|
||||
throw new MessageException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
package com.changhu.module.management.pojo.entity;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.changhu.common.db.enums.IsOrNot;
|
||||
import com.changhu.common.db.enums.ServiceProjectType;
|
||||
import com.changhu.support.mybatisplus.pojo.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,9 +12,9 @@ import lombok.Data;
|
|||
*/
|
||||
@Data
|
||||
public class IndexDisableOrEnableParams {
|
||||
@Schema(description = "单位id")
|
||||
@NotNull(message = "单位id不能为空")
|
||||
private Long unitId;
|
||||
@Schema(description = "数据id")
|
||||
@NotNull(message = "数据id不能为空")
|
||||
private Long dataId;
|
||||
|
||||
@Schema(description = "单位类型")
|
||||
@NotNull(message = "单位类型不能为空")
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.changhu.module.management.pojo.queryParams;
|
||||
|
||||
import com.changhu.common.db.enums.IsEnable;
|
||||
import com.changhu.common.db.enums.Sex;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author 20252
|
||||
* @createTime 2024/9/6 下午4:53
|
||||
* @desc UnitMiniProgramUserPagerQueryParams...
|
||||
*/
|
||||
@Data
|
||||
public class UnitMiniProgramUserPagerQueryParams {
|
||||
@Schema(description = "名称")
|
||||
private String name;
|
||||
@Schema(description = "性别")
|
||||
private Sex sex;
|
||||
@Schema(description = "手机号")
|
||||
private String telephone;
|
||||
@Schema(description = "是否启用")
|
||||
private IsEnable isEnable;
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.changhu.module.management.pojo.vo;
|
||||
|
||||
import com.changhu.common.db.enums.CheckStatus;
|
||||
import com.changhu.common.db.enums.IsEnable;
|
||||
import com.changhu.common.db.enums.MiniProgramUserIdentity;
|
||||
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/6 下午4:32
|
||||
* @desc 单位下的微信小程序用户
|
||||
*/
|
||||
@Data
|
||||
public class UnitMiniProgramUserPagerVo {
|
||||
|
||||
@Schema(description = "id")
|
||||
private Long snowFlakeId;
|
||||
|
||||
@Schema(description = "名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "手机号")
|
||||
private String telephone;
|
||||
|
||||
@Schema(description = "性别")
|
||||
private Sex sex;
|
||||
|
||||
@Schema(description = "身份证")
|
||||
private String idCard;
|
||||
|
||||
@Schema(description = "身份")
|
||||
private MiniProgramUserIdentity identity;
|
||||
|
||||
@Schema(description = "审核状态")
|
||||
private CheckStatus checkStatus;
|
||||
|
||||
@Schema(description = "是否启用")
|
||||
private IsEnable isEnable;
|
||||
|
||||
@Schema(description = ":创建时间")
|
||||
private LocalDateTime createTime;
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package com.changhu.module.management.service;
|
||||
|
||||
import com.changhu.module.management.pojo.params.IndexCheckPassParams;
|
||||
import com.changhu.module.management.pojo.params.IndexCheckStatusParams;
|
||||
import com.changhu.module.management.pojo.params.IndexDisableOrEnableParams;
|
||||
import com.changhu.module.management.pojo.vo.UnitCheckStatusVo;
|
||||
|
||||
/**
|
||||
* @author 20252
|
||||
* @createTime 2024/9/2 上午9:49
|
||||
* @desc IndexService...
|
||||
*/
|
||||
public interface IndexService {
|
||||
|
||||
/**
|
||||
* 审核通过
|
||||
*
|
||||
* @param params 审核参数
|
||||
*/
|
||||
void checkPass(IndexCheckPassParams params);
|
||||
|
||||
/**
|
||||
* 获取审核状态
|
||||
*
|
||||
* @param params 参数
|
||||
* @return 结果
|
||||
*/
|
||||
UnitCheckStatusVo getCheckStatus(IndexCheckStatusParams params);
|
||||
|
||||
/**
|
||||
* 启用或者禁用单位
|
||||
*
|
||||
* @param params 参数
|
||||
*/
|
||||
void disableOrEnable(IndexDisableOrEnableParams params);
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.changhu.module.management.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.changhu.module.management.pojo.params.IndexCheckPassParams;
|
||||
import com.changhu.module.management.pojo.params.IndexCheckStatusParams;
|
||||
import com.changhu.module.management.pojo.params.IndexDisableOrEnableParams;
|
||||
import com.changhu.module.management.pojo.queryParams.UnitMiniProgramUserPagerQueryParams;
|
||||
import com.changhu.module.management.pojo.vo.UnitCheckStatusVo;
|
||||
import com.changhu.module.management.pojo.vo.UnitMiniProgramUserPagerVo;
|
||||
import com.changhu.support.mybatisplus.pojo.params.PageParams;
|
||||
|
||||
/**
|
||||
* @author 20252
|
||||
* @createTime 2024/9/2 上午9:49
|
||||
* @desc IndexService...
|
||||
*/
|
||||
public interface ManagementService {
|
||||
|
||||
/**
|
||||
* 审核通过
|
||||
*
|
||||
* @param params 审核参数
|
||||
*/
|
||||
void checkPass(IndexCheckPassParams params);
|
||||
|
||||
/**
|
||||
* 获取审核状态
|
||||
*
|
||||
* @param params 参数
|
||||
* @return 结果
|
||||
*/
|
||||
UnitCheckStatusVo getCheckStatus(IndexCheckStatusParams params);
|
||||
|
||||
/**
|
||||
* 启用或者禁用单位
|
||||
*
|
||||
* @param params 参数
|
||||
*/
|
||||
void disableOrEnable(IndexDisableOrEnableParams params);
|
||||
|
||||
/**
|
||||
* 查询单位下的小程序用户
|
||||
*
|
||||
* @param queryParams 查询参数
|
||||
* @return 结果
|
||||
*/
|
||||
Page<UnitMiniProgramUserPagerVo> miniProgramUserPager(PageParams<UnitMiniProgramUserPagerQueryParams, UnitMiniProgramUserPagerVo> queryParams);
|
||||
|
||||
/**
|
||||
* 审核通过小程序用户
|
||||
*
|
||||
* @param params 参数
|
||||
*/
|
||||
void passMiniProgramUser(IndexDisableOrEnableParams params);
|
||||
|
||||
/**
|
||||
* 禁用或启用小程序用户
|
||||
*
|
||||
* @param params 参数
|
||||
*/
|
||||
void disableOrEnableMiniProgramUser(IndexDisableOrEnableParams params);
|
||||
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
package com.changhu.module.management.service.impl;
|
||||
|
||||
import com.changhu.module.management.pojo.params.IndexCheckPassParams;
|
||||
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.service.IndexService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 20252
|
||||
* @createTime 2024/9/2 上午9:49
|
||||
* @desc IndexServiceImpl...
|
||||
*/
|
||||
@Service
|
||||
public class IndexServiceImpl implements IndexService {
|
||||
@Override
|
||||
public void checkPass(IndexCheckPassParams params) {
|
||||
params.getUnitOptType()
|
||||
.getHandler()
|
||||
.pass(params.getCheckDataId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnitCheckStatusVo getCheckStatus(IndexCheckStatusParams params) {
|
||||
return params.getUnitOptType()
|
||||
.getHandler()
|
||||
.getCheckStatus(params.getOnlyCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableOrEnable(IndexDisableOrEnableParams params) {
|
||||
params.getUnitOptType()
|
||||
.getHandler()
|
||||
.disableOrEnable(params.getUnitId());
|
||||
}
|
||||
}
|
|
@ -8,7 +8,6 @@ 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.pojo.entity.ManagementPoliceUnitUser;
|
||||
import com.changhu.module.management.pojo.params.ManagementPoliceUserSaveOrUpdateParams;
|
||||
|
|
|
@ -9,9 +9,7 @@ import com.changhu.common.annotation.UserType;
|
|||
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.ManagementSecurityUnitUserMapper;
|
||||
import com.changhu.module.management.pojo.entity.ManagementPoliceUnitUser;
|
||||
import com.changhu.module.management.pojo.entity.ManagementSecurityUnitUser;
|
||||
import com.changhu.module.management.pojo.params.ManagementSecurityUnitUserSaveOrUpdateParams;
|
||||
import com.changhu.module.management.pojo.queryParams.ManagementSecurityUnitUserPagerQueryParams;
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
package com.changhu.module.management.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.changhu.common.annotation.UserType;
|
||||
import com.changhu.common.db.enums.MiniProgramUserIdentity;
|
||||
import com.changhu.common.exception.MessageException;
|
||||
import com.changhu.common.utils.UserUtil;
|
||||
import com.changhu.module.management.pojo.params.IndexCheckPassParams;
|
||||
import com.changhu.module.management.pojo.params.IndexCheckStatusParams;
|
||||
import com.changhu.module.management.pojo.params.IndexDisableOrEnableParams;
|
||||
import com.changhu.module.management.pojo.queryParams.UnitMiniProgramUserPagerQueryParams;
|
||||
import com.changhu.module.management.pojo.vo.UnitCheckStatusVo;
|
||||
import com.changhu.module.management.pojo.vo.UnitMiniProgramUserPagerVo;
|
||||
import com.changhu.module.management.service.ManagementService;
|
||||
import com.changhu.module.miniProgram.mapper.MiniProgramUserMapper;
|
||||
import com.changhu.support.mybatisplus.pojo.params.PageParams;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 20252
|
||||
* @createTime 2024/9/2 上午9:49
|
||||
* @desc IndexServiceImpl...
|
||||
*/
|
||||
@Service
|
||||
public class ManagementServiceImpl implements ManagementService {
|
||||
|
||||
@Autowired
|
||||
private MiniProgramUserMapper miniProgramUserMapper;
|
||||
|
||||
@Override
|
||||
public void checkPass(IndexCheckPassParams params) {
|
||||
params.getUnitOptType()
|
||||
.getHandler()
|
||||
.pass(params.getCheckDataId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnitCheckStatusVo getCheckStatus(IndexCheckStatusParams params) {
|
||||
return params.getUnitOptType()
|
||||
.getHandler()
|
||||
.getCheckStatus(params.getOnlyCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableOrEnable(IndexDisableOrEnableParams params) {
|
||||
params.getUnitOptType()
|
||||
.getHandler()
|
||||
.disableOrEnable(params.getDataId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<UnitMiniProgramUserPagerVo> miniProgramUserPager(PageParams<UnitMiniProgramUserPagerQueryParams, UnitMiniProgramUserPagerVo> queryParams) {
|
||||
UserType userType = UserUtil.getUserType();
|
||||
MiniProgramUserIdentity identity = switch (userType) {
|
||||
case MANAGEMENT_POLICE -> MiniProgramUserIdentity.POLICE;
|
||||
case MANAGEMENT_SECURITY -> MiniProgramUserIdentity.PROJECT_MANAGER;
|
||||
default -> throw new MessageException("用户类型不匹配");
|
||||
};
|
||||
return miniProgramUserMapper.pager(queryParams.getPage(), queryParams.getParams(), identity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void passMiniProgramUser(IndexDisableOrEnableParams params) {
|
||||
params.getUnitOptType()
|
||||
.getHandler()
|
||||
.passMiniProgramUser(params.getDataId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableOrEnableMiniProgramUser(IndexDisableOrEnableParams params) {
|
||||
params.getUnitOptType()
|
||||
.getHandler()
|
||||
.disableOrEnableMiniProgramUser(params.getDataId());
|
||||
}
|
||||
}
|
|
@ -10,14 +10,14 @@ import com.changhu.common.db.enums.IsEnable;
|
|||
import com.changhu.common.db.enums.MiniProgramUserIdentity;
|
||||
import com.changhu.common.pojo.vo.SelectNodeVo;
|
||||
import com.changhu.common.utils.UserUtil;
|
||||
import com.changhu.module.miniProgram.mapper.MiniProgramUserMapper;
|
||||
import com.changhu.module.management.mapper.SecurityUnitMapper;
|
||||
import com.changhu.module.miniProgram.pojo.entity.MiniProgramUser;
|
||||
import com.changhu.module.management.pojo.entity.SecurityUnit;
|
||||
import com.changhu.module.management.pojo.params.SecurityUnitSaveOrUpdateParams;
|
||||
import com.changhu.module.management.pojo.queryParams.SecurityUnitPagerQueryParams;
|
||||
import com.changhu.module.management.pojo.vo.SecurityUnitPagerVo;
|
||||
import com.changhu.module.management.service.SecurityUnitService;
|
||||
import com.changhu.module.miniProgram.mapper.MiniProgramUserMapper;
|
||||
import com.changhu.module.miniProgram.pojo.entity.MiniProgramUser;
|
||||
import com.changhu.support.mybatisplus.pojo.params.PageParams;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package com.changhu.module.miniProgram.controller;
|
||||
|
||||
import com.changhu.common.annotation.CheckUserType;
|
||||
import com.changhu.common.annotation.JsonBody;
|
||||
import com.changhu.common.annotation.UserType;
|
||||
import com.changhu.enums.ClientType;
|
||||
import com.changhu.common.pojo.vo.TokenInfo;
|
||||
import com.changhu.module.miniProgram.pojo.params.MiniProgramUserRegisterParams;
|
||||
import com.changhu.module.miniProgram.service.MiniProgramUserService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
@ -29,7 +27,7 @@ public class MiniProgramUserController {
|
|||
|
||||
@Operation(summary = "注册")
|
||||
@PostMapping("/register")
|
||||
public void register(@RequestBody @Valid MiniProgramUserRegisterParams params) {
|
||||
miniProgramUserService.register(params);
|
||||
public TokenInfo register(@RequestBody @Valid MiniProgramUserRegisterParams params) {
|
||||
return miniProgramUserService.register(params);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
package com.changhu.module.miniProgram.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.changhu.common.db.enums.MiniProgramUserIdentity;
|
||||
import com.changhu.module.management.pojo.queryParams.UnitMiniProgramUserPagerQueryParams;
|
||||
import com.changhu.module.management.pojo.vo.UnitMiniProgramUserPagerVo;
|
||||
import com.changhu.module.miniProgram.pojo.entity.MiniProgramUser;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* mini_program_user (小程序用户) 固化类
|
||||
|
@ -12,4 +17,15 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
@Mapper
|
||||
public interface MiniProgramUserMapper extends BaseMapper<MiniProgramUser> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页参数
|
||||
* @param params 查询参数
|
||||
* @param identity 用户身份
|
||||
* @return 结果
|
||||
*/
|
||||
Page<UnitMiniProgramUserPagerVo> pager(@Param("page") Page<UnitMiniProgramUserPagerVo> page,
|
||||
@Param("params") UnitMiniProgramUserPagerQueryParams params,
|
||||
@Param("identity") MiniProgramUserIdentity identity);
|
||||
}
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
package com.changhu.module.miniProgram.pojo.entity;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.changhu.common.db.enums.CheckStatus;
|
||||
import com.changhu.common.db.enums.IsEnable;
|
||||
import com.changhu.common.db.enums.MiniProgramUserIdentity;
|
||||
import com.changhu.common.db.enums.Sex;
|
||||
import com.changhu.support.mybatisplus.pojo.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -76,4 +77,9 @@ public class MiniProgramUser extends BaseEntity implements Serializable {
|
|||
*/
|
||||
private IsEnable isEnable;
|
||||
|
||||
/**
|
||||
* 审核状态
|
||||
*/
|
||||
private CheckStatus checkStatus;
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.changhu.module.miniProgram.pojo.params;
|
|||
|
||||
import com.changhu.common.db.enums.MiniProgramUserIdentity;
|
||||
import com.changhu.common.db.enums.Sex;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
@ -13,19 +14,26 @@ import lombok.Data;
|
|||
*/
|
||||
@Data
|
||||
public class MiniProgramUserRegisterParams {
|
||||
@Schema(description = "微信code")
|
||||
@NotBlank(message = "code不能为空")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "名称")
|
||||
@NotBlank(message = "名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "性别")
|
||||
@NotNull(message = "性别不能为空")
|
||||
private Sex sex;
|
||||
|
||||
@Schema(description = "手机号")
|
||||
private String telephone;
|
||||
|
||||
@Schema(description = "身份")
|
||||
@NotNull(message = "身份不能为空")
|
||||
private MiniProgramUserIdentity identity;
|
||||
|
||||
@Schema(description = "单位id")
|
||||
@NotNull(message = "单位不能为空")
|
||||
private Long unitId;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.changhu.module.miniProgram.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.changhu.common.pojo.vo.TokenInfo;
|
||||
import com.changhu.module.miniProgram.pojo.entity.MiniProgramUser;
|
||||
import com.changhu.module.miniProgram.pojo.params.MiniProgramUserRegisterParams;
|
||||
|
||||
|
@ -16,5 +17,5 @@ public interface MiniProgramUserService extends IService<MiniProgramUser> {
|
|||
*
|
||||
* @param params 参数
|
||||
*/
|
||||
void register(MiniProgramUserRegisterParams params);
|
||||
TokenInfo register(MiniProgramUserRegisterParams params);
|
||||
}
|
||||
|
|
|
@ -2,11 +2,15 @@ package com.changhu.module.miniProgram.service.impl;
|
|||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
||||
import cn.dev33.satoken.stp.SaTokenInfo;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.changhu.common.annotation.UserType;
|
||||
import com.changhu.common.exception.MessageException;
|
||||
import com.changhu.common.pojo.vo.TokenInfo;
|
||||
import com.changhu.common.utils.SnowFlakeIdUtil;
|
||||
import com.changhu.common.utils.UserUtil;
|
||||
import com.changhu.module.miniProgram.mapper.MiniProgramUserMapper;
|
||||
import com.changhu.module.miniProgram.pojo.entity.MiniProgramUser;
|
||||
import com.changhu.module.miniProgram.pojo.params.MiniProgramUserRegisterParams;
|
||||
|
@ -27,7 +31,7 @@ public class MiniProgramUserServiceImpl extends ServiceImpl<MiniProgramUserMappe
|
|||
private WxMaService wxMaService;
|
||||
|
||||
@Override
|
||||
public void register(MiniProgramUserRegisterParams params) {
|
||||
public TokenInfo register(MiniProgramUserRegisterParams params) {
|
||||
MiniProgramUser miniProgramUser = BeanUtil.copyProperties(params, MiniProgramUser.class);
|
||||
try {
|
||||
WxMaJscode2SessionResult sessionInfo = wxMaService.getUserService().getSessionInfo(params.getCode());
|
||||
|
@ -40,13 +44,15 @@ public class MiniProgramUserServiceImpl extends ServiceImpl<MiniProgramUserMappe
|
|||
if (exists) {
|
||||
throw new MessageException("该用户已存在,请勿重复注册!");
|
||||
}
|
||||
|
||||
miniProgramUser.setSnowFlakeId(SnowFlakeIdUtil.snowflakeId());
|
||||
long userId = SnowFlakeIdUtil.snowflakeId();
|
||||
miniProgramUser.setSnowFlakeId(userId);
|
||||
boolean save = this.save(miniProgramUser);
|
||||
if (!save) {
|
||||
throw new MessageException();
|
||||
}
|
||||
|
||||
//todo 是否需要返回token直接登录?
|
||||
//登录
|
||||
SaTokenInfo saTokenInfo = UserUtil.loginAndTokenInfo(userId, UserType.MINI_PROGRAM_PROJECT_MANAGE, miniProgramUser.getUnitId());
|
||||
return new TokenInfo(saTokenInfo.getTokenName(), saTokenInfo.getTokenValue());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package com.changhu.pojo.params;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author 20252
|
||||
* @createTime 2024/9/10 上午10:00
|
||||
* @desc MiniProgramUserLoginParams...
|
||||
*/
|
||||
@Data
|
||||
public class MiniProgramUserLoginParams {
|
||||
@NotBlank(message = "code不能为空")
|
||||
private String code;
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.changhu.pojo.queryParams;
|
||||
|
||||
import com.changhu.common.db.enums.MiniProgramUserIdentity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 20252
|
||||
* @createTime 2024/9/6 下午3:43
|
||||
* @desc QueryUnitListByIdentityQueryParams...
|
||||
*/
|
||||
@Data
|
||||
public class QueryUnitListByIdentityQueryParams {
|
||||
|
||||
@NotNull(message = "身份不能为空")
|
||||
@Schema(description = "身份")
|
||||
private MiniProgramUserIdentity identity;
|
||||
|
||||
@NotEmpty(message = "行政区划编码不能为空")
|
||||
@Schema(description = "行政区划编码")
|
||||
private List<String> administrativeDivisionCodes;
|
||||
|
||||
}
|
|
@ -20,4 +20,12 @@ public interface AdministrativeDivisionService extends IService<AdministrativeDi
|
|||
* @return 全国行政区划树
|
||||
*/
|
||||
List<TreeNodeVo<String>> tree(Integer level);
|
||||
|
||||
/**
|
||||
* 根据父编码查询子级(懒加载)
|
||||
*
|
||||
* @param parentCode 父编码
|
||||
* @return 子级
|
||||
*/
|
||||
List<TreeNodeVo<String>> administrativeDivisionByParentCode(String parentCode);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
package com.changhu.service;
|
||||
|
||||
import com.changhu.common.pojo.model.JsonResult;
|
||||
import com.changhu.common.pojo.vo.SelectNodeVo;
|
||||
import com.changhu.pojo.params.PoliceUnitRegisterParams;
|
||||
import com.changhu.pojo.params.SecurityUnitRegisterParams;
|
||||
import com.changhu.pojo.queryParams.QueryUnitListByIdentityQueryParams;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 20252
|
||||
|
@ -24,4 +28,12 @@ public interface CommonService {
|
|||
* @param params 注册参数
|
||||
*/
|
||||
JsonResult<Void> policeUnitRegister(PoliceUnitRegisterParams params);
|
||||
|
||||
/**
|
||||
* 根据身份查询单位列表
|
||||
*
|
||||
* @param queryParams 查询参数
|
||||
* @return 结果
|
||||
*/
|
||||
List<SelectNodeVo<Long>> queryUnitListByIdentity(QueryUnitListByIdentityQueryParams queryParams);
|
||||
}
|
||||
|
|
|
@ -22,4 +22,18 @@ public class AdministrativeDivisionServiceImpl extends ServiceImpl<Administrativ
|
|||
List<TreeNodeVo<String>> treeNodeVos = baseMapper.treeList(level);
|
||||
return TreeNodeVo.buildTree(treeNodeVos, "0");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeNodeVo<String>> administrativeDivisionByParentCode(String parentCode) {
|
||||
return this.lambdaQuery()
|
||||
.eq(AdministrativeDivision::getParentCode, parentCode)
|
||||
.list()
|
||||
.stream()
|
||||
.map(item -> TreeNodeVo.<String>builder()
|
||||
.value(item.getCode())
|
||||
.label(item.getName())
|
||||
.parentValue(item.getParentCode())
|
||||
.build())
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,19 +2,24 @@ package com.changhu.service.impl;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.changhu.common.db.enums.CheckStatus;
|
||||
import com.changhu.common.db.enums.IsEnable;
|
||||
import com.changhu.common.enums.ResultCode;
|
||||
import com.changhu.common.exception.MessageException;
|
||||
import com.changhu.common.pojo.model.JsonResult;
|
||||
import com.changhu.common.pojo.vo.SelectNodeVo;
|
||||
import com.changhu.module.management.mapper.PoliceUnitMapper;
|
||||
import com.changhu.module.management.mapper.SecurityUnitMapper;
|
||||
import com.changhu.module.management.pojo.entity.PoliceUnit;
|
||||
import com.changhu.module.management.pojo.entity.SecurityUnit;
|
||||
import com.changhu.pojo.params.PoliceUnitRegisterParams;
|
||||
import com.changhu.pojo.params.SecurityUnitRegisterParams;
|
||||
import com.changhu.pojo.queryParams.QueryUnitListByIdentityQueryParams;
|
||||
import com.changhu.service.CommonService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
|
@ -93,4 +98,37 @@ public class CommonServiceImpl implements CommonService {
|
|||
|
||||
return JsonResult.successMsg("申请已提交,请等待审核");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SelectNodeVo<Long>> queryUnitListByIdentity(QueryUnitListByIdentityQueryParams queryParams) {
|
||||
List<String> administrativeDivisionCodes = queryParams.getAdministrativeDivisionCodes();
|
||||
return switch (queryParams.getIdentity()) {
|
||||
case POLICE -> policeUnitMapper.selectList(Wrappers.<PoliceUnit>lambdaQuery()
|
||||
.eq(PoliceUnit::getIsEnable, IsEnable.TRUE)
|
||||
.eq(PoliceUnit::getCheckStatus, CheckStatus.checked)
|
||||
.eq(!administrativeDivisionCodes.isEmpty(), PoliceUnit::getProvince, administrativeDivisionCodes.get(0))
|
||||
.eq(administrativeDivisionCodes.size() >= 2, PoliceUnit::getCity, administrativeDivisionCodes.get(1))
|
||||
.eq(administrativeDivisionCodes.size() >= 3, PoliceUnit::getDistricts, administrativeDivisionCodes.get(2))
|
||||
.eq(administrativeDivisionCodes.size() >= 4, PoliceUnit::getStreet, administrativeDivisionCodes.get(3)))
|
||||
.stream()
|
||||
.map(item -> SelectNodeVo.<Long>builder()
|
||||
.value(item.getSnowFlakeId())
|
||||
.label(item.getName())
|
||||
.build())
|
||||
.toList();
|
||||
case PROJECT_MANAGER -> securityUnitMapper.selectList(Wrappers.<SecurityUnit>lambdaQuery()
|
||||
.eq(SecurityUnit::getIsEnable, IsEnable.TRUE)
|
||||
.eq(SecurityUnit::getCheckStatus, CheckStatus.checked)
|
||||
.eq(!administrativeDivisionCodes.isEmpty(), SecurityUnit::getProvince, administrativeDivisionCodes.get(0))
|
||||
.eq(administrativeDivisionCodes.size() >= 2, SecurityUnit::getCity, administrativeDivisionCodes.get(1))
|
||||
.eq(administrativeDivisionCodes.size() >= 3, SecurityUnit::getDistricts, administrativeDivisionCodes.get(2))
|
||||
.eq(administrativeDivisionCodes.size() >= 4, SecurityUnit::getStreet, administrativeDivisionCodes.get(3)))
|
||||
.stream()
|
||||
.map(item -> SelectNodeVo.<Long>builder()
|
||||
.value(item.getSnowFlakeId())
|
||||
.label(item.getName())
|
||||
.build())
|
||||
.toList();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public class GlobalExceptionHandler {
|
|||
|
||||
@ExceptionHandler(HttpMessageNotWritableException.class)
|
||||
public void HttpMessageNotWritableException(HttpMessageNotWritableException e) {
|
||||
log.error("HttpMessageNotWritableException:{}", ExceptionUtil.stacktraceToString(e, 500));
|
||||
log.error("HttpMessageNotWritableException", e);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,7 +57,7 @@ public class GlobalExceptionHandler {
|
|||
@ExceptionHandler(NullPointerException.class)
|
||||
public JsonResult<String> nullPointerException(NullPointerException exception) {
|
||||
String errorLabel = "空指针错误:" + ExceptionUtil.getMessage(exception);
|
||||
log.error("空指针错误:{}", ExceptionUtil.stacktraceToString(exception));
|
||||
log.error("空指针错误:", exception);
|
||||
return JsonResult.custom(ResultCode.ERROR.getCode(), errorLabel);
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class GlobalExceptionHandler {
|
|||
@ExceptionHandler(MessageException.class)
|
||||
public JsonResult<String> messageExceptionHandler(MessageException exception) {
|
||||
String errorLabel = "业务异常:" + exception.getMessage();
|
||||
log.error(errorLabel);
|
||||
log.error("业务异常:", exception);
|
||||
return JsonResult.custom(exception.getCode(), errorLabel);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.changhu.common.annotation.CheckUserType;
|
|||
import com.changhu.common.annotation.UserType;
|
||||
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;
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
<?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.miniProgram.mapper.MiniProgramUserMapper">
|
||||
<select id="pager" resultType="com.changhu.module.management.pojo.vo.UnitMiniProgramUserPagerVo">
|
||||
select
|
||||
mpu.*
|
||||
from mini_program_user mpu
|
||||
where
|
||||
mpu.delete_flag = 0
|
||||
and mpu.identity = #{identity.value}
|
||||
and mpu.unit_id = ${@com.changhu.common.utils.UserUtil@getUnitId()}
|
||||
<if test="params.name!=null and params.name!=''">
|
||||
and mpu.name like concat('%',#{params.name},'%')
|
||||
</if>
|
||||
<if test="params.telephone!=null and params.telephone!=''">
|
||||
and mpu.telephone like concat('%',#{params.telephone},'%')
|
||||
</if>
|
||||
<if test="params.sex!=null">
|
||||
and mpu.sex = #{params.sex.value}
|
||||
</if>
|
||||
<if test="params.isEnable!=null">
|
||||
and mpu.is_enable = #{params.isEnable.value}
|
||||
</if>
|
||||
order by mpu.create_time desc
|
||||
</select>
|
||||
</mapper>
|
|
@ -10,6 +10,7 @@
|
|||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vueuse/core": "^11.0.3",
|
||||
"ant-design-vue": "^4.2.3",
|
||||
"axios": "^1.7.5",
|
||||
"jsencrypt": "^3.3.2",
|
||||
|
|
|
@ -92,7 +92,7 @@ const columns: TableProps['columns'] = [
|
|||
class={record.isEnable.value === 0 ? 'btn-danger' : 'btn-success'}
|
||||
onClick={async () => {
|
||||
const resp = await api.post('/management/disableOrEnable', {
|
||||
unitId: record.snowFlakeId,
|
||||
dataId: record.snowFlakeId,
|
||||
unitOptType: UNIT_TYPE.police
|
||||
})
|
||||
message.success(resp.message)
|
||||
|
|
|
@ -103,7 +103,7 @@ const columns: TableProps['columns'] = [
|
|||
class={record.isEnable.value === 0 ? 'btn-danger' : 'btn-success'}
|
||||
onClick={async () => {
|
||||
const resp = await api.post('/management/disableOrEnable', {
|
||||
unitId: record.snowFlakeId,
|
||||
dataId: record.snowFlakeId,
|
||||
unitOptType: UNIT_TYPE.security
|
||||
})
|
||||
message.success(resp.message)
|
||||
|
|
Loading…
Reference in New Issue