first commit
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package com.sqx.modules.urlAddress.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.utils.DateUtils;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.sys.controller.AbstractController;
|
||||
import com.sqx.modules.urlAddress.entity.UrlAddress;
|
||||
import com.sqx.modules.urlAddress.service.UrlAddressService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@RestController
|
||||
@Api(value = "域名池", tags = {"域名池"})
|
||||
@RequestMapping(value = "/urlAddress")
|
||||
public class UrlAddressController extends AbstractController {
|
||||
|
||||
@Autowired
|
||||
private UrlAddressService urlAddressService;
|
||||
|
||||
@PostMapping("/insertUrlAddress")
|
||||
@ApiOperation("创建域名")
|
||||
public Result insertUrlAddress(@RequestBody UrlAddress urlAddress){
|
||||
urlAddress.setCreateTime(DateUtils.format(new Date()));
|
||||
urlAddressService.save(urlAddress);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@PostMapping("/updateUrlAddress")
|
||||
@ApiOperation("修改域名")
|
||||
public Result updateUrlAddress(@RequestBody UrlAddress urlAddress){
|
||||
urlAddressService.updateById(urlAddress);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@PostMapping("/deleteUrlAddress")
|
||||
@ApiOperation("删除域名")
|
||||
public Result deleteUrlAddress(Long addressId){
|
||||
urlAddressService.removeById(addressId);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@GetMapping("/selectUrlAddressList")
|
||||
@ApiOperation("查询域名池列表")
|
||||
public Result selectUrlAddressList(Integer page,Integer limit,String urlAddress,Integer status){
|
||||
return Result.success().put("data",new PageUtils(urlAddressService.page(new Page<>(page,limit),
|
||||
new QueryWrapper<UrlAddress>().like(StringUtils.isNotEmpty(urlAddress),"url_address",urlAddress)
|
||||
.eq(status!=null && status!=0,"status",status))));
|
||||
}
|
||||
|
||||
@GetMapping("/selectUrlAddress")
|
||||
@ApiOperation("获取分享链接")
|
||||
public Result selectUrlAddress(){
|
||||
return Result.success().put("data",urlAddressService.selectUrlAddressOne());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.sqx.modules.urlAddress.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.urlAddress.entity.UrlAddress;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface UrlAddressDao extends BaseMapper<UrlAddress> {
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.sqx.modules.urlAddress.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @description url_address
|
||||
* @author fang
|
||||
* @date 2024-01-10
|
||||
*/
|
||||
@Data
|
||||
public class UrlAddress implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
/**
|
||||
* 域名池id
|
||||
*/
|
||||
private Integer urlId;
|
||||
|
||||
/**
|
||||
* 域名地址
|
||||
*/
|
||||
private String urlAddress;
|
||||
|
||||
/**
|
||||
* 使用次数
|
||||
*/
|
||||
private Integer num;
|
||||
|
||||
/**
|
||||
* 状态 1开启 2关闭
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
|
||||
public UrlAddress() {}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.sqx.modules.urlAddress.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.sqx.modules.urlAddress.entity.UrlAddress;
|
||||
|
||||
public interface UrlAddressService extends IService<UrlAddress> {
|
||||
|
||||
UrlAddress selectUrlAddressOne();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.sqx.modules.urlAddress.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sqx.modules.urlAddress.dao.UrlAddressDao;
|
||||
import com.sqx.modules.urlAddress.entity.UrlAddress;
|
||||
import com.sqx.modules.urlAddress.service.UrlAddressService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@Service
|
||||
public class UrlAddressServiceImpl extends ServiceImpl<UrlAddressDao, UrlAddress> implements UrlAddressService {
|
||||
|
||||
@Override
|
||||
public UrlAddress selectUrlAddressOne(){
|
||||
//获取最少数量的
|
||||
UrlAddress urlAddress = baseMapper.selectOne(new QueryWrapper<UrlAddress>().last(" order by num asc limit 1"));
|
||||
urlAddress.setNum(urlAddress.getNum()==null?1:urlAddress.getNum()+1);
|
||||
baseMapper.updateById(urlAddress);
|
||||
return urlAddress;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user