Commit c6b23de1 by giaogiao

1.商家端注册;

2.优化托管出售
parent e20ae98d
......@@ -109,7 +109,7 @@ public class AppSmsServiceImpl implements AppSmsService {
*/
String getRandomCode() {
// 如果为测试环境则生成默认
if (profiles.equals(DEV_PROFILE)) {
if (profiles.equals(DEV_PROFILE) || profiles.equals("test")) {
return DEFAULT_DEV_SMS_CODE;
} else {
return Arrays.toString(RandomUtil.randomInts(6));
......
package com.jumeirah.api.merchant.controller;
import com.jumeirah.api.merchant.service.MerchantSmsService;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* APP用户 控制器
*
* @author wei
* @since 2020-09-23
*/
@Slf4j
@RestController
//@Module("api-app")
@Api(value = "短信验证码", tags = {"APP短信验证码相关"})
@RequestMapping("/app/sms/")
public class MerchantSmsController extends BaseController {
@Autowired
private MerchantSmsService merchantSmsService;
/**
* 获取注册验证码
*/
@GetMapping("/registerCode")
@OperationLog(name = "获取注册或登陆的验证码", type = OperationLogType.INFO)
@ApiOperation(value = "获取注册或登陆的验证码", response = Object.class, notes = "本地环境默认666666")
public ApiResult<Object> registerOrLoginCode(@RequestParam String phoneArea, @RequestParam String phone) throws Exception {
return merchantSmsService.registerCode(phoneArea, phone);
}
}
......@@ -108,5 +108,12 @@ public class MerchantUserController extends BaseController {
return merchantUserService.login(loginParam, response, language);
}
@PostMapping("/register")
@OperationLogIgnore
@ApiOperation(value = "注册", notes = "商家注册", response = LoginSysUserTokenVo.class)
public ApiResult<LoginSysUserTokenVo> register(@Validated @RequestBody LoginParam loginParam, HttpServletResponse response, @RequestHeader(required = false) String language) throws Exception {
return merchantUserService.login(loginParam, response, language);
}
}
package com.jumeirah.api.merchant.service;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
public interface MerchantSmsService {
void deleteRegisterCode(String area, String number);
/**
* 获取注册验证码
*/
ApiResult<Object> registerCode(String phoneArea, String phone);
/**
* 获取注册验证码
*/
ApiResult LoginType(String area, String number);
/**
* 校验注册验证码
*
* @param area
* @param number
* @param code
* @return
*/
boolean equalsRegisterCode(String area, String number, String code);
/**
* 校验验登陆证码
*
* @param area
* @param number
* @param code
* @return
*/
boolean equalsLoginCode(String area, String number, String code);
}
package com.jumeirah.api.merchant.service;
import cn.hutool.core.util.RandomUtil;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.time.Duration;
import java.util.Arrays;
@Service
@Slf4j
public class MerchantSmsServiceImpl implements MerchantSmsService {
/**
* 获取当前环境
*/
@Value("${spring.profiles.active}")
private String profiles;
@Autowired
private RedisTemplate redisTemplate;
/**
* 测试环境
*/
private static final String DEV_PROFILE = "dev";
/**
* 测试环境默认短信验证码
*/
private static final String DEFAULT_DEV_SMS_CODE = "666666";
/**
* 短信验证码redis的key值
*/
private static final String SMS_REGIEST = "mer:sms:register:%s_%s";
/**
* 短信验证码redis的key值
*/
private static final String SMS_LOGIN = "mer:sms:login:%s_%s";
@Override
public void deleteRegisterCode(String area, String number) {
redisTemplate.delete(String.format(SMS_REGIEST, area, number));
}
@Override
public ApiResult<Object> registerCode(String area, String number) {
return getSmsCodeApiResult(String.format(SMS_REGIEST, area, number), area, number);
}
private ApiResult<Object> getSmsCodeApiResult(String key, String area, String number) {
String randomCode = getRandomCode();
// 过期时间(秒)
long expire = 120L;
Duration expireDuration = Duration.ofSeconds(expire);
redisTemplate.opsForValue().set(key, randomCode, expireDuration);
log.info(area + "," + number + ":" + randomCode);
// TODO 需要补充调用短信平台发送短信代码 2020年09月30日09:48:42
return ApiResult.ok(null);
}
@Override
public ApiResult LoginType(String area, String number) {
return getSmsCodeApiResult(String.format(SMS_LOGIN, area, number), area, number);
}
@Override
public boolean equalsRegisterCode(String area, String number, String code) {
return equalsSms(SMS_REGIEST, area, number, code);
}
private boolean equalsSms(String type, String area, String number, String code) {
String formatKey = String.format(type, area, number);
Object key = redisTemplate.opsForValue().get(formatKey);
if (key == null) {
return false;
}
return String.valueOf(key).equals(code);
}
@Override
public boolean equalsLoginCode(String area, String number, String code) {
return equalsSms(SMS_LOGIN, area, number, code);
}
/**
* 生成验证码code
*
* @return
*/
String getRandomCode() {
// 如果为测试环境则生成默认
if (profiles.equals(DEV_PROFILE) || profiles.equals("test")) {
return DEFAULT_DEV_SMS_CODE;
} else {
return Arrays.toString(RandomUtil.randomInts(6));
}
}
}
package com.jumeirah.api.merchant.service;
import com.jumeirah.common.param.app.AppSmsRegisterParam;
import com.jumeirah.common.param.app.AppUserInfoParam;
import com.jumeirah.common.vo.app.LoginAppUserTokenVo;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
public interface MerchantUserApiService {
/**
* 注册
* @param loginParam
* @param language
* @return
* @throws Exception
*/
ApiResult<LoginAppUserTokenVo> register(AppSmsRegisterParam loginParam, String language) throws Exception;
// ApiResult<LoginAppUserTokenVo> login(AppSmsRegisterParam loginParam, String language) throws Exception;
/**
* 修改或补充用户信息
* @param appUserInfoParam
* @return
* @throws Exception
*/
boolean updateAppUser(AppUserInfoParam appUserInfoParam) throws Exception;
}
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jumeirah.api.system.controller;
import io.geekidea.springbootplus.config.properties.SpringBootPlusProperties;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.log.annotation.Module;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.geekidea.springbootplus.framework.util.DownloadUtil;
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.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 下载控制器
*
* @author geekidea
* @date 2019/8/20
* @since 1.2.1-RELEASE
*/
@Slf4j
@Controller
@RequestMapping("/sys/download")
@Module("system")
@Api(value = "文件下载", tags = {"文件下载"})
public class DownloadController {
@Autowired
private SpringBootPlusProperties springBootPlusProperties;
/**
* 下载文件
*/
@GetMapping("/{downloadFileName}")
@OperationLog(name = "下载文件", type = OperationLogType.download)
@ApiOperation(value = "下载文件", notes = "下载文件", response = ApiResult.class)
public void download(@PathVariable(required = true) String downloadFileName, HttpServletResponse response) throws Exception {
// 下载目录,既是上传目录
String downloadDir = springBootPlusProperties.getUploadPath();
// 允许下载的文件后缀
List<String> allowFileExtensions = springBootPlusProperties.getAllowDownloadFileExtensions();
// 文件下载,使用默认下载处理器
// 文件下载,使用自定义下载处理器
DownloadUtil.download(downloadDir, downloadFileName, allowFileExtensions, response, (dir, fileName, file, fileExtension, contentType, length) -> {
// 下载自定义处理,返回true:执行下载,false:取消下载
log.info("dir = " + dir);
log.info("fileName = " + fileName);
log.info("file = " + file);
log.info("fileExtension = " + fileExtension);
log.info("contentType = " + contentType);
log.info("length = " + length);
return true;
});
}
}
///*
// * Copyright 2019-2029 geekidea(https://github.com/geekidea)
// *
// * Licensed under the Apache License, Version 2.0 (the "License");
// * you may not use this file except in compliance with the License.
// * You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// */
//
//package com.jumeirah.api.system.controller;
//
//import io.geekidea.springbootplus.config.properties.SpringBootPlusProperties;
//import io.geekidea.springbootplus.framework.common.api.ApiResult;
//import io.geekidea.springbootplus.framework.log.annotation.Module;
//import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
//import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
//import io.geekidea.springbootplus.framework.util.DownloadUtil;
//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.stereotype.Controller;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.RequestMapping;
//
//import javax.servlet.http.HttpServletResponse;
//import java.util.List;
//
///**
// * 下载控制器
// *
// * @author geekidea
// * @date 2019/8/20
// * @since 1.2.1-RELEASE
// */
//@Slf4j
//@Controller
//@RequestMapping("/sys/download")
//@Module("system")
//@Api(value = "文件下载", tags = {"文件下载"})
//public class DownloadController {
//
// @Autowired
// private SpringBootPlusProperties springBootPlusProperties;
//
// /**
// * 下载文件
// */
// @GetMapping("/{downloadFileName}")
// @OperationLog(name = "下载文件", type = OperationLogType.download)
// @ApiOperation(value = "下载文件", notes = "下载文件", response = ApiResult.class)
// public void download(@PathVariable(required = true) String downloadFileName, HttpServletResponse response) throws Exception {
// // 下载目录,既是上传目录
// String downloadDir = springBootPlusProperties.getUploadPath();
// // 允许下载的文件后缀
// List<String> allowFileExtensions = springBootPlusProperties.getAllowDownloadFileExtensions();
// // 文件下载,使用默认下载处理器
// // 文件下载,使用自定义下载处理器
// DownloadUtil.download(downloadDir, downloadFileName, allowFileExtensions, response, (dir, fileName, file, fileExtension, contentType, length) -> {
// // 下载自定义处理,返回true:执行下载,false:取消下载
// log.info("dir = " + dir);
// log.info("fileName = " + fileName);
// log.info("file = " + file);
// log.info("fileExtension = " + fileExtension);
// log.info("contentType = " + contentType);
// log.info("length = " + length);
// return true;
// });
// }
//
//}
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jumeirah.api.system.controller;
import io.geekidea.springbootplus.config.properties.SpringBootPlusProperties;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.log.annotation.Module;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
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.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletResponse;
/**
* 图片等文件资源访问控制器
* /api/resource 访问路径 用于区分 文件访问虚拟目录映射 /resource
*
* @author geekidea
* @date 2019/8/20
* @since 1.2.1-RELEASE
*/
@Slf4j
@Controller
@RequestMapping("/api/resource")
@Module("system")
@Api(value = "资源访问", tags = {"资源访问"})
public class ResourceController {
@Autowired
private SpringBootPlusProperties springBootPlusProperties;
/**
* 访问资源
*/
@GetMapping("/image/{imageFileName}")
@OperationLog(name = "访问资源", type = OperationLogType.ADD)
@ApiOperation(value = "访问资源", response = ApiResult.class)
public void getImage(@PathVariable(required = true) String imageFileName, HttpServletResponse response) throws Exception {
log.info("imageFileName:{}", imageFileName);
// 重定向到图片访问路径
response.sendRedirect(springBootPlusProperties.getResourceAccessPath() + imageFileName);
}
}
///*
// * Copyright 2019-2029 geekidea(https://github.com/geekidea)
// *
// * Licensed under the Apache License, Version 2.0 (the "License");
// * you may not use this file except in compliance with the License.
// * You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// */
//
//package com.jumeirah.api.system.controller;
//
//import io.geekidea.springbootplus.config.properties.SpringBootPlusProperties;
//import io.geekidea.springbootplus.framework.common.api.ApiResult;
//import io.geekidea.springbootplus.framework.log.annotation.Module;
//import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
//import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
//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.stereotype.Controller;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.RequestMapping;
//
//import javax.servlet.http.HttpServletResponse;
//
///**
// * 图片等文件资源访问控制器
// * /api/resource 访问路径 用于区分 文件访问虚拟目录映射 /resource
// *
// * @author geekidea
// * @date 2019/8/20
// * @since 1.2.1-RELEASE
// */
//@Slf4j
//@Controller
//@RequestMapping("/api/resource")
//@Module("system")
//@Api(value = "资源访问", tags = {"资源访问"})
//public class ResourceController {
//
// @Autowired
// private SpringBootPlusProperties springBootPlusProperties;
//
// /**
// * 访问资源
// */
// @GetMapping("/image/{imageFileName}")
// @OperationLog(name = "访问资源", type = OperationLogType.ADD)
// @ApiOperation(value = "访问资源", response = ApiResult.class)
// public void getImage(@PathVariable(required = true) String imageFileName, HttpServletResponse response) throws Exception {
// log.info("imageFileName:{}", imageFileName);
// // 重定向到图片访问路径
// response.sendRedirect(springBootPlusProperties.getResourceAccessPath() + imageFileName);
// }
//
//}
package com.jumeirah.api.system.controller;
import com.jumeirah.api.system.service.SysSmsService;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* APP用户 控制器
*
* @author wei
* @since 2020-09-23
*/
@Slf4j
@RestController
@Api(value = "短信验证码", tags = {"短信验证码相关"})
@RequestMapping("/sys/sms/")
public class SysSmsController extends BaseController {
@Autowired
private SysSmsService appSmsService;
/**
* 获取注册验证码
*/
@GetMapping("/registerCode")
@OperationLog(name = "获取注册验证码", type = OperationLogType.INFO)
@ApiOperation(value = "获取注册验证码", response = Object.class, notes = "本地环境默认666666")
public ApiResult<Object> registerOrLoginCode(@RequestParam String phoneArea, @RequestParam String phone) throws Exception {
return appSmsService.registerOrLoginCode(phoneArea, phone);
}
}
......@@ -23,7 +23,6 @@ import com.jumeirah.common.param.sysuser.UpdatePasswordParam;
import com.jumeirah.common.param.sysuser.UploadHeadParam;
import com.jumeirah.common.service.SysUserService;
import com.jumeirah.common.vo.SysUserQueryVo;
import io.geekidea.springbootplus.config.properties.SpringBootPlusProperties;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
......@@ -63,9 +62,6 @@ public class SysUserController extends BaseController {
@Autowired
private SysUserService sysUserService;
@Autowired
private SpringBootPlusProperties springBootPlusProperties;
/**
* 添加系统用户
*/
......
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jumeirah.api.system.controller;
import io.geekidea.springbootplus.config.properties.SpringBootPlusProperties;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.log.annotation.Module;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.geekidea.springbootplus.framework.util.UploadUtil;
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.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/**
* 上传控制器
*
* @author geekidea
* @date 2019/8/20
* @since 1.2.1-RELEASE
*/
@Slf4j
@RestController
@RequestMapping("/sys/upload")
@Module("system")
@Api(value = "文件上传", tags = {"文件上传"})
public class UploadController {
@Autowired
private SpringBootPlusProperties springBootPlusProperties;
/**
* 上传单个文件
*
* @return
*/
@PostMapping
@OperationLog(name = "上传单个文件", type = OperationLogType.UPLOAD)
@ApiOperation(value = "上传单个文件", response = ApiResult.class)
@ApiImplicitParams({
@ApiImplicitParam(name = "file", value = "文件", required = true, dataType = "__file"),
@ApiImplicitParam(name = "type", value = "类型 head:头像", required = true)
})
public ApiResult<String> upload(@RequestParam("file") MultipartFile multipartFile,
@RequestParam("type") String type) throws Exception {
log.info("multipartFile = " + multipartFile);
log.info("ContentType = " + multipartFile.getContentType());
log.info("OriginalFilename = " + multipartFile.getOriginalFilename());
log.info("Name = " + multipartFile.getName());
log.info("Size = " + multipartFile.getSize());
log.info("type = " + type);
// 上传文件,返回保存的文件名称
String saveFileName = UploadUtil.upload(springBootPlusProperties.getUploadPath(), multipartFile, originalFilename -> {
// 文件后缀
String fileExtension = FilenameUtils.getExtension(originalFilename);
// 这里可自定义文件名称,比如按照业务类型/文件格式/日期
String dateString = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssS")) + RandomStringUtils.randomNumeric(6);
String fileName = dateString + "." + fileExtension;
return fileName;
});
// 上传成功之后,返回访问路径,请根据实际情况设置
String fileAccessPath = springBootPlusProperties.getResourceAccessUrl() + saveFileName;
log.info("fileAccessPath:{}", fileAccessPath);
return ApiResult.ok(fileAccessPath);
}
}
///*
// * Copyright 2019-2029 geekidea(https://github.com/geekidea)
// *
// * Licensed under the Apache License, Version 2.0 (the "License");
// * you may not use this file except in compliance with the License.
// * You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// */
//
//package com.jumeirah.api.system.controller;
//
//import io.geekidea.springbootplus.config.properties.SpringBootPlusProperties;
//import io.geekidea.springbootplus.framework.common.api.ApiResult;
//import io.geekidea.springbootplus.framework.log.annotation.Module;
//import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
//import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
//import io.geekidea.springbootplus.framework.util.UploadUtil;
//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.apache.commons.io.FilenameUtils;
//import org.apache.commons.lang3.RandomStringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.multipart.MultipartFile;
//
//import java.time.LocalDateTime;
//import java.time.format.DateTimeFormatter;
//
///**
// * 上传控制器
// *
// * @author geekidea
// * @date 2019/8/20
// * @since 1.2.1-RELEASE
// */
//@Slf4j
//@RestController
//@RequestMapping("/sys/upload")
//@Module("system")
//@Api(value = "文件上传", tags = {"文件上传"})
//public class UploadController {
//
// @Autowired
// private SpringBootPlusProperties springBootPlusProperties;
//
// /**
// * 上传单个文件
// *
// * @return
// */
// @PostMapping
// @OperationLog(name = "上传单个文件", type = OperationLogType.UPLOAD)
// @ApiOperation(value = "上传单个文件", response = ApiResult.class)
// @ApiImplicitParams({
// @ApiImplicitParam(name = "file", value = "文件", required = true, dataType = "__file"),
// @ApiImplicitParam(name = "type", value = "类型 head:头像", required = true)
// })
// public ApiResult<String> upload(@RequestParam("file") MultipartFile multipartFile,
// @RequestParam("type") String type) throws Exception {
// log.info("multipartFile = " + multipartFile);
// log.info("ContentType = " + multipartFile.getContentType());
// log.info("OriginalFilename = " + multipartFile.getOriginalFilename());
// log.info("Name = " + multipartFile.getName());
// log.info("Size = " + multipartFile.getSize());
// log.info("type = " + type);
//
// // 上传文件,返回保存的文件名称
// String saveFileName = UploadUtil.upload(springBootPlusProperties.getUploadPath(), multipartFile, originalFilename -> {
// // 文件后缀
// String fileExtension = FilenameUtils.getExtension(originalFilename);
// // 这里可自定义文件名称,比如按照业务类型/文件格式/日期
// String dateString = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssS")) + RandomStringUtils.randomNumeric(6);
// String fileName = dateString + "." + fileExtension;
// return fileName;
// });
//
// // 上传成功之后,返回访问路径,请根据实际情况设置
//
// String fileAccessPath = springBootPlusProperties.getResourceAccessUrl() + saveFileName;
// log.info("fileAccessPath:{}", fileAccessPath);
//
// return ApiResult.ok(fileAccessPath);
// }
//
//}
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jumeirah.api.system.controller;
import io.geekidea.springbootplus.config.constant.CommonConstant;
import io.geekidea.springbootplus.config.constant.CommonRedisKey;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.log.annotation.Module;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.geekidea.springbootplus.framework.util.UUIDUtil;
import io.geekidea.springbootplus.framework.util.VerificationCode;
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.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* 验证码接口
*
* @author geekidea
* @date 2019-10-27
**/
@Slf4j
@Controller
@Api(value = "验证码API", tags = {"验证码"})
@Module("system")
@RequestMapping("/sys/verificationCode")
@ConditionalOnProperty(value = {"spring-boot-plus.enable-verify-code"}, matchIfMissing = true)
public class VerificationCodeController {
@Autowired
private RedisTemplate<String, String> redisTemplate;
/**
* 获取验证码
*/
@GetMapping("/getImage")
@OperationLog(name = "获取验证码", type = OperationLogType.OTHER)
@ApiOperation(value = "获取验证码", response = ApiResult.class)
public void getImage(HttpServletResponse response) throws Exception {
VerificationCode verificationCode = new VerificationCode();
BufferedImage image = verificationCode.getImage();
String code = verificationCode.getText();
String verifyToken = UUIDUtil.getUuid();
// 缓存到Redis
redisTemplate.opsForValue().set(String.format(CommonRedisKey.VERIFY_CODE, verifyToken), code, 5, TimeUnit.MINUTES);
response.setHeader(CommonConstant.VERIFY_TOKEN, verifyToken);
response.setContentType(MediaType.IMAGE_JPEG_VALUE);
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expire", 0);
ServletOutputStream outputStream = response.getOutputStream();
ImageIO.write(image, CommonConstant.JPEG, outputStream);
}
/**
* 获取图片Base64验证码
*/
@GetMapping("/getBase64Image")
@ResponseBody
@OperationLog(name = "获取图片Base64验证码", type = OperationLogType.OTHER)
@ApiOperation(value = "获取图片Base64验证码", response = ApiResult.class)
public ApiResult<Map<String, Object>> getCode(HttpServletResponse response) throws Exception {
VerificationCode verificationCode = new VerificationCode();
BufferedImage image = verificationCode.getImage();
String code = verificationCode.getText();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ImageIO.write(image, CommonConstant.JPEG, outputStream);
// 将图片转换成base64字符串
String base64 = Base64.getEncoder().encodeToString(outputStream.toByteArray());
// 生成当前验证码会话token
String verifyToken = UUIDUtil.getUuid();
Map<String, Object> map = new HashMap<>(2);
map.put(CommonConstant.IMAGE, CommonConstant.BASE64_PREFIX + base64);
map.put(CommonConstant.VERIFY_TOKEN, verifyToken);
// 缓存到Redis
redisTemplate.opsForValue().set(String.format(CommonRedisKey.VERIFY_CODE, verifyToken), code, 5, TimeUnit.MINUTES);
return ApiResult.ok(map);
}
}
///*
// * Copyright 2019-2029 geekidea(https://github.com/geekidea)
// *
// * Licensed under the Apache License, Version 2.0 (the "License");
// * you may not use this file except in compliance with the License.
// * You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// */
//
//package com.jumeirah.api.system.controller;
//
//import io.geekidea.springbootplus.config.constant.CommonConstant;
//import io.geekidea.springbootplus.config.constant.CommonRedisKey;
//import io.geekidea.springbootplus.framework.common.api.ApiResult;
//import io.geekidea.springbootplus.framework.log.annotation.Module;
//import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
//import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
//import io.geekidea.springbootplus.framework.util.UUIDUtil;
//import io.geekidea.springbootplus.framework.util.VerificationCode;
//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.boot.autoconfigure.condition.ConditionalOnProperty;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.http.MediaType;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//import javax.imageio.ImageIO;
//import javax.servlet.ServletOutputStream;
//import javax.servlet.http.HttpServletResponse;
//import java.awt.image.BufferedImage;
//import java.io.ByteArrayOutputStream;
//import java.util.Base64;
//import java.util.HashMap;
//import java.util.Map;
//import java.util.concurrent.TimeUnit;
//
///**
// * 验证码接口
// *
// * @author geekidea
// * @date 2019-10-27
// **/
//@Slf4j
//@Controller
//@Api(value = "验证码API", tags = {"验证码"})
//@Module("system")
//@RequestMapping("/sys/verificationCode")
//@ConditionalOnProperty(value = {"spring-boot-plus.enable-verify-code"}, matchIfMissing = true)
//public class VerificationCodeController {
//
// @Autowired
// private RedisTemplate<String, String> redisTemplate;
//
// /**
// * 获取验证码
// */
// @GetMapping("/getImage")
// @OperationLog(name = "获取验证码", type = OperationLogType.OTHER)
// @ApiOperation(value = "获取验证码", response = ApiResult.class)
// public void getImage(HttpServletResponse response) throws Exception {
// VerificationCode verificationCode = new VerificationCode();
// BufferedImage image = verificationCode.getImage();
// String code = verificationCode.getText();
// String verifyToken = UUIDUtil.getUuid();
// // 缓存到Redis
// redisTemplate.opsForValue().set(String.format(CommonRedisKey.VERIFY_CODE, verifyToken), code, 5, TimeUnit.MINUTES);
// response.setHeader(CommonConstant.VERIFY_TOKEN, verifyToken);
// response.setContentType(MediaType.IMAGE_JPEG_VALUE);
// response.setHeader("Pragma", "No-cache");
// response.setHeader("Cache-Control", "no-cache");
// response.setDateHeader("Expire", 0);
// ServletOutputStream outputStream = response.getOutputStream();
// ImageIO.write(image, CommonConstant.JPEG, outputStream);
// }
//
// /**
// * 获取图片Base64验证码
// */
// @GetMapping("/getBase64Image")
// @ResponseBody
// @OperationLog(name = "获取图片Base64验证码", type = OperationLogType.OTHER)
// @ApiOperation(value = "获取图片Base64验证码", response = ApiResult.class)
// public ApiResult<Map<String, Object>> getCode(HttpServletResponse response) throws Exception {
// VerificationCode verificationCode = new VerificationCode();
// BufferedImage image = verificationCode.getImage();
// String code = verificationCode.getText();
// ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
// ImageIO.write(image, CommonConstant.JPEG, outputStream);
// // 将图片转换成base64字符串
// String base64 = Base64.getEncoder().encodeToString(outputStream.toByteArray());
// // 生成当前验证码会话token
// String verifyToken = UUIDUtil.getUuid();
// Map<String, Object> map = new HashMap<>(2);
// map.put(CommonConstant.IMAGE, CommonConstant.BASE64_PREFIX + base64);
// map.put(CommonConstant.VERIFY_TOKEN, verifyToken);
// // 缓存到Redis
// redisTemplate.opsForValue().set(String.format(CommonRedisKey.VERIFY_CODE, verifyToken), code, 5, TimeUnit.MINUTES);
// return ApiResult.ok(map);
// }
//
//}
package com.jumeirah.api.system.service;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
public interface SysSmsService {
void deleteRegisterCode(String area, String number);
/**
* 获取注册验证码
*/
ApiResult<Object> registerOrLoginCode(String phoneArea, String phone);
/**
* 获取注册验证码
*/
ApiResult<Object> registerCode(String area, String phone);
/**
* 获取注册验证码
*/
ApiResult LoginType(String area, String number);
/**
* 校验注册验证码
*
* @param area
* @param number
* @param code
* @return
*/
boolean equalsRegisterCode(String area, String number, String code);
/**
* 校验验登陆证码
*
* @param area
* @param number
* @param code
* @return
*/
boolean equalsLoginCode(String area, String number, String code);
}
package com.jumeirah.api.system.service;
import cn.hutool.core.util.RandomUtil;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.time.Duration;
import java.util.Arrays;
@Service
@Slf4j
public class SysSmsServiceImpl implements SysSmsService {
/**
* 获取当前环境
*/
@Value("${spring.profiles.active}")
private String profiles;
@Autowired
private RedisTemplate redisTemplate;
/**
* 测试环境
*/
private static final String DEV_PROFILE = "dev";
/**
* 测试环境默认短信验证码
*/
private static final String DEFAULT_DEV_SMS_CODE = "666666";
/**
* 短信验证码redis的key值
*/
private static final String SMS_REGIEST = "sys:sms:register:%s_%s";
/**
* 短信验证码redis的key值
*/
private static final String SMS_LOGIN = "sys:sms:login:%s_%s";
@Override
public void deleteRegisterCode(String area, String number) {
redisTemplate.delete(String.format(SMS_REGIEST, area, number));
}
@Override
public ApiResult<Object> registerOrLoginCode(String area, String phone) {
return getSmsCodeApiResult(String.format(SMS_REGIEST, area, phone), area, phone);
}
@Override
public ApiResult<Object> registerCode(String area, String phone) {
return getSmsCodeApiResult(String.format(SMS_REGIEST, area, phone), area, phone);
}
private ApiResult<Object> getSmsCodeApiResult(String key, String area, String number) {
String randomCode = getRandomCode();
// 过期时间(秒)
long expire = 120L;
Duration expireDuration = Duration.ofSeconds(expire);
redisTemplate.opsForValue().set(key, randomCode, expireDuration);
// SmsCode smsCode = new SmsCode();
// smsCode.setSmsCode(randomCode);
// log.info(area + "," + number + ":" + randomCode);
// TODO 需要补充调用短信平台发送短信代码 2020年09月30日09:48:42
return ApiResult.ok(null);
}
@Override
public ApiResult LoginType(String area, String number) {
return getSmsCodeApiResult(String.format(SMS_LOGIN, area, number), area, number);
}
@Override
public boolean equalsRegisterCode(String area, String number, String code) {
return equalsSms(SMS_REGIEST, area, number, code);
}
private boolean equalsSms(String type, String area, String number, String code) {
String formatKey = String.format(type, area, number);
Object key = redisTemplate.opsForValue().get(formatKey);
if (key == null) {
return false;
}
return String.valueOf(key).equals(code);
}
@Override
public boolean equalsLoginCode(String area, String number, String code) {
return equalsSms(SMS_LOGIN, area, number, code);
}
/**
* 生成验证码code
*
* @return
*/
String getRandomCode() {
// 如果为测试环境则生成默认
if (profiles.equals(DEV_PROFILE) || profiles.equals("test")) {
return DEFAULT_DEV_SMS_CODE;
} else {
return Arrays.toString(RandomUtil.randomInts(6));
}
}
}
......@@ -63,4 +63,9 @@ public class BusinessPlain extends BaseEntity {
@ApiModelProperty("更新时间(时间戳)")
private Date updateTime;
@ApiModelProperty("图片高")
private Integer imageListHeight;
@ApiModelProperty("图片宽")
private Integer imageListWidth;
}
......@@ -2,6 +2,7 @@ package com.jumeirah.common.param;
import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
......@@ -20,4 +21,6 @@ import lombok.experimental.Accessors;
@ApiModel(value = "公务机出售/托管表分页参数")
public class BusinessPlainPageParam extends BasePageOrderParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty("类型,0-出售,1-托管")
private Integer type;
}
......@@ -63,7 +63,7 @@ public class BusinessPlainServiceImpl extends BaseServiceImpl<BusinessPlainMappe
@Override
public Paging<BusinessPlainQueryForAppVo> getBusinessPlainPageListForApp(BusinessPlainPageParam businessPlainPageParam) throws Exception {
Page<BusinessPlainQueryForAppVo> page = new PageInfo<>(businessPlainPageParam, OrderItem.desc(getLambdaColumn(BusinessPlain::getCreateTime)));
Page<BusinessPlainQueryForAppVo> page = new PageInfo<>(businessPlainPageParam, OrderItem.desc("bp.create_time"));
IPage<BusinessPlainQueryForAppVo> iPage = businessPlainMapper.getBusinessPlainPageListForApp(page, businessPlainPageParam);
return new Paging<>(iPage);
}
......
......@@ -22,10 +22,7 @@ public class BusinessPlainQueryForAppVo implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("商家name")
private Long mcName;
@ApiModelProperty("业务类型,0-出售,1-托管")
private Integer businessType;
private String mcName;
@ApiModelProperty("图片url")
private String imgUrl;
......@@ -42,4 +39,10 @@ public class BusinessPlainQueryForAppVo implements Serializable {
@ApiModelProperty("微信号")
private String wechat;
@ApiModelProperty("商家头像")
private String mcHead;
@ApiModelProperty("图片高")
private Integer imageListHeight;
@ApiModelProperty("图片宽")
private Integer imageListWidth;
}
\ No newline at end of file
......@@ -4,7 +4,7 @@
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, mc_id, business_type, img_url, introduction, name, phone, wechat, status, create_time, update_time
id, mc_id, business_type, img_url, introduction, name, phone, wechat, status, create_time, update_time,image_list_height,image_list_width
</sql>
<sql id="Base_Column_ListForApp">
......@@ -27,9 +27,10 @@
<select id="getBusinessPlainPageListForApp" parameterType="com.jumeirah.common.param.BusinessPlainPageParam"
resultType="com.jumeirah.common.vo.BusinessPlainQueryForAppVo">
select
<include refid="Base_Column_ListForApp"/>
<include refid="Base_Column_ListForApp"/>,bp.image_list_height,bp.image_list_width,m.`head` AS mcHead
from business_plain bp
INNER JOIN merchant m ON bp.mc_id=m.id
where bp.business_type=#{param.type}
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment