Commit 650b2c9f authored by licc's avatar licc

修改用户注册返回结果

parent 6233cbcd
......@@ -13,7 +13,7 @@
</resultMap>
<sql id="table">
scheme_query_record
scheme
</sql>
<sql id="cols_all">
......
......@@ -8,6 +8,9 @@ import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @author 86187
*/
@Data
@ApiModel(value = "SchemeInnfo")
public class SchemeInfo extends BaseEntity implements Serializable {
......
......@@ -50,8 +50,8 @@ public class Volunteer extends BaseEntity implements Serializable {
/**
* 专业名称
*/
@ApiModelProperty(value = "专业名称", name = "majorName")
@ExcelProperty(value = "专业名称")
@ApiModelProperty(value = "专业", name = "majorName")
@ExcelProperty(value = "专业")
private String majorName;
/**
......@@ -79,7 +79,7 @@ public class Volunteer extends BaseEntity implements Serializable {
* 学年制(年)
*/
@ApiModelProperty(value = "学年制(年)", name = "yearLimit")
@ExcelProperty(value = "学制(年)")
@ExcelProperty(value = "学制(年)")
private Integer yearLimit;
/**
......
......@@ -19,7 +19,7 @@ public interface UserLoginService {
* @param userRegisterVo 用户信息
* @return true 成功 false 失败
*/
R<Boolean> register(UserRegisterVo userRegisterVo);
R<UserInfoVo> register(UserRegisterVo userRegisterVo);
/**
* 手机验证码登录
......
......@@ -30,4 +30,12 @@ public interface VolunteerService extends IService<Volunteer> {
* @throws IOException 异常
*/
void excelAdd(MultipartFile file, Integer type, String schemeName, HttpServletResponse response) throws IOException;
/**
* Excel批量添加方案志愿
* @param file 志愿文件
* @param response 相应数据
* @throws IOException 异常
*/
void ceshi(MultipartFile file, HttpServletResponse response) throws IOException;
}
......@@ -45,7 +45,7 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, User> impleme
private Cache cache;
@Override
public R<Boolean> register(UserRegisterVo userVo) {
public R<UserInfoVo> register(UserRegisterVo userVo) {
log.info("volunteer-service[]UserLoginServiceImpl[]register[]input.param.userVo:" + userVo);
if (null == userVo || StringUtils.isBlank(userVo.getPhone()) || StringUtils.isBlank(userVo.getPassword())) {
return R.error("入参为空!");
......@@ -72,22 +72,24 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, User> impleme
int count = usersMapper.add(userInfo);
if (count == 0) {
return R.ok(1, false);
return R.error("考生注册失败!");
}
//4、保存操作记录
User user=usersMapper.getByPhone(userVo.getPhone());
User user = usersMapper.getByPhone(userVo.getPhone());
LoginRecord loginRecord = new LoginRecord();
loginRecord.setType(OperationTypeEnum.USER_REGISTER.getCode());
loginRecord.setUserId(user.getId());
String name = OperationTypeEnum.getByCode(OperationTypeEnum.USER_REGISTER.getCode());
loginRecord.setOperationName(name);
int sum = loginRecordMapper.add(loginRecord);
if (sum == 0) {
return R.ok(1, false);
}
loginRecordMapper.add(loginRecord);
return R.ok(0, true);
//5、封装返回参数
UserInfoVo userInfoVo = new UserInfoVo();
userInfoVo.setUserId(user.getId());
userInfoVo.setUserName(user.getUserName());
userInfoVo.setPhone(user.getPhone());
return R.ok(userInfoVo);
}
@Override
......@@ -130,7 +132,7 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, User> impleme
//2、判断密码是否正确
//MD5加密
String secret = Md5Util.digestMD5( userVo.getPassword()+ userVo.getPhone());
String secret = Md5Util.digestMD5(userVo.getPassword() + userVo.getPhone());
if (!user.getPassword().equals(secret)) {
return R.error("密码错误,请您输入正确密码!");
......
......@@ -43,6 +43,9 @@ public class VolunteerServiceImpl extends ServiceImpl<VolunteerMapper, Volunteer
@Override
public void excelAdd(MultipartFile file, Integer type, String schemeName, HttpServletResponse response) throws IOException {
if (file == null || file.isEmpty() || null == type || StringUtils.isBlank(schemeName)) {
throw new BaseException("操作错误");
}
//判断文件类型=
boolean valid = this.validContentType(file.getOriginalFilename());
......@@ -57,7 +60,22 @@ public class VolunteerServiceImpl extends ServiceImpl<VolunteerMapper, Volunteer
schemeInfo.setUploadTime(new Date());
schemeInfo.setIsDelete(0);
saveSchemeAndVolunteer(schemeInfo,file);
saveSchemeAndVolunteer(schemeInfo, file);
}
@Override
public void ceshi(MultipartFile file, HttpServletResponse response) throws IOException {
if (file == null || file.isEmpty()) {
throw new BaseException("操作错误");
}
//判断文件类型=
boolean valid = this.validContentType(file.getOriginalFilename());
if (!valid) {
throw new BaseException("请传入Excel文件");
}
//2.读取数据进行入库操作
EasyExcel.read(file.getInputStream(), Volunteer.class, new VolunteerListener(this)).sheet().doRead();
}
/**
......@@ -67,7 +85,7 @@ public class VolunteerServiceImpl extends ServiceImpl<VolunteerMapper, Volunteer
* @param file 志愿文件
* @throws IOException 异常
*/
@Transactional(rollbackFor =Exception.class )
@Transactional(rollbackFor = Exception.class)
public void saveSchemeAndVolunteer(SchemeInfo schemeInfo, MultipartFile file) throws IOException {
//1、保存方案信息
......
......@@ -23,7 +23,7 @@ public class VolunteerListener extends AnalysisEventListener<Volunteer> {
private VolunteerService volunteerService;
private final int batch = 20000;
private final int batch = 50000;
/**
* 导入模板头内容
......@@ -122,8 +122,6 @@ public class VolunteerListener extends AnalysisEventListener<Volunteer> {
log.info("doAfterAllAnalysed解析玩一个志愿sheet工作表>>>>>>>>>>");
//如果集合不为空
if (!CollectionUtils.isEmpty(list)) {
//TODO 判断excel表中的手机号是否重复
log.info("批量插入志愿数据,条数为>>>>>>>>>>:{}", list.size());
if (list.size() > 0) {
volunteerService.saveBatch(list);
......
......@@ -51,9 +51,8 @@ public class SchemeController {
}
@ApiOperation(value = "Excel批量添加方案志愿", notes = "Excel批量添加方案志愿")
@ApiImplicitParam(name = "file", value = "excel文件", dataType = "MultipartFile")
@PostMapping("/excel/add")
public R excelAdd(@RequestParam("uploadfile") MultipartFile file, @RequestParam("type") Integer type,
public R excelAdd(@RequestParam("file") MultipartFile file, @RequestParam("type") Integer type,
@RequestParam("schemeName") String schemeName, HttpServletResponse response) throws IOException {
if (file == null || file.isEmpty() || null == type || StringUtils.isBlank(schemeName)) {
throw new BaseException("操作错误");
......@@ -63,4 +62,17 @@ public class SchemeController {
return R.ok("添加成功");
}
@ApiOperation(value = "测试Excel", notes = "测试Excel")
@ApiImplicitParam(name = "file", value = "志愿查询参数", dataType = "MultipartFile")
@PostMapping("/excel/add/ceshi")
public R ceshi(@RequestBody MultipartFile file, HttpServletResponse response) throws IOException {
log.info("");
if (file == null || file.isEmpty()) {
throw new BaseException("操作错误");
}
volunteerService.ceshi(file, response);
return R.ok("添加成功");
}
}
......@@ -36,7 +36,7 @@ public class UserLoginController {
@ApiOperation(value = "用户注册", notes = "用户注册", httpMethod = "POST")
@ApiImplicitParam(name = "userVo", value = "用户信息", dataType = "UserRegisterVo")
@PostMapping("/register")
public R<Boolean> resetPassword(@RequestBody UserRegisterVo userVo) {
public R<UserInfoVo> resetPassword(@RequestBody UserRegisterVo userVo) {
log.info("volunteer-service[]UserLongController[]resetPassword[]input.param.userVo:" + userVo);
if (null == userVo) {
......
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