8 changed files with 258 additions and 0 deletions
@ -0,0 +1,63 @@ |
|||||
|
package com.yxt.portal.apiadmin; |
||||
|
|
||||
|
import cn.hutool.crypto.digest.MD5; |
||||
|
import com.yxt.common.core.query.PagerQuery; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import com.yxt.common.core.vo.PagerVo; |
||||
|
import com.yxt.portal.biz.organizationappkey.*; |
||||
|
import com.yxt.portal.biz.region.RegionChildTwoVo; |
||||
|
import com.yxt.portal.biz.sysmenu.SysMenuQuery; |
||||
|
import com.yxt.portal.biz.sysmenu.SysMenuVo; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2025/1/21 10:42 |
||||
|
*/ |
||||
|
@Api(tags = "申请组织appkey") |
||||
|
@RestController |
||||
|
@RequestMapping("apiadmin/organizationappkey") |
||||
|
public class OrganizationAppKeyRest { |
||||
|
|
||||
|
@Autowired |
||||
|
OrganizationAppKeyService organizationAppKeyService; |
||||
|
|
||||
|
@ApiOperation("根据条件分页查询数据的列表") |
||||
|
@PostMapping("/listPage") |
||||
|
public ResultBean<PagerVo<OrganizationAppKeyVo>> listPage(@RequestBody PagerQuery<OrganizationAppKeyQuery> pq) { |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
PagerVo<OrganizationAppKeyVo> pv = organizationAppKeyService.listPageVo(pq); |
||||
|
return rb.success().setData(pv); |
||||
|
} |
||||
|
/** |
||||
|
* 申请appkey |
||||
|
* |
||||
|
* @return 申请appkey |
||||
|
*/ |
||||
|
@ApiOperation("申请appkey") |
||||
|
@ResponseBody |
||||
|
@PostMapping("/saveAppKey") |
||||
|
public ResultBean saveAppKey(@RequestBody OrganizationAppKeyDto dto) { |
||||
|
return organizationAppKeyService.saveAppKey(dto); |
||||
|
} |
||||
|
@ApiOperation("根据组织查询appeky") |
||||
|
@ResponseBody |
||||
|
@GetMapping("/initialization/{orgSid}") |
||||
|
public ResultBean initialization(@PathVariable("orgSid") String orgSid) { |
||||
|
return organizationAppKeyService.getAppkeyByOrgSid(orgSid); |
||||
|
} |
||||
|
@ApiOperation("校验是否存在") |
||||
|
@ResponseBody |
||||
|
@GetMapping("/checkByAppKey/{appKey}") |
||||
|
public ResultBean<OrganizationAppKey> checkByAppKey(@PathVariable("appKey") String appKey) { |
||||
|
return organizationAppKeyService.checkByAppKey(appKey); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
package com.yxt.portal.biz.organizationappkey; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import com.yxt.common.core.domain.BaseEntity; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2025/1/21 11:19 |
||||
|
*/ |
||||
|
@Data |
||||
|
@TableName("organization_appkey") |
||||
|
public class OrganizationAppKey extends BaseEntity { |
||||
|
private String orgSid; |
||||
|
private String appKey; |
||||
|
private String secret; |
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
package com.yxt.portal.biz.organizationappkey; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2025/1/21 11:19 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class OrganizationAppKeyDto { |
||||
|
private String orgSid; |
||||
|
private String appKey; |
||||
|
private String secret; |
||||
|
private String state; |
||||
|
} |
@ -0,0 +1,21 @@ |
|||||
|
package com.yxt.portal.biz.organizationappkey; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.core.toolkit.Constants; |
||||
|
import com.yxt.portal.biz.sysauthorizegroup.SysAuthorizeGroup; |
||||
|
import com.yxt.portal.biz.sysauthorizegroup.SysAuthorizeGroupVo; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2025/1/21 11:19 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface OrganizationAppKeyMapper extends BaseMapper<OrganizationAppKey> { |
||||
|
|
||||
|
IPage<OrganizationAppKeyVo> listPage(IPage<OrganizationAppKey> page, @Param(Constants.WRAPPER) QueryWrapper<OrganizationAppKey> qw); |
||||
|
|
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
<?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.yxt.portal.biz.organizationappkey.OrganizationAppKeyMapper"> |
||||
|
<!-- <where> ${ew.sqlSegment} </where>--> |
||||
|
<!-- ${ew.customSqlSegment} --> |
||||
|
<select id="listPage" resultType="com.yxt.portal.biz.organizationappkey.OrganizationAppKeyVo"> |
||||
|
select a.*,case a.state when 0 then '待审核' when 1 then '通过' end as stateValue , |
||||
|
b.name as orgName |
||||
|
from organization_appkey a |
||||
|
left join sys_organization b on b.sid =a.orgSid |
||||
|
<where> |
||||
|
${ew.sqlSegment} |
||||
|
</where> |
||||
|
</select> |
||||
|
|
||||
|
</mapper> |
@ -0,0 +1,14 @@ |
|||||
|
package com.yxt.portal.biz.organizationappkey; |
||||
|
|
||||
|
import com.yxt.common.core.query.Query; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2025/1/21 14:53 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class OrganizationAppKeyQuery implements Query { |
||||
|
private String state; |
||||
|
private String orgName; |
||||
|
} |
@ -0,0 +1,91 @@ |
|||||
|
package com.yxt.portal.biz.organizationappkey; |
||||
|
|
||||
|
import cn.hutool.core.bean.BeanUtil; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.yxt.common.base.service.MybatisBaseService; |
||||
|
import com.yxt.common.base.utils.PagerUtil; |
||||
|
import com.yxt.common.core.query.PagerQuery; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import com.yxt.common.core.vo.PagerVo; |
||||
|
import com.yxt.portal.biz.sysauthorizegroup.SysAuthorizeGroup; |
||||
|
import com.yxt.portal.biz.sysauthorizegroup.SysAuthorizeGroupMapper; |
||||
|
import com.yxt.portal.biz.sysmenu.SysMenu; |
||||
|
import com.yxt.portal.biz.sysmenu.SysMenuQuery; |
||||
|
import com.yxt.portal.biz.sysmenu.SysMenuVo; |
||||
|
import com.yxt.portal.biz.sysorgregister.SysOrgRegister; |
||||
|
import com.yxt.portal.biz.sysorgregister.SysOrgRegisterService; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
import java.util.UUID; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2025/1/21 11:19 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class OrganizationAppKeyService extends MybatisBaseService<OrganizationAppKeyMapper, OrganizationAppKey> { |
||||
|
@Autowired |
||||
|
SysOrgRegisterService sysOrgRegisterService; |
||||
|
|
||||
|
|
||||
|
private QueryWrapper<OrganizationAppKey> createQueryWrapper(OrganizationAppKeyQuery query) { |
||||
|
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
||||
|
QueryWrapper<OrganizationAppKey> qw = new QueryWrapper<>(); |
||||
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(query.getOrgName())) { |
||||
|
qw.like("b.name",query.getOrgName()); |
||||
|
} |
||||
|
return qw; |
||||
|
} |
||||
|
|
||||
|
public PagerVo<OrganizationAppKeyVo> listPageVo(PagerQuery<OrganizationAppKeyQuery> pq) { |
||||
|
OrganizationAppKeyQuery query = pq.getParams(); |
||||
|
QueryWrapper<OrganizationAppKey> qw = createQueryWrapper(query); |
||||
|
IPage<OrganizationAppKey> page = PagerUtil.queryToPage(pq); |
||||
|
IPage<OrganizationAppKeyVo> pagging = baseMapper.listPage(page, qw); |
||||
|
PagerVo<OrganizationAppKeyVo> p = PagerUtil.pageToVo(pagging, null); |
||||
|
return p; |
||||
|
} |
||||
|
|
||||
|
public ResultBean saveAppKey(OrganizationAppKeyDto dto){ |
||||
|
ResultBean rb= new ResultBean().fail(); |
||||
|
List<SysOrgRegister> orgSid = sysOrgRegisterService.list(new QueryWrapper<SysOrgRegister>().eq("orgSid", dto.getOrgSid())); |
||||
|
if(orgSid.stream().filter(s->s.getRegType().equals("1")).collect(Collectors.toList()).size()==orgSid.size()){ |
||||
|
return rb.setMsg("请先购买正式版本"); |
||||
|
} |
||||
|
if(orgSid.stream().filter(s->s.getExpireDate().compareTo(new Date())==-1).collect(Collectors.toList()).size()==orgSid.size()){ |
||||
|
return rb.setMsg("正式已过有效期"); |
||||
|
} |
||||
|
OrganizationAppKey organiz = baseMapper.selectOne(new QueryWrapper<OrganizationAppKey>().eq("orgSid", orgSid.get(0).getOrgSid())); |
||||
|
if(organiz!=null){ |
||||
|
return rb.setMsg("此组织已申请过appkey"); |
||||
|
} |
||||
|
OrganizationAppKey organizationAppKey=new OrganizationAppKey(); |
||||
|
BeanUtil.copyProperties(dto,organizationAppKey); |
||||
|
organizationAppKey.setAppKey(organizationAppKey.getSid().substring(organizationAppKey.getSid().length()-10)); |
||||
|
organizationAppKey.setSecret(organizationAppKey.getSid().substring(0,8)); |
||||
|
organizationAppKey.setState(1); |
||||
|
baseMapper.insert(organizationAppKey); |
||||
|
return new ResultBean().success().setMsg("成功"); |
||||
|
} |
||||
|
|
||||
|
public static void main(String[] args) { |
||||
|
Date date = new Date("2025-08-10 00:00:00"); |
||||
|
System.out.println(date); |
||||
|
|
||||
|
} |
||||
|
public ResultBean getAppkeyByOrgSid(String orgSid){ |
||||
|
OrganizationAppKey organizationAppKey = baseMapper.selectOne(new QueryWrapper<OrganizationAppKey>().eq("orgSid", orgSid)); |
||||
|
return new ResultBean().success().setData(organizationAppKey); |
||||
|
} |
||||
|
public ResultBean<OrganizationAppKey> checkByAppKey(String appKey){ |
||||
|
OrganizationAppKey organizationAppKey = baseMapper.selectOne(new QueryWrapper<OrganizationAppKey>().eq("appKey", appKey)); |
||||
|
return new ResultBean().success().setData(organizationAppKey); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,21 @@ |
|||||
|
package com.yxt.portal.biz.organizationappkey; |
||||
|
|
||||
|
import com.alibaba.fastjson.annotation.JSONField; |
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2025/1/21 11:19 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class OrganizationAppKeyVo { |
||||
|
private String orgSid; |
||||
|
private String appKey; |
||||
|
private String secret; |
||||
|
private String state; |
||||
|
private String stateValue; |
||||
|
private String orgName; |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
private String createTime; |
||||
|
} |
Loading…
Reference in new issue