diff --git a/suimangCApi/src/main/java/com/iformall/controller/VideoController.java b/suimangCApi/src/main/java/com/iformall/controller/VideoController.java index e53e066..8b1d88f 100644 --- a/suimangCApi/src/main/java/com/iformall/controller/VideoController.java +++ b/suimangCApi/src/main/java/com/iformall/controller/VideoController.java @@ -1,7 +1,10 @@ package com.iformall.controller; +import com.iformall.annotation.AuthIgnore; import com.iformall.common.ErrorCode; import com.iformall.common.ResultData; +import com.iformall.domain.po.WxCVideoTable; +import com.iformall.service.WxCVideoService; import com.iformall.video.VideoFactory; import com.iformall.video.entity.VideUploadResult; import io.swagger.annotations.ApiImplicitParam; @@ -29,6 +32,8 @@ public class VideoController extends BaseController { @Autowired String videoType; + @Autowired + WxCVideoService wxCVideoService; /** * 上传视频 @@ -119,4 +124,16 @@ public class VideoController extends BaseController { } } + /** + * 视频模板列表 + */ + @AuthIgnore + @PostMapping("/avatarList") + @ApiOperation(value = "视频模板列表", notes = "{\"username\",\"string\",\"code\",\"string\"}") + public WxCVideoTable avatarList(@RequestBody Map params){ + String username = params.get("username"); + WxCVideoTable TemplateVideo = wxCVideoService.findByUserName(username); + return null; + } + } diff --git a/suimangCApi/src/main/java/com/iformall/controller/WxUserGrantController.java b/suimangCApi/src/main/java/com/iformall/controller/WxUserGrantController.java index 6b3190d..e0ee82f 100644 --- a/suimangCApi/src/main/java/com/iformall/controller/WxUserGrantController.java +++ b/suimangCApi/src/main/java/com/iformall/controller/WxUserGrantController.java @@ -36,6 +36,7 @@ import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.awt.image.BufferedImage; import java.io.IOException; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -128,6 +129,83 @@ public class WxUserGrantController extends BaseController { } } + @AuthIgnore + @PostMapping("/userlogin") + @ApiOperation(value = "用户登录", notes = "{\"username\":\"string\",\"password\":\"string\",\"code\":\"string\",\"Mcode\":\"string\",\"status\":\"int\"}") + public ResultData userLogin(@RequestBody Map map,HttpServletResponse response){ + String ipAddr = getIpAddr(); + logger.debug("[" + ipAddr + "] WxUserGrantController::userlogin"); + String code = map.get("code"); + if(StringUtils.isBlank(code)){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "请输入验证码"); + } + + String key = Constant.captchaPrev + ":" + ipAddr; + String code1 = RedisCacheUtils.getCacheString(redisTemplate, key); + if(StringUtils.isBlank(code1)){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "验证码已过期"); + } + if(!code1.equals(code)){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "验证码不正确"); + } + + String phone = map.get("username"); + String password = map.get("password"); + if(StringUtils.isBlank(phone) || StringUtils.isBlank(password)){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "手机号或密码为空"); + } + + WxCUserBasicInfo basicInfo = wxCUserBasicInfoService.findInfoByPhone(getTenantInfo(), phone); + if(basicInfo == null){ + return new ResultData(ErrorCode.USER_IS_EMPTY); + } + + String encryptPassword = new PasswordHelper().encryptPassword(password); + + if(!encryptPassword.equals(basicInfo.getPassword())){ + return new ResultData(ErrorCode.USER_PASSWD_ERR.getCode(), "手机号或密码错误"); + } + int status = Integer.parseInt(map.get("status")); + + if (status==0){ + basicInfo =wxCUserBasicInfoService.getById1(basicInfo.getId()); + if (basicInfo.getCode()!=null && !map.get("Mcode").equals(basicInfo.getCode())){ + return new ResultData(ErrorCode.USER_ALREADY_LOGIN.getCode(),"用户已在其他设备登录"); + }if (basicInfo.getCode()==null){ + wxCUserBasicInfoService.updateCode(basicInfo.getId(),map.get("Mcode")); + } + } + if (status==-1){ + wxCUserBasicInfoService.updateCode(basicInfo.getId(),null); + basicInfo.setStatus(-2); + return new ResultData(ErrorCode.USER_CANCEL_MCODE.getCode(),"设备已注销"); + } + + basicInfo =wxCUserBasicInfoService.getById1(basicInfo.getId()); + + wxCUserBasicInfoService.handleLoginUser(basicInfo); + Map resultMap = new HashMap(); +// resultMap.put("phone", basicInfo.getPhone()); + Map data = new HashMap(); + data.put("status",basicInfo.getStatus()); + data.put("version",basicInfo.getVersion()); + data.put("current_time",new Date(System.currentTimeMillis()/1000)); + data.put("expire_time",basicInfo.getExpireTime().getTime()/1000); + Map info = new HashMap(); + info.put("log_id",basicInfo.getId()); + info.put("username",basicInfo.getPhone()); + + resultMap.put("data",data); + resultMap.put("info",info); + + + // resultMap.put("expire_time", basicInfo.getExpireTime()); + return new ResultData(resultMap); + } + + + + /** * 用户登录 * diff --git a/suimangService/src/main/java/com/iformall/common/ErrorCode.java b/suimangService/src/main/java/com/iformall/common/ErrorCode.java index 83a9005..596eb46 100644 --- a/suimangService/src/main/java/com/iformall/common/ErrorCode.java +++ b/suimangService/src/main/java/com/iformall/common/ErrorCode.java @@ -97,6 +97,8 @@ public enum ErrorCode{ USER_NAME_IS_FOUND(2008,"用户名已存在"), USER_PHONE_IS_FOUND(2009,"手机号已存在"), MEMBER_IS_LOCKED(2010, "当前会员已被锁定"), + USER_ALREADY_LOGIN(2011,"用户已在其他端登入"), + USER_CANCEL_MCODE(2012,"用户已在其他端登入"), USER_BIRTHDATE_AFTER(2109, "出生日期大于当前日期"), USER_APPINFO_NOT_EXIST(2110,"当前登录用户APP为空"), USER_APPINFO_NOFUND_PAYACCOUNT(2111,"当前app找不到payAccount"), diff --git a/suimangService/src/main/java/com/iformall/domain/po/WxCUserBasicInfo.java b/suimangService/src/main/java/com/iformall/domain/po/WxCUserBasicInfo.java index a09a0bf..172a300 100644 --- a/suimangService/src/main/java/com/iformall/domain/po/WxCUserBasicInfo.java +++ b/suimangService/src/main/java/com/iformall/domain/po/WxCUserBasicInfo.java @@ -157,14 +157,18 @@ public class WxCUserBasicInfo extends TenantEntityWithoutFinalTenantId { @io.swagger.annotations.ApiModelProperty(value = "状态0正常1锁定", name = "status") private Integer status; + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value = "机器码", name = "code") + private String code; /*用户登录用token**/ @TableField(exist = false) @io.swagger.annotations.ApiModelProperty(value="用户登录用token",name="token") protected String token; /*用户过期时间**/ -// @io.swagger.annotations.ApiModelProperty(value="用户过期时间",name="expireTime") -// protected Date expireTime; + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value="用户过期时间",name="expireTime") + protected Date expireTime; @TableField(exist = false) @Excel(name="标签",width = 50,orderNum = "15") @@ -218,6 +222,10 @@ public class WxCUserBasicInfo extends TenantEntityWithoutFinalTenantId { @TableField(exist = false) @io.swagger.annotations.ApiModelProperty(value="套餐类型(1、基础版,2、专业版,3、加强版)",name="packageType") private Integer packageType; + @TableField(exist = false) + @io.swagger.annotations.ApiModelProperty(value="套餐类型(1、基础版,2、专业版,3、加强版)",name="packageType") + private Integer version; + public void protectInfos() { if(StringUtils.isNotBlank(this.password)) { diff --git a/suimangService/src/main/java/com/iformall/mapper/WxCUserBasicInfoMapper.java b/suimangService/src/main/java/com/iformall/mapper/WxCUserBasicInfoMapper.java index 7584390..4d526c3 100644 --- a/suimangService/src/main/java/com/iformall/mapper/WxCUserBasicInfoMapper.java +++ b/suimangService/src/main/java/com/iformall/mapper/WxCUserBasicInfoMapper.java @@ -65,5 +65,9 @@ public interface WxCUserBasicInfoMapper extends CommonMapper findIdByFilter(WxCUserBasicInfoDto wxCUserBasicInfoDto); long getTotalCreditAmount(@Param("tenantId")String tenantId, @Param("finalTenantId")String finalTenantId); + + WxCUserBasicInfo selectById1(Long id); + + void updateCode(Long id, String mcode); } diff --git a/suimangService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java b/suimangService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java index cd40af2..a2db33a 100644 --- a/suimangService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java +++ b/suimangService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java @@ -200,5 +200,10 @@ public interface WxCUserBasicInfoService { void sendTicketEmail(WxCUserBasicInfo basicInfo, EnumMsgModel type); void updUserInfo(WxCUserBasicInfo cUser, Long memberId); + + WxCUserBasicInfo getById1(Long id); + + + void updateCode(Long id, String mcode); } diff --git a/suimangService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java b/suimangService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java index 166b2bb..22fdcbb 100644 --- a/suimangService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java +++ b/suimangService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java @@ -953,6 +953,17 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc update(info); } + @Override + public WxCUserBasicInfo getById1(Long id) { + return wxCUserBasicInfoMapper.selectById1(id); + } + + @Override + public void updateCode(Long id, String mcode) { + + wxCUserBasicInfoMapper.updateCode(id,mcode); + } + @Override public WxCUserBasicInfo getById(Long id,String finalTenantId) { diff --git a/suimangService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml b/suimangService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml index dcbd9cd..22e9275 100644 --- a/suimangService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml +++ b/suimangService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml @@ -28,7 +28,9 @@ - + + + @@ -38,6 +40,13 @@ wcubi.`avatar_url`,wcubi.`credit`,wcubi.`active_time`,wcubi.`login_count`,wcubi.`act_record`, wcubi.score_date,wcubi.status + + wcubi.`id`,wcubi.`phone`,wcubi.`birthdate`,wcubi.`education`,wcubi.`sex`,wcubi.`height`,wcubi.`weight`,wcubi.`id_card`,wcubi.`email`, + wcubi.`address`,wcubi.`poins`,wcubi.`tag_id`,wcubi.`create_date`,wcubi.`update_date`, + wcubi.`final_tenant_id`,wcubi.`tenant_id`,wcubi.`parent_tenant_id`,wcubi.`name`,wcubi.`nick_name`, + wcubi.`avatar_url`,wcubi.`credit`,wcubi.`active_time`,wcubi.`login_count`,wcubi.`act_record`, + wcubi.score_date,wcubi.status,wcubi1.code,wcubi1.version,wcubi1.expire_time + where 1=1 @@ -129,6 +138,11 @@ from wx_c_user_basic_info wcubi where wcubi.id =#{id} +