Commit 10bc084e by lpx

Merge branch 'master' of http://119.28.51.83/hewei/Jumeirah into dev/lanpingxiong

parents a1e8f5a9 b7920cd9
...@@ -109,7 +109,7 @@ public class AppSmsServiceImpl implements AppSmsService { ...@@ -109,7 +109,7 @@ public class AppSmsServiceImpl implements AppSmsService {
*/ */
String getRandomCode() { String getRandomCode() {
// 如果为测试环境则生成默认 // 如果为测试环境则生成默认
if (profiles.equals(DEV_PROFILE)) { if (profiles.equals(DEV_PROFILE) || profiles.equals("test")) {
return DEFAULT_DEV_SMS_CODE; return DEFAULT_DEV_SMS_CODE;
} else { } else {
return Arrays.toString(RandomUtil.randomInts(6)); 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 { ...@@ -108,5 +108,12 @@ public class MerchantUserController extends BaseController {
return merchantUserService.login(loginParam, response, language); 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) // * Copyright 2019-2029 geekidea(https://github.com/geekidea)
* // *
* Licensed under the Apache License, Version 2.0 (the "License"); // * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. // * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at // * You may obtain a copy of the License at
* // *
* http://www.apache.org/licenses/LICENSE-2.0 // * http://www.apache.org/licenses/LICENSE-2.0
* // *
* Unless required by applicable law or agreed to in writing, software // * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, // * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and // * See the License for the specific language governing permissions and
* limitations under the License. // * limitations under the License.
*/ // */
//
package com.jumeirah.api.system.controller; //package com.jumeirah.api.system.controller;
//
import io.geekidea.springbootplus.config.properties.SpringBootPlusProperties; //import io.geekidea.springbootplus.config.properties.SpringBootPlusProperties;
import io.geekidea.springbootplus.framework.common.api.ApiResult; //import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.log.annotation.Module; //import io.geekidea.springbootplus.framework.log.annotation.Module;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog; //import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType; //import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.geekidea.springbootplus.framework.util.DownloadUtil; //import io.geekidea.springbootplus.framework.util.DownloadUtil;
import io.swagger.annotations.Api; //import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; //import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; //import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; //import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; //import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; //import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; //import org.springframework.web.bind.annotation.RequestMapping;
//
import javax.servlet.http.HttpServletResponse; //import javax.servlet.http.HttpServletResponse;
import java.util.List; //import java.util.List;
//
/** ///**
* 下载控制器 // * 下载控制器
* // *
* @author geekidea // * @author geekidea
* @date 2019/8/20 // * @date 2019/8/20
* @since 1.2.1-RELEASE // * @since 1.2.1-RELEASE
*/ // */
@Slf4j //@Slf4j
@Controller //@Controller
@RequestMapping("/sys/download") //@RequestMapping("/sys/download")
@Module("system") //@Module("system")
@Api(value = "文件下载", tags = {"文件下载"}) //@Api(value = "文件下载", tags = {"文件下载"})
public class DownloadController { //public class DownloadController {
//
@Autowired // @Autowired
private SpringBootPlusProperties springBootPlusProperties; // private SpringBootPlusProperties springBootPlusProperties;
//
/** // /**
* 下载文件 // * 下载文件
*/ // */
@GetMapping("/{downloadFileName}") // @GetMapping("/{downloadFileName}")
@OperationLog(name = "下载文件", type = OperationLogType.download) // @OperationLog(name = "下载文件", type = OperationLogType.download)
@ApiOperation(value = "下载文件", notes = "下载文件", response = ApiResult.class) // @ApiOperation(value = "下载文件", notes = "下载文件", response = ApiResult.class)
public void download(@PathVariable(required = true) String downloadFileName, HttpServletResponse response) throws Exception { // public void download(@PathVariable(required = true) String downloadFileName, HttpServletResponse response) throws Exception {
// 下载目录,既是上传目录 // // 下载目录,既是上传目录
String downloadDir = springBootPlusProperties.getUploadPath(); // String downloadDir = springBootPlusProperties.getUploadPath();
// 允许下载的文件后缀 // // 允许下载的文件后缀
List<String> allowFileExtensions = springBootPlusProperties.getAllowDownloadFileExtensions(); // List<String> allowFileExtensions = springBootPlusProperties.getAllowDownloadFileExtensions();
// 文件下载,使用默认下载处理器 // // 文件下载,使用默认下载处理器
// 文件下载,使用自定义下载处理器 // // 文件下载,使用自定义下载处理器
DownloadUtil.download(downloadDir, downloadFileName, allowFileExtensions, response, (dir, fileName, file, fileExtension, contentType, length) -> { // DownloadUtil.download(downloadDir, downloadFileName, allowFileExtensions, response, (dir, fileName, file, fileExtension, contentType, length) -> {
// 下载自定义处理,返回true:执行下载,false:取消下载 // // 下载自定义处理,返回true:执行下载,false:取消下载
log.info("dir = " + dir); // log.info("dir = " + dir);
log.info("fileName = " + fileName); // log.info("fileName = " + fileName);
log.info("file = " + file); // log.info("file = " + file);
log.info("fileExtension = " + fileExtension); // log.info("fileExtension = " + fileExtension);
log.info("contentType = " + contentType); // log.info("contentType = " + contentType);
log.info("length = " + length); // log.info("length = " + length);
return true; // return true;
}); // });
} // }
//
} //}
/* ///*
* Copyright 2019-2029 geekidea(https://github.com/geekidea) // * Copyright 2019-2029 geekidea(https://github.com/geekidea)
* // *
* Licensed under the Apache License, Version 2.0 (the "License"); // * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. // * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at // * You may obtain a copy of the License at
* // *
* http://www.apache.org/licenses/LICENSE-2.0 // * http://www.apache.org/licenses/LICENSE-2.0
* // *
* Unless required by applicable law or agreed to in writing, software // * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, // * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and // * See the License for the specific language governing permissions and
* limitations under the License. // * limitations under the License.
*/ // */
//
package com.jumeirah.api.system.controller; //package com.jumeirah.api.system.controller;
//
import io.geekidea.springbootplus.config.properties.SpringBootPlusProperties; //import io.geekidea.springbootplus.config.properties.SpringBootPlusProperties;
import io.geekidea.springbootplus.framework.common.api.ApiResult; //import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.log.annotation.Module; //import io.geekidea.springbootplus.framework.log.annotation.Module;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog; //import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType; //import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.swagger.annotations.Api; //import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; //import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; //import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; //import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; //import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; //import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; //import org.springframework.web.bind.annotation.RequestMapping;
//
import javax.servlet.http.HttpServletResponse; //import javax.servlet.http.HttpServletResponse;
//
/** ///**
* 图片等文件资源访问控制器 // * 图片等文件资源访问控制器
* /api/resource 访问路径 用于区分 文件访问虚拟目录映射 /resource // * /api/resource 访问路径 用于区分 文件访问虚拟目录映射 /resource
* // *
* @author geekidea // * @author geekidea
* @date 2019/8/20 // * @date 2019/8/20
* @since 1.2.1-RELEASE // * @since 1.2.1-RELEASE
*/ // */
@Slf4j //@Slf4j
@Controller //@Controller
@RequestMapping("/api/resource") //@RequestMapping("/api/resource")
@Module("system") //@Module("system")
@Api(value = "资源访问", tags = {"资源访问"}) //@Api(value = "资源访问", tags = {"资源访问"})
public class ResourceController { //public class ResourceController {
//
@Autowired // @Autowired
private SpringBootPlusProperties springBootPlusProperties; // private SpringBootPlusProperties springBootPlusProperties;
//
/** // /**
* 访问资源 // * 访问资源
*/ // */
@GetMapping("/image/{imageFileName}") // @GetMapping("/image/{imageFileName}")
@OperationLog(name = "访问资源", type = OperationLogType.ADD) // @OperationLog(name = "访问资源", type = OperationLogType.ADD)
@ApiOperation(value = "访问资源", response = ApiResult.class) // @ApiOperation(value = "访问资源", response = ApiResult.class)
public void getImage(@PathVariable(required = true) String imageFileName, HttpServletResponse response) throws Exception { // public void getImage(@PathVariable(required = true) String imageFileName, HttpServletResponse response) throws Exception {
log.info("imageFileName:{}", imageFileName); // log.info("imageFileName:{}", imageFileName);
// 重定向到图片访问路径 // // 重定向到图片访问路径
response.sendRedirect(springBootPlusProperties.getResourceAccessPath() + 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; ...@@ -23,7 +23,6 @@ import com.jumeirah.common.param.sysuser.UpdatePasswordParam;
import com.jumeirah.common.param.sysuser.UploadHeadParam; import com.jumeirah.common.param.sysuser.UploadHeadParam;
import com.jumeirah.common.service.SysUserService; import com.jumeirah.common.service.SysUserService;
import com.jumeirah.common.vo.SysUserQueryVo; 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.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController; import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.core.pagination.Paging; import io.geekidea.springbootplus.framework.core.pagination.Paging;
...@@ -63,9 +62,6 @@ public class SysUserController extends BaseController { ...@@ -63,9 +62,6 @@ public class SysUserController extends BaseController {
@Autowired @Autowired
private SysUserService sysUserService; private SysUserService sysUserService;
@Autowired
private SpringBootPlusProperties springBootPlusProperties;
/** /**
* 添加系统用户 * 添加系统用户
*/ */
......
/* ///*
* Copyright 2019-2029 geekidea(https://github.com/geekidea) // * Copyright 2019-2029 geekidea(https://github.com/geekidea)
* // *
* Licensed under the Apache License, Version 2.0 (the "License"); // * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. // * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at // * You may obtain a copy of the License at
* // *
* http://www.apache.org/licenses/LICENSE-2.0 // * http://www.apache.org/licenses/LICENSE-2.0
* // *
* Unless required by applicable law or agreed to in writing, software // * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, // * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and // * See the License for the specific language governing permissions and
* limitations under the License. // * limitations under the License.
*/ // */
//
package com.jumeirah.api.system.controller; //package com.jumeirah.api.system.controller;
//
import io.geekidea.springbootplus.config.properties.SpringBootPlusProperties; //import io.geekidea.springbootplus.config.properties.SpringBootPlusProperties;
import io.geekidea.springbootplus.framework.common.api.ApiResult; //import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.log.annotation.Module; //import io.geekidea.springbootplus.framework.log.annotation.Module;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog; //import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType; //import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.geekidea.springbootplus.framework.util.UploadUtil; //import io.geekidea.springbootplus.framework.util.UploadUtil;
import io.swagger.annotations.Api; //import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; //import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; //import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; //import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; //import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FilenameUtils; //import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.RandomStringUtils; //import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; //import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; //import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; //import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; //import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; //import org.springframework.web.multipart.MultipartFile;
//
import java.time.LocalDateTime; //import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; //import java.time.format.DateTimeFormatter;
//
/** ///**
* 上传控制器 // * 上传控制器
* // *
* @author geekidea // * @author geekidea
* @date 2019/8/20 // * @date 2019/8/20
* @since 1.2.1-RELEASE // * @since 1.2.1-RELEASE
*/ // */
@Slf4j //@Slf4j
@RestController //@RestController
@RequestMapping("/sys/upload") //@RequestMapping("/sys/upload")
@Module("system") //@Module("system")
@Api(value = "文件上传", tags = {"文件上传"}) //@Api(value = "文件上传", tags = {"文件上传"})
public class UploadController { //public class UploadController {
//
@Autowired // @Autowired
private SpringBootPlusProperties springBootPlusProperties; // private SpringBootPlusProperties springBootPlusProperties;
//
/** // /**
* 上传单个文件 // * 上传单个文件
* // *
* @return // * @return
*/ // */
@PostMapping // @PostMapping
@OperationLog(name = "上传单个文件", type = OperationLogType.UPLOAD) // @OperationLog(name = "上传单个文件", type = OperationLogType.UPLOAD)
@ApiOperation(value = "上传单个文件", response = ApiResult.class) // @ApiOperation(value = "上传单个文件", response = ApiResult.class)
@ApiImplicitParams({ // @ApiImplicitParams({
@ApiImplicitParam(name = "file", value = "文件", required = true, dataType = "__file"), // @ApiImplicitParam(name = "file", value = "文件", required = true, dataType = "__file"),
@ApiImplicitParam(name = "type", value = "类型 head:头像", required = true) // @ApiImplicitParam(name = "type", value = "类型 head:头像", required = true)
}) // })
public ApiResult<String> upload(@RequestParam("file") MultipartFile multipartFile, // public ApiResult<String> upload(@RequestParam("file") MultipartFile multipartFile,
@RequestParam("type") String type) throws Exception { // @RequestParam("type") String type) throws Exception {
log.info("multipartFile = " + multipartFile); // log.info("multipartFile = " + multipartFile);
log.info("ContentType = " + multipartFile.getContentType()); // log.info("ContentType = " + multipartFile.getContentType());
log.info("OriginalFilename = " + multipartFile.getOriginalFilename()); // log.info("OriginalFilename = " + multipartFile.getOriginalFilename());
log.info("Name = " + multipartFile.getName()); // log.info("Name = " + multipartFile.getName());
log.info("Size = " + multipartFile.getSize()); // log.info("Size = " + multipartFile.getSize());
log.info("type = " + type); // log.info("type = " + type);
//
// 上传文件,返回保存的文件名称 // // 上传文件,返回保存的文件名称
String saveFileName = UploadUtil.upload(springBootPlusProperties.getUploadPath(), multipartFile, originalFilename -> { // String saveFileName = UploadUtil.upload(springBootPlusProperties.getUploadPath(), multipartFile, originalFilename -> {
// 文件后缀 // // 文件后缀
String fileExtension = FilenameUtils.getExtension(originalFilename); // String fileExtension = FilenameUtils.getExtension(originalFilename);
// 这里可自定义文件名称,比如按照业务类型/文件格式/日期 // // 这里可自定义文件名称,比如按照业务类型/文件格式/日期
String dateString = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssS")) + RandomStringUtils.randomNumeric(6); // String dateString = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssS")) + RandomStringUtils.randomNumeric(6);
String fileName = dateString + "." + fileExtension; // String fileName = dateString + "." + fileExtension;
return fileName; // return fileName;
}); // });
//
// 上传成功之后,返回访问路径,请根据实际情况设置 // // 上传成功之后,返回访问路径,请根据实际情况设置
//
String fileAccessPath = springBootPlusProperties.getResourceAccessUrl() + saveFileName; // String fileAccessPath = springBootPlusProperties.getResourceAccessUrl() + saveFileName;
log.info("fileAccessPath:{}", fileAccessPath); // log.info("fileAccessPath:{}", fileAccessPath);
//
return ApiResult.ok(fileAccessPath); // return ApiResult.ok(fileAccessPath);
} // }
//
} //}
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 { ...@@ -63,4 +63,9 @@ public class BusinessPlain extends BaseEntity {
@ApiModelProperty("更新时间(时间戳)") @ApiModelProperty("更新时间(时间戳)")
private Date updateTime; private Date updateTime;
@ApiModelProperty("图片高")
private Integer imageListHeight;
@ApiModelProperty("图片宽")
private Integer imageListWidth;
} }
...@@ -2,6 +2,7 @@ package com.jumeirah.common.param; ...@@ -2,6 +2,7 @@ package com.jumeirah.common.param;
import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam; import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
...@@ -20,4 +21,6 @@ import lombok.experimental.Accessors; ...@@ -20,4 +21,6 @@ import lombok.experimental.Accessors;
@ApiModel(value = "公务机出售/托管表分页参数") @ApiModel(value = "公务机出售/托管表分页参数")
public class BusinessPlainPageParam extends BasePageOrderParam { public class BusinessPlainPageParam extends BasePageOrderParam {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty("类型,0-出售,1-托管")
private Integer type;
} }
...@@ -63,7 +63,7 @@ public class BusinessPlainServiceImpl extends BaseServiceImpl<BusinessPlainMappe ...@@ -63,7 +63,7 @@ public class BusinessPlainServiceImpl extends BaseServiceImpl<BusinessPlainMappe
@Override @Override
public Paging<BusinessPlainQueryForAppVo> getBusinessPlainPageListForApp(BusinessPlainPageParam businessPlainPageParam) throws Exception { 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); IPage<BusinessPlainQueryForAppVo> iPage = businessPlainMapper.getBusinessPlainPageListForApp(page, businessPlainPageParam);
return new Paging<>(iPage); return new Paging<>(iPage);
} }
......
...@@ -22,10 +22,7 @@ public class BusinessPlainQueryForAppVo implements Serializable { ...@@ -22,10 +22,7 @@ public class BusinessPlainQueryForAppVo implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty("商家name") @ApiModelProperty("商家name")
private Long mcName; private String mcName;
@ApiModelProperty("业务类型,0-出售,1-托管")
private Integer businessType;
@ApiModelProperty("图片url") @ApiModelProperty("图片url")
private String imgUrl; private String imgUrl;
...@@ -42,4 +39,10 @@ public class BusinessPlainQueryForAppVo implements Serializable { ...@@ -42,4 +39,10 @@ public class BusinessPlainQueryForAppVo implements Serializable {
@ApiModelProperty("微信号") @ApiModelProperty("微信号")
private String wechat; 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 @@ ...@@ -4,7 +4,7 @@
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
<sql id="Base_Column_List"> <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>
<sql id="Base_Column_ListForApp"> <sql id="Base_Column_ListForApp">
...@@ -27,9 +27,10 @@ ...@@ -27,9 +27,10 @@
<select id="getBusinessPlainPageListForApp" parameterType="com.jumeirah.common.param.BusinessPlainPageParam" <select id="getBusinessPlainPageListForApp" parameterType="com.jumeirah.common.param.BusinessPlainPageParam"
resultType="com.jumeirah.common.vo.BusinessPlainQueryForAppVo"> resultType="com.jumeirah.common.vo.BusinessPlainQueryForAppVo">
select 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 from business_plain bp
INNER JOIN merchant m ON bp.mc_id=m.id INNER JOIN merchant m ON bp.mc_id=m.id
where bp.business_type=#{param.type}
</select> </select>
</mapper> </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