Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
251735740f
@ -1,12 +1,18 @@
|
||||
package cn.iocoder.yudao.module.archives.controller.admin;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.archives.entity.Archives;
|
||||
import cn.iocoder.yudao.module.archives.service.ArchivesService;
|
||||
import cn.iocoder.yudao.module.archives.vo.ArchivesReqVO;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 档案表 控制层
|
||||
* @author 小李
|
||||
@ -19,4 +25,47 @@ public class ArchivesController {
|
||||
|
||||
@Resource
|
||||
private ArchivesService archivesService;
|
||||
|
||||
/**
|
||||
* 新增或修改 档案表
|
||||
* @author 小李
|
||||
* @date 10:42 2024/8/29
|
||||
* @param archivesReqVO 请求对象
|
||||
**/
|
||||
@PostMapping("/update")
|
||||
@Operation(summary = "新增/修改企业管理-档案表")
|
||||
public CommonResult updateArchives(@RequestBody ArchivesReqVO archivesReqVO){
|
||||
archivesService.updateArchives(archivesReqVO);
|
||||
return CommonResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询 档案表
|
||||
* @author 小李
|
||||
* @date 11:08 2024/8/29
|
||||
* @param archivesReqVO 查询条件
|
||||
* @param pageNo 页码
|
||||
* @param pageSize 条数
|
||||
**/
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "分页查企业管理-档案表")
|
||||
public CommonResult queryArchivesPage(ArchivesReqVO archivesReqVO,
|
||||
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize){
|
||||
Page<Archives> page = new Page<>(pageNo, pageSize);
|
||||
return success(archivesService.queryArchivesPage(archivesReqVO, page));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 档案表
|
||||
* @author 小李
|
||||
* @date 14:14 2024/8/29
|
||||
* @param id 记录ID
|
||||
**/
|
||||
@DeleteMapping("/remove/{id}")
|
||||
@Operation(summary = "删除企业管理-档案表")
|
||||
public CommonResult removeArchivesById(@PathVariable String id){
|
||||
archivesService.removeArchivesById(id);
|
||||
return CommonResult.ok();
|
||||
}
|
||||
}
|
||||
|
@ -74,4 +74,7 @@ public class Archives extends TenantBaseDO {
|
||||
* 部门id(system_dept表中的id)
|
||||
*/
|
||||
private Long deptId;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
}
|
@ -53,6 +53,11 @@ public class ArchivesRole extends TenantBaseDO {
|
||||
*/
|
||||
private String deleteRoleIds;
|
||||
|
||||
/**
|
||||
* 角色ID(system_role的ID,用于分辨用户是否有权限下载)
|
||||
*/
|
||||
private String downloadRoleIds;
|
||||
|
||||
/**
|
||||
* 部门id
|
||||
*/
|
||||
@ -73,4 +78,8 @@ public class ArchivesRole extends TenantBaseDO {
|
||||
/** 用户是否可以删除档案 */
|
||||
@TableField(exist = false)
|
||||
private Boolean isDeleted;
|
||||
|
||||
/** 用户是否可以下载档案 */
|
||||
@TableField(exist = false)
|
||||
private Boolean isDownload;
|
||||
}
|
@ -1,8 +1,12 @@
|
||||
package cn.iocoder.yudao.module.archives.mapper;
|
||||
|
||||
import cn.iocoder.yudao.module.archives.entity.Archives;
|
||||
import cn.iocoder.yudao.module.archives.vo.ArchivesReqVO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 针对表【company_archives(档案表)】的数据库操作Mapper
|
||||
@ -11,4 +15,6 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
**/
|
||||
@Mapper
|
||||
public interface ArchivesMapper extends BaseMapper<Archives> {
|
||||
|
||||
IPage<Archives> queryArchivesPage(@Param("map") ArchivesReqVO archivesReqVO, Page<Archives> page);
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
package cn.iocoder.yudao.module.archives.service;
|
||||
|
||||
import cn.iocoder.yudao.module.archives.entity.Archives;
|
||||
import cn.iocoder.yudao.module.archives.vo.ArchivesReqVO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
@ -9,4 +12,28 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
* @date 20:13 2024/8/28
|
||||
**/
|
||||
public interface ArchivesService extends IService<Archives> {
|
||||
|
||||
/**
|
||||
* 新增或修改 档案表
|
||||
* @author 小李
|
||||
* @date 10:42 2024/8/29
|
||||
* @param archivesReqVO 请求对象
|
||||
**/
|
||||
void updateArchives(ArchivesReqVO archivesReqVO);
|
||||
|
||||
/**
|
||||
* 分页查询 档案表
|
||||
* @author 小李
|
||||
* @date 11:08 2024/8/29
|
||||
* @param archivesReqVO 查询条件
|
||||
**/
|
||||
IPage<Archives> queryArchivesPage(ArchivesReqVO archivesReqVO, Page<Archives> page);
|
||||
|
||||
/**
|
||||
* 删除 档案表
|
||||
* @author 小李
|
||||
* @date 14:14 2024/8/29
|
||||
* @param id 记录ID
|
||||
**/
|
||||
void removeArchivesById(String id);
|
||||
}
|
||||
|
@ -146,6 +146,8 @@ public class ArchivesRoleServiceImpl extends ServiceImpl<ArchivesRoleMapper, Arc
|
||||
item.setIsDeleted(checkPermission(item.getDeleteRoleIds(), roleIds));
|
||||
// 修改权限
|
||||
item.setIsUpdated(checkPermission(item.getUpdateRoleIds(), roleIds));
|
||||
// 下载权限
|
||||
item.setIsDownload(checkPermission(item.getDownloadRoleIds(), roleIds));
|
||||
});
|
||||
|
||||
// dictLabel赋值
|
||||
|
@ -1,11 +1,21 @@
|
||||
package cn.iocoder.yudao.module.archives.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.module.archives.entity.Archives;
|
||||
import cn.iocoder.yudao.module.archives.mapper.ArchivesMapper;
|
||||
import cn.iocoder.yudao.module.archives.service.ArchivesService;
|
||||
import cn.iocoder.yudao.module.archives.vo.ArchivesReqVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
||||
|
||||
/**
|
||||
* 档案表 服务实现类
|
||||
* @author 小李
|
||||
@ -13,4 +23,58 @@ import org.springframework.stereotype.Service;
|
||||
**/
|
||||
@Service
|
||||
public class ArchivesServiceImpl extends ServiceImpl<ArchivesMapper, Archives> implements ArchivesService {
|
||||
|
||||
/**
|
||||
* 新增或修改 档案表
|
||||
* @author 小李
|
||||
* @date 10:42 2024/8/29
|
||||
* @param archivesReqVO 请求对象
|
||||
**/
|
||||
@Override
|
||||
public void updateArchives(ArchivesReqVO archivesReqVO){
|
||||
// 新增
|
||||
if (ObjectUtil.isEmpty(archivesReqVO.getId())){
|
||||
// 判断档案名是否重复
|
||||
List<Archives> archives = baseMapper.selectList(new LambdaQueryWrapper<Archives>().eq(Archives::getArchivesCode, archivesReqVO.getArchivesCode()));
|
||||
if (CollectionUtil.isNotEmpty(archives)){
|
||||
throw exception0(500, "档案名重复");
|
||||
}
|
||||
baseMapper.insert(archivesReqVO);
|
||||
return;
|
||||
}
|
||||
|
||||
// 修改
|
||||
// 判断档案名是否合法
|
||||
// 如果有,判断id是否一致,不一致就是重复,其他情况皆可执行
|
||||
List<Archives> archives = baseMapper.selectList(new LambdaQueryWrapper<Archives>().eq(Archives::getArchivesCode, archivesReqVO.getArchivesCode()));
|
||||
// 用&&短路的特性去判断,少写点代码
|
||||
// get 0有些不合理,理论上讲是不会有多条的,概率小,改一下名字就行
|
||||
Boolean flag = CollectionUtil.isNotEmpty(archives) && !archives.get(0).getId().equals(archivesReqVO.getId());
|
||||
if (flag){
|
||||
throw exception0(500, "档案名重复");
|
||||
}
|
||||
baseMapper.updateById(archivesReqVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询 档案表
|
||||
* @author 小李
|
||||
* @date 11:08 2024/8/29
|
||||
* @param archivesReqVO 查询条件
|
||||
**/
|
||||
@Override
|
||||
public IPage<Archives> queryArchivesPage(ArchivesReqVO archivesReqVO, Page<Archives> page){
|
||||
return baseMapper.queryArchivesPage(archivesReqVO, page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 档案表
|
||||
* @author 小李
|
||||
* @date 14:14 2024/8/29
|
||||
* @param id 记录ID
|
||||
**/
|
||||
@Override
|
||||
public void removeArchivesById(String id){
|
||||
baseMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,13 @@
|
||||
package cn.iocoder.yudao.module.archives.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.archives.entity.Archives;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
/**
|
||||
* 档案表 请求VO
|
||||
@ -10,4 +16,8 @@ import lombok.Data;
|
||||
**/
|
||||
@Data
|
||||
public class ArchivesReqVO extends Archives {
|
||||
|
||||
@Schema(description = "合同日期查询范围")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date[] queryDateArray;
|
||||
}
|
||||
|
@ -15,14 +15,34 @@
|
||||
<result property="signTime" column="sign_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="expireTime" column="expire_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="deptId" column="dept_id" jdbcType="BIGINT"/>
|
||||
<result property="remark" column="remark" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_SQL">
|
||||
id,data_id,archives_name,
|
||||
archives_type,archives_physics_url,archives_urls,
|
||||
archives_code,sign_time,expire_time,
|
||||
dept_id,tenant_id,deleted,
|
||||
creator,create_time,updater,
|
||||
update_time
|
||||
select id,
|
||||
data_id,
|
||||
archives_name,
|
||||
archives_type,
|
||||
archives_physics_url,
|
||||
archives_urls,
|
||||
archives_code,
|
||||
sign_time,
|
||||
expire_time,
|
||||
dept_id,
|
||||
remark
|
||||
from company_archives ca
|
||||
where deleted = '0'
|
||||
</sql>
|
||||
|
||||
<select id="queryArchivesPage" resultMap="BaseResultMap">
|
||||
<include refid="Base_SQL" />
|
||||
and ca.data_id = #{map.dataId}
|
||||
<if test="map.archivesName != null and map.archivesName != ''">
|
||||
and (ca.archives_name like concat('%', #{map.archivesName}, '%'))
|
||||
</if>
|
||||
<if test="map.queryDateArray != null and map.queryDateArray.length > 0">
|
||||
and (ca.sign_time >= #{map.queryDateArray[0]} and ca.expire_time <= #{map.queryDateArray[1]})
|
||||
</if>
|
||||
order by ca.expire_time, ca.create_time desc
|
||||
</select>
|
||||
</mapper>
|
@ -8,10 +8,12 @@
|
||||
<id property="id" column="id" jdbcType="VARCHAR"/>
|
||||
<result property="dictType" column="dict_type" jdbcType="VARCHAR"/>
|
||||
<result property="dataId" column="data_id" jdbcType="BIGINT"/>
|
||||
<result property="queryRoleIds" column="query_role_ids" jdbcType="BIGINT"/>
|
||||
<result property="updateRoleIds" column="update_role_ids" jdbcType="BIGINT"/>
|
||||
<result property="createRoleIds" column="create_role_ids" jdbcType="BIGINT"/>
|
||||
<result property="deleteRoleIds" column="delete_role_ids" jdbcType="BIGINT"/>
|
||||
<result property="queryRoleIds" column="query_role_ids" jdbcType="VARCHAR"/>
|
||||
<result property="updateRoleIds" column="update_role_ids" jdbcType="VARCHAR"/>
|
||||
<result property="createRoleIds" column="create_role_ids" jdbcType="VARCHAR"/>
|
||||
<result property="deleteRoleIds" column="delete_role_ids" jdbcType="VARCHAR"/>
|
||||
<result property="deleteRoleIds" column="delete_role_ids" jdbcType="VARCHAR"/>
|
||||
<result property="downloadRoleIds" column="download_role_ids" jdbcType="VARCHAR"/>
|
||||
<result property="deptId" column="dept_id" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.jx.controller.admin;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
@ -7,12 +8,14 @@ import cn.iocoder.yudao.module.jx.domain.DriveSchoolCoach;
|
||||
import cn.iocoder.yudao.module.jx.domain.DriveSchoolInfo;
|
||||
import cn.iocoder.yudao.module.jx.mapper.DriveSchoolCoachMapper;
|
||||
import cn.iocoder.yudao.module.jx.service.IDriveSchoolInfoService;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import cn.iocoder.yudao.module.system.service.permission.PermissionService;
|
||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -23,6 +26,8 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 认证")
|
||||
@RestController
|
||||
@RequestMapping("/jx/auth")
|
||||
@ -75,4 +80,27 @@ public class JxAuthController {
|
||||
return CommonResult.success(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取App用户信息
|
||||
*
|
||||
* @return 用户信息
|
||||
*/
|
||||
@GetMapping("/getAppInfo")
|
||||
public CommonResult getAppInfo()
|
||||
{
|
||||
LoginUser user = SecurityFrameworkUtils.getLoginUser();
|
||||
// 获取当前登录用户角色编码
|
||||
Set<String> roles = permissionService.getRolePermission(user.getId());
|
||||
Map<String,Object> result = new HashMap<>();
|
||||
result.put("user", user);
|
||||
result.put("role", roles);
|
||||
// ShopConfig shopConfig = configService.selectShopConfigById(1L);
|
||||
// if (StringUtils.isEmpty(shopConfig.getOpenRz())||shopConfig.getOpenRz().equals("0")){
|
||||
// ajax.put("openRz", "0");
|
||||
// }else {
|
||||
// ajax.put("openRz", "1");
|
||||
// }
|
||||
return success(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -470,52 +470,45 @@ public class SysLoginController {
|
||||
// return AjaxResult.success(menuService.buildMenus(menus));
|
||||
// }
|
||||
|
||||
// @ApiOperation("微信登录")
|
||||
// @ApiImplicitParams({
|
||||
// @ApiImplicitParam(name = "WxLoginBody",dataType = "WxLoginBody", value = "jscode", required = true, paramType = "body")
|
||||
// })
|
||||
// @PostMapping("/wxLogin")
|
||||
// public AjaxResult wxLogin(@RequestBody WxLoginBody wxLoginBody) {
|
||||
// String code = wxLoginBody.getCode();
|
||||
// //秘钥
|
||||
// String encryptedIv = wxLoginBody.getEncryptedIv();
|
||||
// //加密数据
|
||||
// String encryptedData = wxLoginBody.getEncryptedData();
|
||||
//
|
||||
//
|
||||
// //想微信服务器发送请求获取用户信息
|
||||
// String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxConfig.getAppId() + "&secret=" + wxConfig.getAppSecret() + "&js_code=" + code + "&grant_type=authorization_code";
|
||||
// System.out.println(url);
|
||||
// String res = restTemplate.getForObject(url, String.class);
|
||||
// JSONObject jsonObject = JSONObject.parseObject(res);
|
||||
//
|
||||
// //获取session_key和openid
|
||||
// String sessionKey = jsonObject.getString("session_key");
|
||||
// String openId = jsonObject.getString("openid");
|
||||
//
|
||||
// System.out.println(sessionKey);
|
||||
// System.out.println(openId);
|
||||
// //解密
|
||||
// String decryptResult = "";
|
||||
// try {
|
||||
// //如果没有绑定微信开放平台,解析结果是没有unionid的。
|
||||
// decryptResult = decrypt(sessionKey, encryptedIv, encryptedData);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// return AjaxResult.error("微信登录失败!");
|
||||
// }
|
||||
//
|
||||
// if (StringUtils.hasText(decryptResult)) {
|
||||
// //如果解析成功,获取token
|
||||
// String token = loginService.wxLogin(decryptResult,openId,wxLoginBody.getInviteId());
|
||||
// AjaxResult ajax = AjaxResult.success();
|
||||
// ajax.put(Constants.TOKEN, token);
|
||||
// return ajax;
|
||||
// } else {
|
||||
// return AjaxResult.error("微信登录失败!");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
@PostMapping("/wxLogin")
|
||||
public CommonResult wxLogin(@RequestBody WxLoginBody wxLoginBody) {
|
||||
String code = wxLoginBody.getCode();
|
||||
//秘钥
|
||||
String encryptedIv = wxLoginBody.getEncryptedIv();
|
||||
//加密数据
|
||||
String encryptedData = wxLoginBody.getEncryptedData();
|
||||
|
||||
|
||||
//想微信服务器发送请求获取用户信息
|
||||
String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxConfig.getJxAppId() + "&secret=" + wxConfig.getJxAppSecret() + "&js_code=" + code + "&grant_type=authorization_code";
|
||||
System.out.println(url);
|
||||
String res = restTemplate.getForObject(url, String.class);
|
||||
JSONObject jsonObject = JSONObject.parseObject(res);
|
||||
|
||||
//获取session_key和openid
|
||||
String sessionKey = jsonObject.getString("session_key");
|
||||
String openId = jsonObject.getString("openid");
|
||||
//解密
|
||||
String decryptResult = "";
|
||||
try {
|
||||
//如果没有绑定微信开放平台,解析结果是没有unionid的。
|
||||
decryptResult = decrypt(sessionKey, encryptedIv, encryptedData);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return error(500, "微信登录失败!");
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(decryptResult)) {
|
||||
//如果解析成功,获取token
|
||||
AuthLoginRespVO loginVO = loginService.wxLogin(decryptResult,openId,wxLoginBody.getInviteId());
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("token", loginVO.getAccessToken());
|
||||
return success(map);
|
||||
} else {
|
||||
return error(500, "微信登录失败!");
|
||||
}
|
||||
}
|
||||
|
||||
// @PostMapping("/wxLoginJc")
|
||||
// public AjaxResult wxLoginJc(@RequestBody WxLoginBody wxLoginBody) {
|
||||
// String code = wxLoginBody.getCode();
|
||||
|
@ -19,6 +19,6 @@ public class WxLoginBody {
|
||||
*/
|
||||
private String encryptedData;
|
||||
|
||||
// //邀请码
|
||||
// private Long inviteId;
|
||||
//邀请码
|
||||
private Long inviteId;
|
||||
}
|
||||
|
@ -75,6 +75,9 @@ public class WechatPayConfig {
|
||||
*/
|
||||
private String baseUrl;
|
||||
|
||||
private String jxAppId = "wx684fc832e96cee65";
|
||||
private String jxAppSecret = "d1fecac806c5f3cd9aca9f3d5c3759c7";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -130,7 +130,11 @@ public class YudaoWebSecurityConfigurerAdapter {
|
||||
// 1.1 静态资源,可匿名访问
|
||||
.antMatchers(HttpMethod.GET, "/*.html", "/**/*.html", "/**/*.css", "/**/*.js").permitAll()
|
||||
|
||||
.antMatchers(HttpMethod.POST, "/admin-api/rescue/login", "/admin-api/rescue/loginApp","/admin-api/system/auth/loginApp", "/admin-api/rescue/driverLogin").anonymous()
|
||||
.antMatchers(HttpMethod.POST, "/admin-api/rescue/login",
|
||||
"/admin-api/rescue/loginApp",
|
||||
"/admin-api/rescue/wxLogin",
|
||||
"/admin-api/system/auth/loginApp",
|
||||
"/admin-api/rescue/driverLogin").anonymous()
|
||||
// 1.2 设置 @PermitAll 无需认证
|
||||
.antMatchers(HttpMethod.GET, permitAllUrls.get(HttpMethod.GET).toArray(new String[0])).permitAll()
|
||||
.antMatchers(HttpMethod.POST, permitAllUrls.get(HttpMethod.POST).toArray(new String[0])).permitAll()
|
||||
|
@ -132,6 +132,49 @@ public class AuthController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
// @PostMapping("/wxLoginJc")
|
||||
// public AjaxResult wxLoginJc(@RequestBody WxLoginBody wxLoginBody) {
|
||||
// String code = wxLoginBody.getCode();
|
||||
// //秘钥
|
||||
// String encryptedIv = wxLoginBody.getEncryptedIv();
|
||||
// //加密数据
|
||||
// String encryptedData = wxLoginBody.getEncryptedData();
|
||||
//
|
||||
// //想微信服务器发送请求获取用户信息
|
||||
// String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxConfig.getAppId() + "&secret=" + wxConfig.getAppSecret() + "&js_code=" + code + "&grant_type=authorization_code";
|
||||
// System.out.println(url);
|
||||
// String res = restTemplate.getForObject(url, String.class);
|
||||
// JSONObject jsonObject = JSONObject.parseObject(res);
|
||||
//
|
||||
// //获取session_key和openid
|
||||
// String sessionKey = jsonObject.getString("session_key");
|
||||
// String openId = jsonObject.getString("openid");
|
||||
//
|
||||
// System.out.println(sessionKey);
|
||||
// System.out.println(openId);
|
||||
// //解密
|
||||
// String decryptResult = "";
|
||||
// try {
|
||||
// //如果没有绑定微信开放平台,解析结果是没有unionid的。
|
||||
// decryptResult = decrypt(sessionKey, encryptedIv, encryptedData);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// return AjaxResult.error("微信登录失败!");
|
||||
// }
|
||||
//
|
||||
// if (StringUtils.hasText(decryptResult)) {
|
||||
// //如果解析成功,获取token
|
||||
// String token = loginService.wxLoginJc(decryptResult,openId,wxLoginBody.getInviteId());
|
||||
// AjaxResult ajax = AjaxResult.success();
|
||||
// ajax.put(Constants.TOKEN, token);
|
||||
// return ajax;
|
||||
// } else {
|
||||
// return AjaxResult.error("微信登录失败!");
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
@PostMapping("/refresh-token")
|
||||
@PermitAll
|
||||
@Operation(summary = "刷新令牌")
|
||||
|
@ -109,5 +109,6 @@ public class AdminUserDO extends TenantBaseDO {
|
||||
|
||||
private String jcOpenId;
|
||||
|
||||
private String openId;
|
||||
|
||||
}
|
||||
|
@ -53,4 +53,6 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
|
||||
Integer getStudentNumberByUserId(Long jlId);
|
||||
|
||||
List<String> getStudentNumber(Long id);
|
||||
|
||||
AdminUserDO selectUserByPhone(String phone);
|
||||
}
|
||||
|
@ -70,4 +70,6 @@ public interface AdminAuthService {
|
||||
*/
|
||||
AuthLoginRespVO refreshToken(String refreshToken);
|
||||
|
||||
AuthLoginRespVO wxLogin(String decryptResult,String openId,Long inviteId);
|
||||
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import cn.iocoder.yudao.module.system.service.member.MemberService;
|
||||
import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService;
|
||||
import cn.iocoder.yudao.module.system.service.social.SocialUserService;
|
||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.xingyuv.captcha.model.common.ResponseModel;
|
||||
import com.xingyuv.captcha.model.vo.CaptchaVO;
|
||||
@ -65,6 +66,7 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
||||
@Resource
|
||||
private SmsCodeApi smsCodeApi;
|
||||
|
||||
|
||||
/**
|
||||
* 验证码的开关,默认为 true
|
||||
*/
|
||||
@ -207,6 +209,63 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
||||
return AuthConvert.INSTANCE.convert(accessTokenDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthLoginRespVO wxLogin(String decryptResult, String openId, Long inviteId) {
|
||||
//字符串转json
|
||||
JSONObject jsonObject = JSONObject.parseObject(decryptResult);
|
||||
System.out.println(jsonObject);
|
||||
System.out.println("openId"+openId);
|
||||
String phoneNumber = jsonObject.getString("phoneNumber");
|
||||
//还可以获取其他信息
|
||||
//根据openid判断数据库中是否有该用户
|
||||
//根据openid查询用户信息
|
||||
AdminUserDO wxUser = userService.selectUserByPhone(phoneNumber);
|
||||
//如果查不到,则新增,查到了,则更新
|
||||
// SysUser user = new SysUser();
|
||||
// if (wxUser == null) {
|
||||
// // 新增
|
||||
// user.setUserName(phoneNumber);
|
||||
// user.setNickName(phoneNumber);
|
||||
// user.setPhonenumber(phoneNumber);
|
||||
// user.setOpenId(openId);
|
||||
// user.setCreateTime(DateUtils.getNowDate());
|
||||
// user.setPassword(SecurityUtils.encryptPassword("654321"));
|
||||
// if (null!=inviteId){
|
||||
//
|
||||
// //绑定上级
|
||||
// user.setInviteId(inviteId);
|
||||
// //给上级进行积分奖励
|
||||
// userBalanceService.inviteRewards(inviteId);
|
||||
// }
|
||||
// //新增 用户
|
||||
// userService.insertUser(user);
|
||||
// }else {
|
||||
// //更新
|
||||
// user = wxUser;
|
||||
// user.setNickName(phoneNumber);
|
||||
// user.setPhonenumber(phoneNumber);
|
||||
// user.setUpdateTime(DateUtils.getNowDate());
|
||||
// user.setOpenId(openId);
|
||||
// if (ObjectUtil.isEmpty(user.getInviteId())){
|
||||
// if (null!=inviteId){
|
||||
// //绑定上级
|
||||
// user.setInviteId(inviteId);
|
||||
// //给上级进行积分奖励
|
||||
// userBalanceService.inviteRewards(inviteId);
|
||||
// }
|
||||
// }
|
||||
// userMapper.updateUser(user);
|
||||
// }
|
||||
//组装token信息
|
||||
// LoginUser loginUser = new LoginUser();
|
||||
// loginUser.setOpenId(openId);
|
||||
// //如果有的话设置
|
||||
// loginUser.setUser(user);
|
||||
// loginUser.setUserId(user.getUserId());
|
||||
// 生成token
|
||||
return createTokenAfterLoginSuccess(wxUser.getId(), wxUser.getUsername(), LoginLogTypeEnum.LOGIN_SOCIAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logout(String token, Integer logType) {
|
||||
// 删除访问令牌
|
||||
|
@ -215,4 +215,6 @@ public interface AdminUserService {
|
||||
Integer getStudentNumberByUserId(Long jlId);
|
||||
|
||||
List<String> getStudentNumber(Long id);
|
||||
|
||||
AdminUserDO selectUserByPhone(String phone);
|
||||
}
|
||||
|
@ -520,6 +520,11 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
return userMapper.getStudentNumber(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdminUserDO selectUserByPhone(String phone) {
|
||||
return userMapper.selectUserByPhone(phone);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对密码进行加密
|
||||
*
|
||||
|
@ -30,4 +30,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="getStudentNumber" resultType="String">
|
||||
select distinct phone from drive_school_pay where jxId = #{deptId} and state = '3'
|
||||
</select>
|
||||
<select id="selectUserByPhone" resultType="cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO">
|
||||
select su.*
|
||||
from system_users su where su.mobile = #{phone} and su.deleted = '0'
|
||||
</select>
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue
Block a user