29 changed files with 742 additions and 506 deletions
@ -0,0 +1,6 @@ |
|||
package com.zdxt.enforcementcode.common.util; |
|||
|
|||
public class ApiConstants { |
|||
|
|||
public static final String API_SIQUSERLOGIN= "/pub/auth/getUserInfo"; |
|||
} |
|||
@ -0,0 +1,63 @@ |
|||
package com.zdxt.enforcementcode.common.util; |
|||
|
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
|
|||
import java.io.BufferedReader; |
|||
import java.io.DataOutputStream; |
|||
import java.io.InputStreamReader; |
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
import java.nio.charset.StandardCharsets; |
|||
import java.util.Map; |
|||
|
|||
public class HttpUtil { |
|||
|
|||
|
|||
private static final Logger log = LoggerFactory.getLogger(HttpUtil.class); |
|||
public static String httpSendPost(String url, String params, Map<String,Object> heardMap){ |
|||
try { |
|||
URL uri = new URL(url); |
|||
HttpURLConnection connection = (HttpURLConnection) uri.openConnection(); |
|||
connection.setRequestMethod("POST"); |
|||
connection.setRequestProperty("Content-Type","application/json"); |
|||
connection.setRequestProperty("Charsert","UTF-8"); |
|||
for (Map.Entry<String, Object> entry : heardMap.entrySet()) { |
|||
// 对value进行相应的操作
|
|||
connection.setRequestProperty(entry.getKey(), String.valueOf(entry.getValue())); |
|||
} |
|||
connection.setDoOutput(true); |
|||
DataOutputStream out = new DataOutputStream(connection.getOutputStream()); |
|||
// out.writeBytes(params);
|
|||
out.write(params.getBytes(StandardCharsets.UTF_8)); //解决中文乱码
|
|||
out.flush(); |
|||
out.close(); |
|||
int responseCode = connection.getResponseCode(); |
|||
if(responseCode == HttpURLConnection.HTTP_OK){ |
|||
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)); |
|||
String inputLine; |
|||
StringBuffer response = new StringBuffer(); |
|||
|
|||
while ((inputLine = in.readLine()) != null){ |
|||
response.append(inputLine); |
|||
} |
|||
in.close(); |
|||
log.info(response.toString()); |
|||
System.out.println("请求成功"); |
|||
return response.toString(); |
|||
}else{ |
|||
log.error("============================== 深i企接口获取用户信息接口调用失败 =============================="); |
|||
log.error("---> 失败码:{}",responseCode); |
|||
log.error("---> url: {}",url); |
|||
log.error("---> params: {}",params); |
|||
log.error("---> heardMap: {}",heardMap); |
|||
log.error("============================== =========================== =============================="); |
|||
// BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
|
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
return ""; |
|||
} |
|||
} |
|||
@ -0,0 +1,133 @@ |
|||
package com.zdxt.enforcementcode.common.util; |
|||
|
|||
/** |
|||
* 用户常量信息 |
|||
* |
|||
* @author ruoyi |
|||
*/ |
|||
public class UserConstants |
|||
{ |
|||
/** 正常状态 */ |
|||
public static final String NORMAL = "0"; |
|||
|
|||
/** 异常状态 */ |
|||
public static final String EXCEPTION = "1"; |
|||
|
|||
/** 用户封禁状态 */ |
|||
public static final String USER_BLOCKED = "1"; |
|||
|
|||
/** 角色封禁状态 */ |
|||
public static final String ROLE_BLOCKED = "1"; |
|||
|
|||
/** 部门正常状态 */ |
|||
public static final String DEPT_NORMAL = "0"; |
|||
|
|||
/** 字典正常状态 */ |
|||
public static final String DICT_NORMAL = "0"; |
|||
|
|||
/** 是否为系统默认(是) */ |
|||
public static final String YES = "Y"; |
|||
|
|||
/** 上移 */ |
|||
public static final String UP = "up"; |
|||
|
|||
/** 下移 */ |
|||
public static final String DOWN = "down"; |
|||
|
|||
/** |
|||
* 用户名长度限制 |
|||
*/ |
|||
public static final int USERNAME_MIN_LENGTH = 2; |
|||
public static final int USERNAME_MAX_LENGTH = 20; |
|||
|
|||
/** 登录名称是否唯一的返回结果码 */ |
|||
public final static String USER_NAME_UNIQUE = "0"; |
|||
public final static String USER_NAME_NOT_UNIQUE = "1"; |
|||
|
|||
/** 手机号码是否唯一的返回结果 */ |
|||
public final static String USER_PHONE_UNIQUE = "0"; |
|||
public final static String USER_PHONE_NOT_UNIQUE = "1"; |
|||
|
|||
/** e-mail 是否唯一的返回结果 */ |
|||
public final static String USER_EMAIL_UNIQUE = "0"; |
|||
public final static String USER_EMAIL_NOT_UNIQUE = "1"; |
|||
|
|||
/** 部门名称是否唯一的返回结果码 */ |
|||
public final static String DEPT_NAME_UNIQUE = "0"; |
|||
public final static String DEPT_NAME_NOT_UNIQUE = "1"; |
|||
|
|||
/** 角色名称是否唯一的返回结果码 */ |
|||
public final static String ROLE_NAME_UNIQUE = "0"; |
|||
public final static String ROLE_NAME_NOT_UNIQUE = "1"; |
|||
|
|||
/** 岗位名称是否唯一的返回结果码 */ |
|||
public final static String POST_NAME_UNIQUE = "0"; |
|||
public final static String POST_NAME_NOT_UNIQUE = "1"; |
|||
|
|||
/** 角色权限是否唯一的返回结果码 */ |
|||
public final static String ROLE_KEY_UNIQUE = "0"; |
|||
public final static String ROLE_KEY_NOT_UNIQUE = "1"; |
|||
|
|||
/** 岗位编码是否唯一的返回结果码 */ |
|||
public final static String POST_CODE_UNIQUE = "0"; |
|||
public final static String POST_CODE_NOT_UNIQUE = "1"; |
|||
|
|||
/** 菜单名称是否唯一的返回结果码 */ |
|||
public final static String MENU_NAME_UNIQUE = "0"; |
|||
public final static String MENU_NAME_NOT_UNIQUE = "1"; |
|||
|
|||
/** 字典类型是否唯一的返回结果码 */ |
|||
public final static String DICT_TYPE_UNIQUE = "0"; |
|||
public final static String DICT_TYPE_NOT_UNIQUE = "1"; |
|||
|
|||
/** 编码是否唯一的返回结果码 */ |
|||
public final static String AUTOENCODER_UNIQUE = "0"; |
|||
public final static String AUTOENCODER_NOT_UNIQUE = "1"; |
|||
/** 编码正常状态 */ |
|||
public static final Integer AUTOENCODER_NORMAL = 0; |
|||
|
|||
/** 参数键名是否唯一的返回结果码 */ |
|||
public final static String CONFIG_KEY_UNIQUE = "0"; |
|||
public final static String CONFIG_KEY_NOT_UNIQUE = "1"; |
|||
|
|||
/** |
|||
* 密码长度限制 |
|||
*/ |
|||
public static final int PASSWORD_MIN_LENGTH = 5; |
|||
public static final int PASSWORD_MAX_LENGTH = 20; |
|||
|
|||
/** |
|||
* 手机号码格式限制 |
|||
*/ |
|||
public static final String MOBILE_PHONE_NUMBER_PATTERN = "^0{0,1}(13[0-9]|15[0-9]|14[0-9]|18[0-9])[0-9]{8}$"; |
|||
|
|||
/** |
|||
* 邮箱格式限制 |
|||
*/ |
|||
public static final String EMAIL_PATTERN = "^((([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+(\\.([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(\\\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.)+(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.?"; |
|||
|
|||
/** |
|||
* 默认用户权限 |
|||
*/ |
|||
public static final Long DEFAULT_ROLE = 178L; |
|||
|
|||
/** |
|||
* 默认密码 |
|||
*/ |
|||
public static final String DEFAULT_PASSWORD = "szsf@zfjd"; |
|||
|
|||
/** |
|||
* 默认部门 |
|||
*/ |
|||
public static final String DEFAULT_DEPT = "405"; |
|||
|
|||
/** |
|||
* 默认用户源 |
|||
*/ |
|||
public static final Integer DEFAULT_USER_SOURCE = 1; |
|||
|
|||
/** |
|||
* 默认删除状态 |
|||
*/ |
|||
public static final String NORMAL_DEL_FLAG = "0"; |
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
package com.zdxt.enforcementcode.controller.app.enterprise; |
|||
|
|||
|
|||
import com.zdxt.enforcementcode.domain.bo.enterprise.AppEnterpriseLoginBo; |
|||
import com.zdxt.enforcementcode.service.enterprise.IAppEnterpriseLoginService; |
|||
import io.swagger.v3.oas.annotations.responses.ApiResponse; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* 企业端-用户登录 |
|||
*/ |
|||
@Tag(name = "企业端-用户登录") |
|||
@Validated |
|||
@RequiredArgsConstructor |
|||
@RestController |
|||
@RequestMapping("/app-ent/login") |
|||
public class AppEnterpriseLoginController { |
|||
|
|||
|
|||
|
|||
@Autowired |
|||
private IAppEnterpriseLoginService appEnterpriseLoginService; |
|||
|
|||
/** |
|||
* 企业端用户登录 |
|||
*/ |
|||
@ApiResponse(description = "企业端-用户登录") |
|||
@PostMapping("siqLogin") |
|||
@ResponseBody |
|||
public Boolean siqLogin(AppEnterpriseLoginBo bo){ |
|||
|
|||
Boolean flag = appEnterpriseLoginService.addSiqUser(bo); |
|||
|
|||
return flag; |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
package com.zdxt.enforcementcode.domain.bo.enterprise; |
|||
|
|||
|
|||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
@JsonIgnoreProperties(ignoreUnknown = true) |
|||
public class AppEnterpriseLoginBo { |
|||
|
|||
private String userId; |
|||
private String userName; |
|||
private String code; |
|||
} |
|||
@ -1,154 +0,0 @@ |
|||
package com.zdxt.enforcementcode.domain.dto.enterprise; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.zdxt.enforcementcode.domain.EnterpriseComplaint; |
|||
import io.github.linpeilie.annotations.AutoMapper; |
|||
import jakarta.validation.constraints.NotBlank; |
|||
import lombok.Data; |
|||
import org.dromara.common.core.validate.EditGroup; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
@Data |
|||
@AutoMapper(target = EnterpriseComplaint.class) |
|||
public class AppEnterpriseComplatintInsertDTO { |
|||
|
|||
/** |
|||
* 主键ID |
|||
*/ |
|||
@NotBlank(message = "主键ID不能为空", groups = { EditGroup.class }) |
|||
private String id; |
|||
|
|||
/** |
|||
* 关联执法记录ID |
|||
*/ |
|||
private String relId; |
|||
|
|||
/** |
|||
* 执法类型 |
|||
*/ |
|||
private Long enforceType; |
|||
|
|||
/** |
|||
* 问题描述 |
|||
*/ |
|||
private String problemDescription; |
|||
|
|||
/** |
|||
* 联系人 |
|||
*/ |
|||
private String linkman; |
|||
|
|||
/** |
|||
* 联系方式 |
|||
*/ |
|||
private String linkmanTel; |
|||
|
|||
/** |
|||
* 是否删除 0 否 1 是 |
|||
*/ |
|||
private Long isDelete; |
|||
|
|||
/** |
|||
* 投诉对接12345案件类型 |
|||
*/ |
|||
private String caseType; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private Long authorization; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private Long comOrOpi; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private String enterpriseAddress; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private String proWoCode; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private Long status; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private Date evaluateTime; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private String enterpriseNumber; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private String enterpriseName; |
|||
|
|||
/** |
|||
* 执法部门多个-逗号隔开 |
|||
*/ |
|||
private String complaintDepartments; |
|||
|
|||
/** |
|||
* 执法部门id多个-逗号隔开 |
|||
*/ |
|||
private String complaintDepartmentIds; |
|||
|
|||
/** |
|||
* 执法时间 |
|||
*/ |
|||
private Date enforcementTime; |
|||
|
|||
/** |
|||
* 投诉类型 0 系默认 1 联合检查 |
|||
*/ |
|||
private Long complaintType; |
|||
|
|||
/** |
|||
* 投诉事项编码,多个逗号隔开 |
|||
*/ |
|||
private String complaintItemCodes; |
|||
|
|||
/** |
|||
* 投诉事项名称,多个逗号隔开 |
|||
*/ |
|||
private String complaintItemNames; |
|||
|
|||
/** |
|||
* 同步过来的处理时间 |
|||
*/ |
|||
private String handleTime; |
|||
|
|||
/** |
|||
* 投诉事项(对应记录表执法/入企事项) |
|||
*/ |
|||
private String complaintRecordItem; |
|||
|
|||
/** |
|||
* 数据类型 0行政 1 非行政 |
|||
*/ |
|||
private Integer recordType; |
|||
|
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createTime; |
|||
|
|||
/** |
|||
* 文件列表- |
|||
*/ |
|||
@TableField(exist = false) |
|||
private List<String> fileList; |
|||
} |
|||
@ -1,156 +0,0 @@ |
|||
package com.zdxt.enforcementcode.domain.dto.enterprise; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.zdxt.enforcementcode.domain.EnterpriseComplaint; |
|||
import io.github.linpeilie.annotations.AutoMapper; |
|||
import jakarta.validation.constraints.NotBlank; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
import org.dromara.common.core.validate.EditGroup; |
|||
import org.dromara.common.mybatis.core.domain.BaseEntity; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
@AutoMapper(target = EnterpriseComplaint.class) |
|||
public class AppEnterpriseComplatintQueryDTO extends BaseEntity { |
|||
/** |
|||
* 主键ID |
|||
*/ |
|||
@NotBlank(message = "主键ID不能为空", groups = { EditGroup.class }) |
|||
private String id; |
|||
|
|||
/** |
|||
* 关联执法记录ID |
|||
*/ |
|||
private String relId; |
|||
|
|||
/** |
|||
* 执法类型 |
|||
*/ |
|||
private Long enforceType; |
|||
|
|||
/** |
|||
* 问题描述 |
|||
*/ |
|||
private String problemDescription; |
|||
|
|||
/** |
|||
* 联系人 |
|||
*/ |
|||
private String linkman; |
|||
|
|||
/** |
|||
* 联系方式 |
|||
*/ |
|||
private String linkmanTel; |
|||
|
|||
/** |
|||
* 是否删除 0 否 1 是 |
|||
*/ |
|||
private Long isDelete; |
|||
|
|||
/** |
|||
* 投诉对接12345案件类型 |
|||
*/ |
|||
private String caseType; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private Long authorization; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private Long comOrOpi; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private String enterpriseAddress; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private String proWoCode; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private Long status; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private Date evaluateTime; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private String enterpriseNumber; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private String enterpriseName; |
|||
|
|||
/** |
|||
* 执法部门多个-逗号隔开 |
|||
*/ |
|||
private String complaintDepartments; |
|||
|
|||
/** |
|||
* 执法部门id多个-逗号隔开 |
|||
*/ |
|||
private String complaintDepartmentIds; |
|||
|
|||
/** |
|||
* 执法时间 |
|||
*/ |
|||
private Date enforcementTime; |
|||
|
|||
/** |
|||
* 投诉类型 0 系默认 1 联合检查 |
|||
*/ |
|||
private Long complaintType; |
|||
|
|||
/** |
|||
* 投诉事项编码,多个逗号隔开 |
|||
*/ |
|||
private String complaintItemCodes; |
|||
|
|||
/** |
|||
* 投诉事项名称,多个逗号隔开 |
|||
*/ |
|||
private String complaintItemNames; |
|||
|
|||
/** |
|||
* 同步过来的处理时间 |
|||
*/ |
|||
private String handleTime; |
|||
|
|||
/** |
|||
* 投诉事项(对应记录表执法/入企事项) |
|||
*/ |
|||
private String complaintRecordItem; |
|||
|
|||
/** |
|||
* 数据类型 0行政 1 非行政 |
|||
*/ |
|||
private Integer recordType; |
|||
|
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createTime; |
|||
|
|||
/** |
|||
* 文件列表- |
|||
*/ |
|||
@TableField(exist = false) |
|||
private List<String> fileList; |
|||
} |
|||
@ -1,76 +0,0 @@ |
|||
package com.zdxt.enforcementcode.domain.dto.enterprise; |
|||
|
|||
|
|||
|
|||
import lombok.Data; |
|||
|
|||
|
|||
/** |
|||
* 企业端-查询企业执法登记列表 |
|||
* |
|||
* @author Lion Li |
|||
* @date 2026-04-17 |
|||
*/ |
|||
@Data |
|||
public class EnforcementRegistrationQueryDTO { |
|||
|
|||
/** |
|||
* 执法部门 |
|||
*/ |
|||
private String lawEnforcement; |
|||
|
|||
|
|||
/** |
|||
* 执法事项 |
|||
*/ |
|||
private String lawEnforcementItem; |
|||
|
|||
/** |
|||
* 是否真联合执法(0:未联合; 1:已经联合) |
|||
*/ |
|||
private Long isRealUnion; |
|||
|
|||
/** |
|||
* 查询字段 |
|||
*/ |
|||
private String searchValue; |
|||
|
|||
/** |
|||
* 日期类型筛选: 1=本月, 2=本季, 3=本年 |
|||
*/ |
|||
private Integer dateType; |
|||
|
|||
|
|||
|
|||
private String dateSearch; |
|||
/** |
|||
* 年 |
|||
*/ |
|||
private String year; |
|||
/** |
|||
* 季度 |
|||
*/ |
|||
private String quarter; |
|||
/** |
|||
* 日 |
|||
*/ |
|||
private String month; |
|||
|
|||
/** |
|||
* 开始时间 |
|||
*/ |
|||
private String beginTime; |
|||
private String beginEnforcementTime; |
|||
|
|||
/** |
|||
* 结束时间 |
|||
*/ |
|||
private String endTime; |
|||
private String endEnforcementTime; |
|||
|
|||
|
|||
/** |
|||
* 关键字查询 |
|||
*/ |
|||
private String searchText; |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
package com.zdxt.enforcementcode.service.enterprise; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.zdxt.enforcementcode.domain.bo.enterprise.AppEnterpriseLoginBo; |
|||
import org.dromara.system.domain.vo.SysUserVo; |
|||
|
|||
|
|||
/** |
|||
* 企业端-企业用户登录Service接口 |
|||
*/ |
|||
public interface IAppEnterpriseLoginService { |
|||
|
|||
|
|||
Boolean addSiqUser(AppEnterpriseLoginBo bo); |
|||
} |
|||
@ -0,0 +1,321 @@ |
|||
package com.zdxt.enforcementcode.service.enterprise.impl; |
|||
|
|||
|
|||
import cn.hutool.core.util.ArrayUtil; |
|||
import cn.hutool.core.util.StrUtil; |
|||
import cn.hutool.crypto.digest.DigestUtil; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.zdxt.enforcementcode.common.util.ApiConstants; |
|||
import com.zdxt.enforcementcode.common.util.HttpUtil; |
|||
import com.zdxt.enforcementcode.common.util.IdCardCryptoUtil; |
|||
import com.zdxt.enforcementcode.common.util.UserConstants; |
|||
import com.zdxt.enforcementcode.domain.EnterpriseInformation; |
|||
import com.zdxt.enforcementcode.domain.bo.enterprise.AppEnterpriseLoginBo; |
|||
import com.zdxt.enforcementcode.mapper.EnterpriseInformationMapper; |
|||
import com.zdxt.enforcementcode.service.enterprise.IAppEnterpriseLoginService; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.dromara.common.core.utils.DateUtils; |
|||
import org.dromara.common.core.utils.StringUtils; |
|||
import org.dromara.system.domain.SysUser; |
|||
import org.dromara.system.domain.SysUserPost; |
|||
import org.dromara.system.domain.SysUserRole; |
|||
import org.dromara.system.domain.vo.SysUserVo; |
|||
import org.dromara.system.mapper.SysUserMapper; |
|||
import org.dromara.system.mapper.SysUserPostMapper; |
|||
import org.dromara.system.mapper.SysUserRoleMapper; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.text.SimpleDateFormat; |
|||
import java.util.*; |
|||
|
|||
|
|||
/** |
|||
* 企业端-登录Service业务层处理 |
|||
*/ |
|||
@Slf4j |
|||
@RequiredArgsConstructor |
|||
@Service |
|||
public class AppEnterpriseLoginServiceImpl implements IAppEnterpriseLoginService { |
|||
|
|||
@Value("${siq.code}") |
|||
private String code; |
|||
@Value("${siq.secretKey}") |
|||
private String secretKey; |
|||
@Value("${siq.siqUrl}") |
|||
private String siqUrl; |
|||
|
|||
|
|||
@Autowired |
|||
private SysUserMapper sysUserMapper; |
|||
|
|||
@Autowired |
|||
private SysUserPostMapper sysUserPostMapper; |
|||
|
|||
@Autowired |
|||
private SysUserRoleMapper sysUserRoleMapper; |
|||
|
|||
@Autowired |
|||
private EnterpriseInformationMapper enterpriseInformationMapper; |
|||
|
|||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
|||
@Override |
|||
public Boolean addSiqUser(AppEnterpriseLoginBo bo) { |
|||
|
|||
//调用深i企登录接口
|
|||
JSONObject userInfo =siqLoginInfo(bo); |
|||
//判断用户信息
|
|||
Map<String, Object> checkUserInfo = checkUserInfo(userInfo); |
|||
if (UserConstants.USER_NAME_NOT_UNIQUE.equals(checkUserInfo.get("unique"))) { |
|||
return false; |
|||
} |
|||
if (checkUserInfo.get("userId") != null) { |
|||
return false; |
|||
} |
|||
//封装添加用户信息
|
|||
String phone =checkUserInfo.get("phone").toString(); |
|||
SysUser sysUser = addUserInfo(userInfo, phone ); |
|||
//用户密码加密
|
|||
Boolean result=false; |
|||
result =encryptPassword(sysUser); |
|||
//添加深i企用户关联企业信息
|
|||
if (result == true) { |
|||
result= addSiqUserCompany(userInfo); |
|||
} |
|||
// 用户登录-需要生成Token (暂时搁置)
|
|||
return result; |
|||
} |
|||
|
|||
/** |
|||
* 调用深i企登录接口返回用户登录信息 |
|||
*/ |
|||
|
|||
public JSONObject siqLoginInfo(AppEnterpriseLoginBo bo){ |
|||
|
|||
Map<String, Object> params = new HashMap<>(); |
|||
|
|||
String accessKeySign = IdCardCryptoUtil.symmetricEncryptIdCard(secretKey,bo.getCode()); |
|||
params.put("accessKeySign",accessKeySign); |
|||
params.put("accessKeySign{}",accessKeySign); |
|||
params.put("appCode",code); |
|||
|
|||
String data = HttpUtil.httpSendPost(siqUrl + ApiConstants.API_SIQUSERLOGIN, JSONObject.toJSONString(params),new HashMap<>()); |
|||
JSONObject jsonObject = JSONObject.parseObject(data); |
|||
JSONObject userInfo = jsonObject.getJSONObject("data"); |
|||
|
|||
return userInfo; |
|||
} |
|||
|
|||
/** |
|||
* 判断用户登录信息 |
|||
*/ |
|||
public Map<String, Object> checkUserInfo(JSONObject userInfo) { |
|||
|
|||
Map<String, Object> map = new HashMap<>(); |
|||
// 判断用户唯一校验
|
|||
String userUnique; |
|||
LambdaQueryWrapper<SysUser> queryAccountWrapper = new LambdaQueryWrapper<>(); |
|||
queryAccountWrapper.eq(SysUser::getLoginName, userInfo.getString("account")) |
|||
.eq(SysUser::getUserSource, UserConstants.DEFAULT_USER_SOURCE); |
|||
userUnique = String.valueOf(sysUserMapper.selectCount(queryAccountWrapper)); |
|||
|
|||
if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userUnique)) { |
|||
map.put("unique", UserConstants.USER_NAME_NOT_UNIQUE); |
|||
return map; |
|||
} |
|||
|
|||
LambdaQueryWrapper<SysUser> queryPhoneWrapper = new LambdaQueryWrapper<>(); |
|||
queryPhoneWrapper.eq(SysUser::getLoginName, userInfo.getString("phone")) |
|||
.eq(SysUser::getUserSource, UserConstants.DEFAULT_USER_SOURCE); |
|||
userUnique = String.valueOf(sysUserMapper.selectCount(queryPhoneWrapper)); |
|||
|
|||
if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userUnique)) { |
|||
map.put("unique", UserConstants.USER_NAME_NOT_UNIQUE); |
|||
return map; |
|||
} |
|||
|
|||
// 判断用户名是否重复
|
|||
String phone = IdCardCryptoUtil.symmetricDecryptIdCard(secretKey, userInfo.getString("phone")); |
|||
LambdaQueryWrapper<SysUser> queryLoginNameWrapper = new LambdaQueryWrapper<>(); |
|||
queryLoginNameWrapper.eq(SysUser::getLoginName, phone) |
|||
.eq(SysUser::getUserSource, UserConstants.DEFAULT_USER_SOURCE); |
|||
SysUser sysUser = sysUserMapper.selectOne(queryLoginNameWrapper); |
|||
if (sysUser != null && sysUser.getUserId() != null) { |
|||
map.put("userId", sysUser.getUserId()); |
|||
map.put("phone", phone); |
|||
return map; |
|||
} |
|||
return map; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 封装添加用户信息 |
|||
*/ |
|||
public SysUser addUserInfo(JSONObject userInfo,String phone) { |
|||
|
|||
//新增用户信息
|
|||
SysUser user = new SysUser(); |
|||
if (StringUtils.isNotEmpty(userInfo.getString("account"))) { |
|||
|
|||
// 设置默认用户权限,权限默认值
|
|||
user.setRoleId(UserConstants.DEFAULT_ROLE); |
|||
user.setUserName(userInfo.getString("userName")); |
|||
if (StringUtils.isNotEmpty(userInfo.getString("account"))) { |
|||
user.setLoginName(userInfo.getString("account")); |
|||
} else { |
|||
user.setLoginName(phone); |
|||
} |
|||
user.setPhonenumber(phone); |
|||
// 设置默认密码
|
|||
user.setPassword(UserConstants.DEFAULT_PASSWORD); |
|||
user.setCreateTime(DateUtils.getNowDate()); |
|||
// 设置默认部门ID
|
|||
user.setDeptId(UserConstants.DEFAULT_DEPT); |
|||
// 设置用户类型
|
|||
user.setUserSource(UserConstants.DEFAULT_USER_SOURCE); |
|||
user.setDelFlag(UserConstants.NORMAL_DEL_FLAG); |
|||
|
|||
}else if(StringUtils.isNotEmpty(userInfo.getString("phone"))){ |
|||
// 设置默认用户权限,权限默认值
|
|||
user.setRoleId(UserConstants.DEFAULT_ROLE); |
|||
user.setUserName(userInfo.getString("userName")); |
|||
if (StringUtils.isNotEmpty(userInfo.getString("account"))) { |
|||
user.setLoginName(userInfo.getString("account")); |
|||
} else { |
|||
user.setLoginName(phone); |
|||
} |
|||
user.setPhonenumber(phone); |
|||
// 设置默认密码
|
|||
user.setPassword(UserConstants.DEFAULT_PASSWORD); |
|||
user.setCreateTime(DateUtils.getNowDate()); |
|||
// 设置默认部门ID
|
|||
user.setDeptId(UserConstants.DEFAULT_DEPT); |
|||
// 设置用户类型
|
|||
user.setUserSource(UserConstants.DEFAULT_USER_SOURCE); |
|||
user.setDelFlag(UserConstants.NORMAL_DEL_FLAG); |
|||
} |
|||
return user ; |
|||
} |
|||
|
|||
/** |
|||
* 用户密码加密 |
|||
*/ |
|||
public Boolean encryptPassword(SysUser user) { |
|||
// 用户密码加密
|
|||
user.setPassword(DigestUtil.md5Hex(user.getLoginName()+user.getPassword()+user.getSalt())); |
|||
// 新增用户
|
|||
int rows = 0; |
|||
Boolean flag=false; |
|||
rows= sysUserMapper.insert(user); |
|||
// 新增岗位
|
|||
if (ArrayUtil.isNotEmpty(user.getPostIds())) { |
|||
List<SysUserPost> userPostList = new ArrayList<>(); |
|||
for (Long postId : user.getPostIds()) { |
|||
SysUserPost userPost = new SysUserPost(); |
|||
userPost.setUserId(user.getUserId()); |
|||
userPost.setPostId(postId); |
|||
userPostList.add(userPost); |
|||
} |
|||
flag= sysUserPostMapper.insertBatch(userPostList); |
|||
} |
|||
// 新增用户与角色管理
|
|||
if (ArrayUtil.isNotEmpty(user.getRoleId())) { |
|||
List<SysUserRole> userRoleList = new ArrayList<>(); |
|||
for (Long roleId : user.getRoleIds()) { |
|||
SysUserRole userPost = new SysUserRole(); |
|||
userPost.setUserId(user.getUserId()); |
|||
userPost.setRoleId(roleId); |
|||
userRoleList.add(userPost); |
|||
} |
|||
flag=sysUserRoleMapper.insertBatch(userRoleList); |
|||
} |
|||
|
|||
if (rows==1 && flag==true) { |
|||
return true; |
|||
}else{ |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
|
|||
// 添加深i企用户关联企业信息
|
|||
/** |
|||
* 添加深i企用户关联企业信息 |
|||
*/ |
|||
public Boolean addSiqUserCompany(JSONObject userInfo){ |
|||
|
|||
EnterpriseInformation enterpriseInformation = new EnterpriseInformation(); |
|||
// 企业纳税识别号
|
|||
enterpriseInformation.setEnterpriseNumber(userInfo.getString("corpCid")); |
|||
LambdaQueryWrapper<EnterpriseInformation> queryWrapper = new LambdaQueryWrapper<>(); |
|||
queryWrapper.eq(EnterpriseInformation::getEnterpriseNumber, enterpriseInformation.getEnterpriseNumber()); |
|||
if (enterpriseInformationMapper.selectCount(queryWrapper) > 0) { |
|||
return false; |
|||
} |
|||
//企业名称
|
|||
enterpriseInformation.setEnterpriseName(userInfo.getString("corpName")); |
|||
//企业类型
|
|||
enterpriseInformation.setCompanyOrgType(userInfo.getString("companyOrgType")); |
|||
//注册时间
|
|||
String establishDate = userInfo.getString("establishDate"); |
|||
try { |
|||
if (StrUtil.isNotEmpty(establishDate)) { |
|||
Date establishDateD = format.parse(establishDate); |
|||
enterpriseInformation.setEstablishmentTime(establishDateD); |
|||
} |
|||
} catch (Exception e) { |
|||
log.warn("解析企业成立日期失败: {}", establishDate, e); |
|||
} |
|||
//经营范围
|
|||
enterpriseInformation.setBusinessScope(userInfo.getString("businessScope")); |
|||
//注册地址
|
|||
enterpriseInformation.setEnterpriseAddress(userInfo.getString("regLocation")); |
|||
//注册资金
|
|||
enterpriseInformation.setRegisteredCapital(userInfo.getString("regCapital")); |
|||
//企业联系人电话
|
|||
enterpriseInformation.setEnterpriseTel(IdCardCryptoUtil.symmetricDecryptIdCard(secretKey,userInfo.getString("phone"))); |
|||
//企业法人
|
|||
enterpriseInformation.setLegalPerson(userInfo.getString("legalPersonName")); |
|||
//用户Id
|
|||
enterpriseInformation.setUserId(Long.valueOf(userInfo.getString("userId"))); |
|||
//营业时间
|
|||
//开始时间
|
|||
String termStart = userInfo.getString("termStart"); |
|||
try { |
|||
Date termStartD = format.parse(termStart); |
|||
termStart = format.format(termStartD); |
|||
} catch (Exception e) { |
|||
termStart = ""; |
|||
} |
|||
//结束时间 返回为空表示为永久
|
|||
String termEnd = userInfo.getString("termEnd"); |
|||
try { |
|||
if(StrUtil.isNotEmpty(termEnd)){ |
|||
Date termEndD = format.parse(termEnd); |
|||
termEnd = format.format(termEndD); |
|||
} |
|||
} catch (Exception e) { |
|||
termEnd = ""; |
|||
} |
|||
//营业期限-开始时间
|
|||
enterpriseInformation.setOperatingTerm(termStart); |
|||
//营业期限-结束时间 为空表示 无固定期限
|
|||
enterpriseInformation.setOperatingTermEnd(termEnd); |
|||
|
|||
return enterpriseInformationMapper.insert(enterpriseInformation)>0? Boolean.TRUE:Boolean.FALSE; |
|||
|
|||
} |
|||
// 深i企用户登录
|
|||
public SysUserVo siqLogin(JSONObject userInfo){ |
|||
|
|||
SysUserVo sysUserVo = new SysUserVo(); |
|||
|
|||
|
|||
return sysUserVo; |
|||
} |
|||
|
|||
} |
|||
Loading…
Reference in new issue