Commit f0496c04 authored by liqin's avatar liqin 💬

Merge branch 'master' of http://111.203.232.171:8888/licc/shop-mall into master

parents a5b1cf41 3b192d8c
...@@ -23,6 +23,8 @@ public enum ResultEnum { ...@@ -23,6 +23,8 @@ public enum ResultEnum {
CODETYPE_ERROR("1009","手机号码格式不正确"), CODETYPE_ERROR("1009","手机号码格式不正确"),
CODESEND_ERROR("1010","请相隔60S后再发送"), CODESEND_ERROR("1010","请相隔60S后再发送"),
FILE_NOT_LOGIN("2001", "未登录"), FILE_NOT_LOGIN("2001", "未登录"),
FILE_NOT_HAVE_PERMISSION("2002", "没有权限"), FILE_NOT_HAVE_PERMISSION("2002", "没有权限"),
FAIL_ACCOUNT_LOCK("2003", "账号已被锁定"), FAIL_ACCOUNT_LOCK("2003", "账号已被锁定"),
......
...@@ -5,19 +5,22 @@ import cn.wisenergy.common.enums.ResultEnum; ...@@ -5,19 +5,22 @@ import cn.wisenergy.common.enums.ResultEnum;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.Serializable; import java.io.Serializable;
import java.util.Map;
/** /**
* 返回信息包装类 * 返回信息包装类
* Created by m1991 on 2021/2/28 23:08 * Created by m1991 on 2021/2/28 23:08
*/ */
@Component @Component
public class Result<T> implements Serializable{ public class Result<T> implements Serializable {
public String code; public String code;
public String msg; public String msg;
private T data; private T data;
private T wyz;
/** /**
* 无参构造 * 无参构造
*/ */
...@@ -52,6 +55,21 @@ public class Result<T> implements Serializable{ ...@@ -52,6 +55,21 @@ public class Result<T> implements Serializable{
this.data = data; this.data = data;
} }
public T getWyz() {
return wyz;
}
public void setWyz(T wyz) {
this.wyz = wyz;
}
public Result(String code, String msg, T data, T wyz) {
this.code = code;
this.msg = msg;
this.data = data;
this.wyz = wyz;
}
/** /**
* 根据枚举创建一个Result * 根据枚举创建一个Result
* @param resultEnum * @param resultEnum
......
...@@ -41,6 +41,19 @@ public class ResultUtils { ...@@ -41,6 +41,19 @@ public class ResultUtils {
return Result; return Result;
} }
/**
* 用于返回唯一值
* @param data
* @param wyz
* @return
*/
public static Result returnDataSuccess(Object data,String wyz) {
Result Result = new Result(ResultEnum.SUCCESS);
Result.setData(data);
Result.setWyz(wyz);
return Result;
}
/** /**
* 返回一个失败的Result * 返回一个失败的Result
* @return * @return
......
package cn.wisenergy.mapper; package cn.wisenergy.mapper;
import cn.wisenergy.model.app.AccountInfo;
import cn.wisenergy.model.app.LastMonthAccount; import cn.wisenergy.model.app.LastMonthAccount;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -15,4 +14,27 @@ public interface LastAccountMapper extends BaseMapper<LastMonthAccount> { ...@@ -15,4 +14,27 @@ public interface LastAccountMapper extends BaseMapper<LastMonthAccount> {
* @return 账户信息 * @return 账户信息
*/ */
LastMonthAccount getByUserIdAndTime(@Param("userId") String userId, @Param("yearMonth") String yearMonth); LastMonthAccount getByUserIdAndTime(@Param("userId") String userId, @Param("yearMonth") String yearMonth);
/**
* 把 A 表的结构数据 复制给 B表
*
* @param oldTable A
* @param newTable B
*/
void copyTable(@Param("oldTable") String oldTable, @Param("newTable") String newTable);
/**
* 删除表
*
* @param tableName 表名
*/
void deleteTable(@Param("tableName") String tableName);
/**
* 更新表名
*
* @param oldTableName 旧表名
* @param newTableName 新表名
*/
void updateTableName(@Param("oldTableName") String oldTableName, @Param("newTableName") String newTableName);
} }
...@@ -22,19 +22,43 @@ public interface ShopZxMapper extends BaseMapper<shopZx> { ...@@ -22,19 +22,43 @@ public interface ShopZxMapper extends BaseMapper<shopZx> {
*/ */
int zxadd(@Param("zxUrl") String zxUrl,@Param("userId") String userId,@Param("zxName") String zxName,@Param("zxField") String zxField,@Param("imgUrl") String imgUrl,@Param("zxAddress") String zxAddress); int zxadd(@Param("zxUrl") String zxUrl,@Param("userId") String userId,@Param("zxName") String zxName,@Param("zxField") String zxField,@Param("imgUrl") String imgUrl,@Param("zxAddress") String zxAddress);
/**
* 查询全部资讯
* @return
*/
List<shopZx> findAll();
/**分页 资讯内容倒叙查询 /**分页 资讯内容倒叙查询
* PageSize int, --每页的记录数量,比如10条#{beginPos},#{pageSize} * PageSize int, --每页的记录数量,比如10条#{beginPos},#{pageSize}
* @param * @param
* @return * @return
*/ */
// List selectAll( @Param("beginPos") int beginPos,@Param("PageSize") int PageSize); List<shopZx> selectPage();
/**
* 根据手机号删除资讯
* @param userId
* @return
*/
int deleteByPrimaryKey(Long userId);
/** /**
* 分页查询资讯 * 根据手机号查询资讯
* @param userId
* @return * @return
*/ */
// List<shopZx> selectPage(); int insert(shopZx userId);
int insertSelective(shopZx userId);
shopZx selectByPrimaryKey(Long userId);
int updateByPrimaryKeySelective(shopZx userId);
int updateByPrimaryKey(shopZx userId);
} }
...@@ -56,6 +56,10 @@ ...@@ -56,6 +56,10 @@
<if test="updateTime != null">and #{updateTime} &gt;= update_time</if> <if test="updateTime != null">and #{updateTime} &gt;= update_time</if>
</sql> </sql>
<delete id="deleteTable">
drop table ${tableName}
</delete>
<select id="getByUserIdAndTime" resultType="cn.wisenergy.model.app.LastMonthAccount"> <select id="getByUserIdAndTime" resultType="cn.wisenergy.model.app.LastMonthAccount">
select select
...@@ -68,4 +72,14 @@ ...@@ -68,4 +72,14 @@
</where> </where>
</select> </select>
<update id="copyTable">
CREATE TABLE ${newTable} SELECT * FROM ${oldTable};
</update>
<update id="updateTableName">
rename table ${oldTableName} to ${newTableName};
</update>
</mapper> </mapper>
\ No newline at end of file
...@@ -48,11 +48,11 @@ ...@@ -48,11 +48,11 @@
<!--</insert>--> <!--</insert>-->
<!--资讯内容倒叙查询--> <!--资讯内容倒叙查询-->
<select id="selectAll" parameterType="java.lang.Integer" resultType="cn.wisenergy.model.app.shopZx"> <select id="findAll" parameterType="java.lang.Integer" resultType="cn.wisenergy.model.app.shopZx">
select zxid as zxid,zxUrl as zxUrl, select zxid as zxid,zxUrl as zxUrl,
zxLikes as zxLikes,userid as userid,zxName as zxName, zxLikes as zxLikes,userid as userid,zxName as zxName,
zxShenHe as zxShenHe,zxField as zxField,zxDate as zxDate, zxShenHe as zxShenHe,zxField as zxField,zxDate as zxDate,
imgUrl as imgUrl,zxAddress as zxAddress from shop_zx order by zxid desc limit #{beginPos},#{pageSize} imgUrl as imgUrl,zxAddress as zxAddress from shop_zx order by zxid desc limit #{pageNum},#{pageSize}
</select> </select>
<!--资讯总记录数查询--> <!--资讯总记录数查询-->
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
select zxid as zxid,zxUrl as zxUrl, select zxid as zxid,zxUrl as zxUrl,
zxLikes as zxLikes,userid as userid,zxName as zxName, zxLikes as zxLikes,userid as userid,zxName as zxName,
zxShenHe as zxShenHe,zxField as zxField,zxDate as zxDate, zxShenHe as zxShenHe,zxField as zxField,zxDate as zxDate,
imgUrl as imgUrl,zxAddress as zxAddress from shop_zx order by zxid desc limit #{beginPos},#{pageSize} imgUrl as imgUrl,zxAddress as zxAddress from shop_zx order by zxid desc limit #{pageNum},#{pageSize}
</select> </select>
......
...@@ -52,4 +52,9 @@ public interface AccountService { ...@@ -52,4 +52,9 @@ public interface AccountService {
* @return true or false * @return true or false
*/ */
R<Boolean> progressPrizeCount(); R<Boolean> progressPrizeCount();
/**
* 账户表镜像---每月更新一次,保存上一个的数据
*/
void mirrorImage();
} }
...@@ -3,6 +3,7 @@ package cn.wisenergy.service.app; ...@@ -3,6 +3,7 @@ package cn.wisenergy.service.app;
import cn.wisenergy.common.utils.PageRequest; import cn.wisenergy.common.utils.PageRequest;
import cn.wisenergy.common.utils.PageResult; import cn.wisenergy.common.utils.PageResult;
import cn.wisenergy.mapper.ShopZxMapper;
import cn.wisenergy.model.app.shopZx; import cn.wisenergy.model.app.shopZx;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -47,24 +48,31 @@ public interface UploadService { ...@@ -47,24 +48,31 @@ public interface UploadService {
String storeFile(MultipartFile file); String storeFile(MultipartFile file);
Resource loadFileAsResource(String fileName); Resource loadFileAsResource(String fileName);
/** /**
* 查询资讯所有信息(分页——10条信息一页) * 根据用户ID查找用户资讯
* @param * @param userId
* @return * @return
*/ */
Map getList(int beginPos, int pageSize); shopZx findByUserId(Long userId);
// public Page<shopZx> find();
/** /**
* 分页查询接口 * 查询所有资讯
* @return
*/
List<shopZx> findAll();
/**
* 分页查询接口 资讯分页
* 这里统一封装了分页请求和结果,避免直接引入具体框架的分页对象, 如MyBatis或JPA的分页对象 * 这里统一封装了分页请求和结果,避免直接引入具体框架的分页对象, 如MyBatis或JPA的分页对象
* 从而避免因为替换ORM框架而导致服务层、控制层的分页接口也需要变动的情况,替换ORM框架也不会 * 从而避免因为替换ORM框架而导致服务层、控制层的分页接口也需要变动的情况,替换ORM框架也不会
* 影响服务层以上的分页接口,起到了解耦的作用 * 影响服务层以上的分页接口,起到了解耦的作用
* @param pageRequest 自定义,统一分页查询请求 * @param pageRequest 自定义,统一分页查询请求
* @return PageResult 自定义,统一分页查询结果 * @return PageResult 自定义,统一分页查询结果
*/ */
// PageResult findPage(PageRequest pageRequest); PageResult findPage(PageRequest pageRequest);
} }
...@@ -7,28 +7,26 @@ import cn.wisenergy.model.vo.AerialDeliveryVo; ...@@ -7,28 +7,26 @@ import cn.wisenergy.model.vo.AerialDeliveryVo;
import java.util.Map; import java.util.Map;
/** /**
* @author 86187
* @author 86187 * @author 86187
* @ Description: 用户接口 * @ Description: 用户接口
* @ Author : 86187 * @ Author : 86187
* @ Date : 2021/1/6 16:08 * @ Date : 2021/1/6 16:08
* @author 86187
*/ */
public interface UserService { public interface UserService {
/** /**
* 获取用户信息 * 获取用户信息
*
* @param userId 用户id * @param userId 用户id
* @return 用户信息 * @return 用户信息
*/ */
User getById(String userId); User getById(String userId);
R<Integer> getById1(String userId); R<Integer> getById1(String userId);
/** /**
* 获取用户信息 * 获取用户信息
*
* @param userId 用户id * @param userId 用户id
* @return 用户信息 * @return 用户信息
*/ */
...@@ -59,21 +57,5 @@ public interface UserService { ...@@ -59,21 +57,5 @@ public interface UserService {
*/ */
R<AerialDeliveryVo> queryAerialDelivery(); R<AerialDeliveryVo> queryAerialDelivery();
/**
* 设置用户头像
*
* @param userId 用户id
* @param headImage 头像地址url
* @return true or false
*/
R<Boolean> setHeadImage(String userId, String headImage); R<Boolean> setHeadImage(String userId, String headImage);
/**
* 填写设置页面-邀请码
*
* @param userId 用户id
* @param inviteCode 邀请码
* @return true or false
*/
R<Boolean> fillInInviteCode(String userId, String inviteCode);
} }
...@@ -55,6 +55,9 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo> ...@@ -55,6 +55,9 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
@Autowired @Autowired
private ProgressPrizeMapper progressPrizeMapper; private ProgressPrizeMapper progressPrizeMapper;
@Autowired
private LastAccountMapper lastAccountMapper;
private static final String PATTERN = "yyyy-MM"; private static final String PATTERN = "yyyy-MM";
private static final Integer TWENTY = 20; private static final Integer TWENTY = 20;
...@@ -282,6 +285,30 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo> ...@@ -282,6 +285,30 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
return R.ok(0, true); return R.ok(0, true);
} }
@Override
public void mirrorImage() {
//1、把账户表account_info复制给表account_image CREATE TABLE table_2 SELECT * FROM table_1;
lastAccountMapper.copyTable("account_info", "account_image");
//删除上月备份
lastAccountMapper.deleteTable("account_backup");
//备份
lastAccountMapper.copyTable("account_info", "account_backup");
//2、把上月账户表last_month_account 复制给month_account_image
lastAccountMapper.copyTable("last_month_account", "month_account_image");
//3、删除last_month_account
lastAccountMapper.deleteTable("last_month_account");
//4、把account_image 更名为 last_month_account rename table table_2 to table_1;
lastAccountMapper.updateTableName("account_image", "last_month_account");
//5、删除month_account_image DROP table table_2;
lastAccountMapper.deleteTable("month_account_image");
}
public void getUser(List<User> list, String userId) { public void getUser(List<User> list, String userId) {
User user = usersMapper.getByUserId(userId); User user = usersMapper.getByUserId(userId);
list.add(user); list.add(user);
......
...@@ -256,13 +256,6 @@ public class UploadServiceImpl implements UploadService { ...@@ -256,13 +256,6 @@ public class UploadServiceImpl implements UploadService {
} }
/**
* 获取资讯分页数据
* @return
*/
// @Override
/** /**
* 多文件上传 TODO * 多文件上传 TODO
*/ */
...@@ -321,8 +314,31 @@ public class UploadServiceImpl implements UploadService { ...@@ -321,8 +314,31 @@ public class UploadServiceImpl implements UploadService {
} }
@Override @Override
public Map getList(int beginPos, int pageSize) { public shopZx findByUserId(Long userId) {
return null; return shopZxMapper.selectByPrimaryKey(userId);
}
@Override
public List<shopZx> findAll() {
return shopZxMapper.findAll();
}
/**
* 调用分页插件完成分页
* @param pageRequest
* @return
*/
private PageInfo<shopZx> getPageInfo(PageRequest pageRequest) {
int pageNum = pageRequest.getPageNum();
int pageSize = pageRequest.getPageSize();
PageHelper.startPage(pageNum, pageSize);
List<shopZx> sysMenus = shopZxMapper.selectPage();
return new PageInfo<shopZx>(sysMenus);
}
@Override
public PageResult findPage(PageRequest pageRequest) {
return PageUtils.getPageResult(pageRequest, getPageInfo(pageRequest));
} }
// @Override // @Override
......
package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.service.app.AccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author 86187
*/
@Api(tags = "表镜像管理")
@RestController
@RequestMapping("/image")
@Slf4j
public class LastAccountController {
@Autowired
private AccountService accountService;
@ApiOperation(value = "复制表-结构和数据", notes = "复制表-结构和数据", httpMethod = "PUT")
@PutMapping("/add")
public void copyTable(){
accountService.mirrorImage();
}
}
...@@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
...@@ -27,7 +28,7 @@ import java.util.Map; ...@@ -27,7 +28,7 @@ import java.util.Map;
*/ */
@Api(tags = "登录/注册") @Api(tags = "登录/注册")
@Slf4j @Slf4j
@RequestMapping("/api/user") @RequestMapping("api/user")
@RestController @RestController
public class LoginController { public class LoginController {
@Autowired @Autowired
...@@ -52,30 +53,41 @@ public class LoginController { ...@@ -52,30 +53,41 @@ public class LoginController {
@ApiImplicitParam(name = "sms", value = "验证码", dataType = "String"), @ApiImplicitParam(name = "sms", value = "验证码", dataType = "String"),
@ApiImplicitParam(name = "userId", value = "用户手机号", required = true, dataType = "String")}) @ApiImplicitParam(name = "userId", value = "用户手机号", required = true, dataType = "String")})
@RequestMapping("/login") @RequestMapping("/login")
public Result loginBySms(String userId, String sms)throws Exception{ public Map loginBySms(@RequestParam String userId, @RequestParam String sms)throws Exception{
User users=null; User users=null;
Map map=new HashMap();
String key= StringUtil.formatKeyWithPrefix(Constants.RedisKey.PROJECT_PRIFIX,Constants.RedisKey.SMS_PRIFIX,userId,Constants.Sms.CodeType.LOGIN_OR_REGISTER+""); String key= StringUtil.formatKeyWithPrefix(Constants.RedisKey.PROJECT_PRIFIX,Constants.RedisKey.SMS_PRIFIX,userId,Constants.Sms.CodeType.LOGIN_OR_REGISTER+"");
String redisCode=redisUtils.getValue(key); String redisCode=redisUtils.getValue(key);
if(StringUtil.isBlank(redisCode) || !sms.equals(redisCode)){ if(StringUtil.isBlank(redisCode) || !sms.equals(redisCode)){
throw new BaseException(ResultEnum.FAIL_VERIFY);
map.put("code","1003");
map.put("msg","验证码错误");
// throw new BaseException(ResultEnum.FAIL_VERIFY);
return map;
} }
redisUtils.delete(key); redisUtils.delete(key);
//根据手机号判断用户是否存在 //根据手机号判断用户是否存在
//不存在则保存用户信息--修改为提示用户注册 //不存在则保存用户信息--修改为提示用户注册
users=usersService.queryUsersByPhone(userId); users=usersService.queryUsersByPhone(userId);
if(null==users){ if(null==users){
throw new BaseException(ResultEnum.FAIL_ACCOUNT_NOT_EXIST); //throw new BaseException(ResultEnum.FAIL_ACCOUNT_NOT_EXIST);
// users=new User(); map.put("code","1005");
// users.setUserId(userId); map.put("msg","账号不存在,请注册");
// usersService.qdtxAddUsers(users);; return map;
} }
String token=createToken(users); String token= null;
token = createToken(users);
if(!StringUtil.isBlank(token)){ if(!StringUtil.isBlank(token)){
return ResultUtils.returnDataSuccess(StringUtil.createSimpleMap("token",token)); String wyz=users.getInviteCode();
Map<String, Object> map1=StringUtil.createSimpleMap("token",token);
map1.put("wyz",wyz);
map1.put("code",0);
map1.put("msg","成功!");
return map1;
} }
return ResultUtils.returnFail(); return (Map) ResultUtils.returnFail();
} }
public String createToken(User users)throws Exception{ public String createToken(User users)throws Exception{
...@@ -87,21 +99,30 @@ public class LoginController { ...@@ -87,21 +99,30 @@ public class LoginController {
redisUtils.set(tokenKey, JSONObject.toJSONString(usersDto),Constants.Duration.HALF_HOUR_INT); redisUtils.set(tokenKey, JSONObject.toJSONString(usersDto),Constants.Duration.HALF_HOUR_INT);
return token; return token;
} }
@ApiOperation(value = "获取用户登录token信息", notes = "获取用户登录token信息", httpMethod = "POST", produces = "application/json; charset=UTF-8") @ApiOperation(value = "获取用户登录token信息", notes = "获取用户登录token信息", httpMethod = "POST", produces = "application/json; charset=UTF-8")
@RequestMapping("/info") @RequestMapping("/info")
public Result info(HttpServletRequest request)throws Exception{ public Map info(HttpServletRequest request)throws Exception{
String token=request.getHeader("token"); String token=request.getHeader("token");
String tokenKey=StringUtil.formatKeyWithPrefix(Constants.RedisKey.PROJECT_PRIFIX,Constants.RedisKey.TOKEN_PRIFIX,token); String tokenKey=StringUtil.formatKeyWithPrefix(Constants.RedisKey.PROJECT_PRIFIX,Constants.RedisKey.TOKEN_PRIFIX,token);
String userDtoJson=redisUtils.getValue(tokenKey); String userDtoJson=redisUtils.getValue(tokenKey);
if(StringUtil.isBlank(userDtoJson)){ if(StringUtil.isBlank(userDtoJson)){
throw new BaseException(ResultEnum.FILE_NOT_LOGIN); Map map=new HashMap();
map.put("code","2001");
map.put("msg","未登录");
return map;
///throw new BaseException(ResultEnum.FILE_NOT_LOGIN);
} }
UsersDto usersDto=JSONObject.parseObject(userDtoJson,UsersDto.class); UsersDto usersDto=JSONObject.parseObject(userDtoJson,UsersDto.class);
usersDto.setPassword(null); usersDto.setPassword(null);
return ResultUtils.returnDataSuccess(userDtoJson);
return (Map) ResultUtils.returnDataSuccess(userDtoJson);
} }
//用户注册 //用户注册
@ApiOperation(value = "用户注册", notes = "用户注册", httpMethod = "POST", produces = "application/json; charset=UTF-8") @ApiOperation(value = "用户注册", notes = "用户注册", httpMethod = "POST", produces = "application/json; charset=UTF-8")
@ApiImplicitParams({ @ApiImplicitParams({
...@@ -110,23 +131,38 @@ public class LoginController { ...@@ -110,23 +131,38 @@ public class LoginController {
@ApiImplicitParam(name = "sms", value = "验证码",required = true, dataType = "String") @ApiImplicitParam(name = "sms", value = "验证码",required = true, dataType = "String")
}) })
@RequestMapping("/register") @RequestMapping("/register")
public Map register(@RequestParam String userId, String beInvitedCode, @RequestParam String sms)throws Exception { public Map register(@RequestParam String userId,@RequestParam String beInvitedCode, @RequestParam String sms) {
User users=null; User users=null;
String key= StringUtil.formatKeyWithPrefix(Constants.RedisKey.PROJECT_PRIFIX,Constants.RedisKey.SMS_PRIFIX,userId,Constants.Sms.CodeType.LOGIN_OR_REGISTER+""); String key= StringUtil.formatKeyWithPrefix(Constants.RedisKey.PROJECT_PRIFIX,Constants.RedisKey.SMS_PRIFIX,userId,Constants.Sms.CodeType.LOGIN_OR_REGISTER+"");
String redisCode=redisUtils.getValue(key); String redisCode=redisUtils.getValue(key);
if(StringUtil.isBlank(redisCode) || !sms.equals(redisCode)){ if(StringUtil.isBlank(redisCode) || !sms.equals(redisCode)){
throw new BaseException(ResultEnum.FAIL_VERIFY); try {
throw new BaseException(ResultEnum.FAIL_VERIFY);
} catch (BaseException e) {
Map map=new HashMap();
map.put("code","1003");
map.put("msg","验证码错误");
// throw new BaseException(ResultEnum.FAIL_VERIFY);
return map;
}
} }
redisUtils.delete(key); redisUtils.delete(key);
//判断phone是否符合输入类型 //判断phone是否符合输入类型
if(!userId.matches(Constants.RegConstant.PHONE_REGSTR)){ if(!userId.matches(Constants.RegConstant.PHONE_REGSTR)){
throw new BaseException(ResultEnum.PHONE_ERROR); try {
throw new BaseException(ResultEnum.PHONE_ERROR);
} catch (BaseException e) {
e.printStackTrace();
Map map=new HashMap();
map.put("code","1008");
map.put("msg","手机号码格式不正确");
// throw new BaseException(ResultEnum.FAIL_VERIFY);
return map;
}
} }
// if(userId.equals())){
// throw new BaseException(ResultEnum.PHONE_ERROR);
// }
return usersService.userByZx(userId,beInvitedCode); return usersService.userByZx(userId,beInvitedCode);
} }
......
...@@ -10,8 +10,13 @@ import io.swagger.annotations.ApiOperation; ...@@ -10,8 +10,13 @@ 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.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
@Api(tags = "发送手机验证码 codeType 0注册/登录验证 1修改密码 2订单通知信息") @Api(tags = "发送手机验证码 codeType 0注册/登录验证 1修改密码 2订单通知信息")
@Slf4j @Slf4j
@RequestMapping("/api/sms") @RequestMapping("/api/sms")
...@@ -36,13 +41,31 @@ public class SmsController { ...@@ -36,13 +41,31 @@ public class SmsController {
@ApiImplicitParam(name = "phone", value = "用户手机号", required = true, dataType = "String"), @ApiImplicitParam(name = "phone", value = "用户手机号", required = true, dataType = "String"),
@ApiImplicitParam(name = "codeType", value = "验证码类型用途 0注册/登录验证 1修改密码 2订单通知信息", dataType = "Integer")}) @ApiImplicitParam(name = "codeType", value = "验证码类型用途 0注册/登录验证 1修改密码 2订单通知信息", dataType = "Integer")})
@RequestMapping("/verifyCode") @RequestMapping("/verifyCode")
public Result verifyCode(String phone, Integer codeType) throws Exception { @ResponseBody
public Result verifyCode(@RequestParam String phone, @RequestParam Integer codeType) {
Map map=new HashMap();
//判断phone和codeType是否符合输入类型 //判断phone和codeType是否符合输入类型
if(!phone.matches(Constants.RegConstant.PHONE_REGSTR)){ if(!phone.matches(Constants.RegConstant.PHONE_REGSTR)){
throw new BaseException(ResultEnum.PHONE_ERROR); try {
throw new BaseException(ResultEnum.PHONE_ERROR);
} catch (BaseException e) {
e.printStackTrace();
map.put("code","1005");
map.put("msg","账号不存在,请注册");
return (Result) map;
}
} }
if(codeType!=Constants.Sms.CodeType.LOGIN_OR_REGISTER && codeType!=Constants.Sms.CodeType.PASS_UPDATE && codeType!=Constants.Sms.CodeType.ORDER_NOTICE){ if(codeType!=Constants.Sms.CodeType.LOGIN_OR_REGISTER && codeType!=Constants.Sms.CodeType.PASS_UPDATE && codeType!=Constants.Sms.CodeType.ORDER_NOTICE){
throw new BaseException(ResultEnum.CODETYPE_ERROR); try {
throw new BaseException(ResultEnum.CODETYPE_ERROR);
} catch (BaseException e) {
e.printStackTrace();
map.put("code","1009");
map.put("msg","手机号码格式不正确");
return (Result) map;
}
} }
String key= StringUtil.formatKeyWithPrefix(Constants.RedisKey.PROJECT_PRIFIX,Constants.RedisKey.SMS_PRIFIX,phone,codeType+""); String key= StringUtil.formatKeyWithPrefix(Constants.RedisKey.PROJECT_PRIFIX,Constants.RedisKey.SMS_PRIFIX,phone,codeType+"");
...@@ -52,6 +75,6 @@ public class SmsController { ...@@ -52,6 +75,6 @@ public class SmsController {
redisUtils.set(key,code,Constants.Duration.HALF_HOUR_INT); redisUtils.set(key,code,Constants.Duration.HALF_HOUR_INT);
boolean flag=smsUtils.sendMessage(phone,Constants.Sms.TemplateCode.LOGIN_SF_REGISTER,code); boolean flag=smsUtils.sendMessage(phone,Constants.Sms.TemplateCode.LOGIN_SF_REGISTER,code);
return flag? ResultUtils.returnSuccess():ResultUtils.returnFail(); return (flag? ResultUtils.returnSuccess():ResultUtils.returnFail());
} }
} }
\ No newline at end of file
package cn.wisenergy.web.admin.controller.app; package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.utils.PageRequest;
import cn.wisenergy.common.utils.Result; import cn.wisenergy.common.utils.Result;
import cn.wisenergy.service.app.UploadService; import cn.wisenergy.service.app.UploadService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -104,22 +105,37 @@ public class UploadController { ...@@ -104,22 +105,37 @@ public class UploadController {
} }
/** @GetMapping(value="/findByUserId")
* 资讯分页展示接口 public Object findByUserId(@RequestParam Long userId) {
* @param pageOffset return uploadService.findByUserId(userId);
* @param pageSize }
* @return
*/ @GetMapping(value="/findAll")
@ApiOperation(value = "资讯信息接口", notes = "资讯信息接口", httpMethod = "GET", produces = "application/json; charset=UTF-8") public Object findAll() {
@ApiImplicitParams({ return uploadService.findAll();
@ApiImplicitParam(name = "beginPos", value = "从几开始", required = true, dataType = "int"), }
@ApiImplicitParam(name = "pageSize", value = "展示数量(条数)", required = true, dataType = "int")})
@RequestMapping(value = "/shop", method = {RequestMethod.POST, RequestMethod.GET})
public Result find(Integer beginPos, Integer pageSize) {
Map shopZxPage = uploadService.getList(beginPos, pageSize);
return new Result("0", "success", shopZxPage); @ApiOperation(value = "资讯信息接口", notes = "资讯信息接口", httpMethod = "POST", produces = "application/json; charset=UTF-8")
@PostMapping(value="/findPage")
public Object findPage(@RequestBody PageRequest pageQuery) {
return uploadService.findPage(pageQuery);
} }
// /**
// * 资讯分页展示接口
// * @param pageOffset
// * @param pageSize
// * @return
// */
// @ApiOperation(value = "资讯信息接口", notes = "资讯信息接口", httpMethod = "GET", produces = "application/json; charset=UTF-8")
// @ApiImplicitParams({
// @ApiImplicitParam(name = "beginPos", value = "从几开始", required = true, dataType = "int"),
// @ApiImplicitParam(name = "pageSize", value = "展示数量(条数)", required = true, dataType = "int")})
// @RequestMapping(value = "/shop", method = {RequestMethod.POST, RequestMethod.GET})
// public Result find(Integer beginPos, Integer pageSize) {
// Map shopZxPage = uploadService.getList(beginPos, pageSize);
//
// return new Result("0", "success", shopZxPage);
// }
} }
\ No newline at end of file
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