mirror of
https://gitee.com/ZhongBangKeJi/crmeb_java.git
synced 2026-05-07 08:41:24 +08:00
后端代码提交
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package com.zbkj.front.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.zbkj.common.exception.CrmebException;
|
||||
import com.zbkj.common.response.page.PageDiyResponse;
|
||||
import com.zbkj.common.result.CommonResult;
|
||||
import com.zbkj.service.service.PageDiyService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
/**
|
||||
* DIY数据表 前端控制器
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("api/front/pagediy")
|
||||
@Api(tags = "DIY 控制器") //配合swagger使用
|
||||
|
||||
public class PageDiyController {
|
||||
|
||||
@Autowired
|
||||
private PageDiyService pageDiyService;
|
||||
/**
|
||||
* 查询DIY数据表信息
|
||||
* @param id Integer
|
||||
* @author dazongzi
|
||||
* @since 2023-05-16
|
||||
*/
|
||||
@ApiOperation(value = "详情")
|
||||
@RequestMapping(value = "/info/{id}", method = RequestMethod.GET)
|
||||
public CommonResult<PageDiyResponse> info(@PathVariable(value = "id") Integer id){
|
||||
PageDiyResponse response = pageDiyService.getDiyPageByPageIdForFront(id);
|
||||
if(ObjectUtil.isNull(response)) throw new CrmebException("未找到对应模版信息");
|
||||
return CommonResult.success(response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.zbkj.front.controller;
|
||||
|
||||
|
||||
import com.zbkj.common.result.CommonResult;
|
||||
import com.zbkj.common.vo.FileResultVo;
|
||||
import com.zbkj.service.service.UploadService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
/**
|
||||
* 上传文件 前端控制器 -- 用户端
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("api/front/upload")
|
||||
@Api(tags = "用户上传文件")
|
||||
public class UserUploadController {
|
||||
|
||||
@Autowired
|
||||
private UploadService uploadService;
|
||||
|
||||
/**
|
||||
* 图片上传
|
||||
*/
|
||||
@ApiOperation(value = "图片上传")
|
||||
@RequestMapping(value = "/image", method = RequestMethod.POST)
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "model", value = "模块 用户user,商品product,微信wechat,news文章"),
|
||||
@ApiImplicitParam(name = "pid", value = "分类ID 0编辑器,1商品图片,2拼团图片,3砍价图片,4秒杀图片,5文章图片,6组合数据图,7前台用户,8微信系列 ", allowableValues = "range[0,1,2,3,4,5,6,7,8]")
|
||||
})
|
||||
public CommonResult<FileResultVo> image(MultipartFile multipart,
|
||||
@RequestParam(value = "model") String model,
|
||||
@RequestParam(value = "pid") Integer pid) throws IOException {
|
||||
|
||||
return CommonResult.success(uploadService.imageUpload(multipart, model, pid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
*/
|
||||
@ApiOperation(value = "文件上传")
|
||||
@RequestMapping(value = "/file", method = RequestMethod.POST)
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "model", value = "模块 用户user,商品product,微信wechat,news文章"),
|
||||
@ApiImplicitParam(name = "pid", value = "分类ID 0编辑器,1商品图片,2拼团图片,3砍价图片,4秒杀图片,5文章图片,6组合数据图,7前台用户,8微信系列 ", allowableValues = "range[0,1,2,3,4,5,6,7,8]")
|
||||
})
|
||||
public CommonResult<FileResultVo> file(MultipartFile multipart,
|
||||
@RequestParam(value = "model") String model,
|
||||
@RequestParam(value = "pid") Integer pid) throws IOException {
|
||||
return CommonResult.success(uploadService.fileUpload(multipart, model, pid));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.zbkj.front.pub;
|
||||
|
||||
import com.zbkj.common.constants.CopyrightConstants;
|
||||
import com.zbkj.common.response.CopyRightResponse;
|
||||
import com.zbkj.common.response.PayConfigResponse;
|
||||
import com.zbkj.common.result.CommonResult;
|
||||
import com.zbkj.service.service.SystemConfigService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 公开设置控制器
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("api/public/config")
|
||||
@Api(tags = "公开设置控制器")
|
||||
public class PubliclyConfigController {
|
||||
|
||||
@Autowired
|
||||
private SystemConfigService systemConfigService;
|
||||
|
||||
@ApiOperation(value = "获取版权")
|
||||
@RequestMapping(value = "/get/copyright", method = RequestMethod.GET)
|
||||
public CommonResult<CopyRightResponse> getCopyright() {
|
||||
CopyRightResponse copyRightResponse = new CopyRightResponse();
|
||||
copyRightResponse.setCopyrightIcpNumber(systemConfigService.getValueByKey(CopyrightConstants.COPYRIGHT_ICP_NUMBER));
|
||||
copyRightResponse.setCopyrightIcpNumberUrl(systemConfigService.getValueByKey(CopyrightConstants.COPYRIGHT_ICP_NUMBER_URL));
|
||||
copyRightResponse.setCopyrightInternetRecord(systemConfigService.getValueByKey(CopyrightConstants.COPYRIGHT_INTERNET_RECORD));
|
||||
copyRightResponse.setCopyrightInternetRecordUrl(systemConfigService.getValueByKey(CopyrightConstants.COPYRIGHT_INTERNET_RECORD_URL));
|
||||
return CommonResult.success(copyRightResponse);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取移动端域名")
|
||||
@RequestMapping(value = "/get/front/domain", method = RequestMethod.GET)
|
||||
public CommonResult<String> getFrontDomain() {
|
||||
return CommonResult.success(systemConfigService.getFrontDomain());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取平台当前的素材地址")
|
||||
@RequestMapping(value = "/get/admin/mediadomain", method = RequestMethod.GET)
|
||||
public CommonResult<String> getMediaDomain() {
|
||||
return CommonResult.success(systemConfigService.getMediaDomain());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.zbkj.front.pub;
|
||||
|
||||
import com.anji.captcha.model.common.ResponseModel;
|
||||
import com.zbkj.common.result.CommonResult;
|
||||
import com.zbkj.service.service.SafetyService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 安全验证控制器
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("api/public/safety")
|
||||
@Api(tags = "安全验证控制器")
|
||||
public class SafetyController {
|
||||
|
||||
@Autowired
|
||||
private SafetyService safetyService;
|
||||
|
||||
@ApiOperation(value = "获取行为验证码")
|
||||
@RequestMapping(value = "/get", method = RequestMethod.POST)
|
||||
public CommonResult<ResponseModel> getSafetyCode(@RequestBody com.anji.captcha.model.vo.CaptchaVO data, HttpServletRequest request) {
|
||||
return CommonResult.success(safetyService.getSafetyCode(data, request));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "验证行为验证码")
|
||||
@RequestMapping(value = "/check", method = RequestMethod.POST)
|
||||
public CommonResult<ResponseModel> checkSafetyCode(@RequestBody com.anji.captcha.model.vo.CaptchaVO data, HttpServletRequest request) {
|
||||
return CommonResult.success(safetyService.checkSafetyCode(data, request));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "行为验证码二次校验")
|
||||
@RequestMapping(value = "/verify", method = RequestMethod.POST)
|
||||
public CommonResult<ResponseModel> verifySafetyCode(@RequestBody com.anji.captcha.model.vo.CaptchaVO data, HttpServletRequest request) {
|
||||
return CommonResult.success(safetyService.verifySafetyCode(data));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.zbkj.front.service.impl;
|
||||
|
||||
import com.anji.captcha.service.CaptchaCacheService;
|
||||
import com.zbkj.common.utils.RedisUtil;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 对于分布式部署的应用,我们建议应用自己实现CaptchaCacheService,比如用Redis,参考service/spring-boot代码示例。
|
||||
* 如果应用是单点的,也没有使用redis,那默认使用内存。
|
||||
* 内存缓存只适合单节点部署的应用,否则验证码生产与验证在节点之间信息不同步,导致失败。
|
||||
*
|
||||
* ☆☆☆ SPI: 在resources目录新建META-INF.services文件夹(两层),参考当前服务resources。
|
||||
*
|
||||
* @author Han
|
||||
* @version 1.0.0
|
||||
* @Date 2025/6/13
|
||||
*/
|
||||
public class CaptchaCacheServiceRedisImpl implements CaptchaCacheService {
|
||||
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
|
||||
@Override
|
||||
public String type() {
|
||||
return "redis";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void set(String key, String value, long expiresInSeconds) {
|
||||
redisUtil.getRedisTemplate().opsForValue().set(key, value, expiresInSeconds, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exists(String key) {
|
||||
return Boolean.TRUE.equals(redisUtil.getRedisTemplate().hasKey(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String key) {
|
||||
redisUtil.getRedisTemplate().delete(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(String key) {
|
||||
return (String) redisUtil.getRedisTemplate().opsForValue().get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long increment(String key, long val) {
|
||||
return redisUtil.getRedisTemplate().opsForValue().increment(key,val);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user