结果集修改
parent
e54500d5e2
commit
6c59434e5a
|
@ -43,11 +43,11 @@ public class ArchivesController {
|
|||
log.info("功能介绍:获取我的档案详情,请求方式:{},请求路径:{},请求参数:{}",
|
||||
request.getMethod(),request.getRequestURI(),"无参数");
|
||||
|
||||
R<Archives> result = archivesService.findArchivesList();
|
||||
Archives archives = archivesService.findArchivesList();
|
||||
|
||||
log.info("功能介绍:获取我的档案详情,请求方式:{},请求路径:{},响应结果:{}",
|
||||
request.getMethod(),request.getRequestURI(), JSONObject.toJSONString(result));
|
||||
return result;
|
||||
request.getMethod(),request.getRequestURI(), JSONObject.toJSONString(archives));
|
||||
return R.ok(archives);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,11 +60,11 @@ public class ArchivesController {
|
|||
log.info("功能介绍:添加我的档案,请求方式:{},请求路径:{},请求参数:{}",
|
||||
request.getMethod(),request.getRequestURI(),JSONObject.toJSONString(archives));
|
||||
|
||||
R result = archivesService.insertArchivesAndPicture(archives);
|
||||
archivesService.insertArchivesAndPicture(archives);
|
||||
|
||||
log.info("功能介绍:添加我的档案,请求方式:{},请求路径:{},响应结果:{}",
|
||||
request.getMethod(),request.getRequestURI(),JSONObject.toJSONString(result));
|
||||
return result;
|
||||
request.getMethod(),request.getRequestURI(),JSONObject.toJSONString(R.ok()));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
@ -77,11 +77,11 @@ public class ArchivesController {
|
|||
public R updateArchivesAndPicture(@RequestBody Archives archives){
|
||||
log.info("功能介绍:编辑我的档案,请求方式:{},请求路径:{},请求参数:{}",
|
||||
request.getMethod(),request.getRequestURI(),JSONObject.toJSONString(archives));
|
||||
R result = archivesService.updateArchivesAndPicture(archives);
|
||||
archivesService.updateArchivesAndPicture(archives);
|
||||
|
||||
log.info("功能介绍:编辑我的档案,请求方式:{},请求路径:{},响应结果:{}",
|
||||
request.getMethod(),request.getMethod(),JSONObject.toJSONString(result));
|
||||
return result;
|
||||
request.getMethod(),request.getMethod(),JSONObject.toJSONString(R.ok()));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
@ -94,10 +94,10 @@ public class ArchivesController {
|
|||
public R deleteArchivesById(@PathVariable String id){
|
||||
log.info("功能介绍:根据档案编号删除档案,请求方式:{},请求路径:{},请求参数:{}",
|
||||
request.getMethod(),request.getRequestURI(),JSONObject.toJSONString(id));
|
||||
R result = archivesService.deleteArchivesById(id);
|
||||
archivesService.deleteArchivesById(id);
|
||||
log.info("功能介绍:根据档案编号删除档案,请求方式:{},请求路径:{},响应结果:{}",
|
||||
request.getMethod(),request.getRequestURI(), JSONObject.toJSONString(result));
|
||||
return result;
|
||||
request.getMethod(),request.getRequestURI(), JSONObject.toJSONString(R.ok()));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,21 +2,27 @@ package com.ruoyi.mybasic.controller;
|
|||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.mybasic.common.domain.request.InvitationRecordRequest;
|
||||
import com.ruoyi.mybasic.common.domain.request.RequestInvitationRecord;
|
||||
import com.ruoyi.mybasic.service.InvitationService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName InvitationController
|
||||
* @Description 邀请记录的控制层
|
||||
* @Author WenHao.Sao
|
||||
*/
|
||||
|
||||
/**
|
||||
* 邀请获利控制层
|
||||
* @author Lou_Zs
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/Invitation")
|
||||
@Log4j2
|
||||
|
@ -27,14 +33,7 @@ public class InvitationController {
|
|||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
/**
|
||||
* 当前用户查看自己的邀请记录表
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public R<List<InvitationRecordRequest>> show(@PathVariable String userId){
|
||||
return invitationService.show(userId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -47,10 +46,10 @@ public class InvitationController {
|
|||
log.info("功能介绍:新用户邀请,请求方式:{},请求路径:{},请求参数:{}",
|
||||
request.getMethod(),request.getRequestURI(), JSONObject.toJSONString(requestInvitationRecord));
|
||||
//邀请新用户
|
||||
R req = invitationService.UserInviteTask(requestInvitationRecord);
|
||||
invitationService.UserInviteTask(requestInvitationRecord);
|
||||
log.info("功能介绍:新用户邀请,请求方式:{},请求路径:{},响应结果:{}",
|
||||
request.getMethod(),request.getRequestURI(),JSONObject.toJSONString(req));
|
||||
return req;
|
||||
request.getMethod(),request.getRequestURI(),JSONObject.toJSONString(R.ok()));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,20 +24,20 @@ public interface ArchivesMapper {
|
|||
* 添加我的档案
|
||||
* @param archives
|
||||
*/
|
||||
void insertArchives(Archives archives);
|
||||
int insertArchives(Archives archives);
|
||||
|
||||
|
||||
/**
|
||||
* 编辑我的档案
|
||||
* @param archives
|
||||
*/
|
||||
void updateArchives(Archives archives);
|
||||
int updateArchives(Archives archives);
|
||||
|
||||
/**
|
||||
* 删除我的档案
|
||||
* @param id
|
||||
*/
|
||||
void deleteArchivesById(@Param("id") String id);
|
||||
int deleteArchivesById(@Param("id") String id);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -27,14 +27,14 @@ public interface InvitationMapper {
|
|||
* 邀请记录新增
|
||||
* @param requestInvitationRecord
|
||||
*/
|
||||
void insertInvitationRecord(RequestInvitationRecord requestInvitationRecord);
|
||||
int insertInvitationRecord(RequestInvitationRecord requestInvitationRecord);
|
||||
|
||||
/**
|
||||
* 修改钱包信息
|
||||
* @param userId
|
||||
*/
|
||||
void updateUserPurse(@Param("userId") Integer userId);
|
||||
int updateUserPurse(@Param("userId") Integer userId);
|
||||
|
||||
|
||||
void insertUserMoneyLogs(UserMoneyLogs userMoneyLogs);
|
||||
int insertUserMoneyLogs(UserMoneyLogs userMoneyLogs);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.ruoyi.mybasic.service;
|
||||
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.mybasic.common.domain.Archives;
|
||||
|
||||
/**
|
||||
|
@ -15,26 +14,25 @@ public interface ArchivesService {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
R<Archives> findArchivesList();
|
||||
Archives findArchivesList();
|
||||
|
||||
/**
|
||||
* 添加我的档案
|
||||
* @return
|
||||
*/
|
||||
R insertArchivesAndPicture(Archives archives);
|
||||
void insertArchivesAndPicture(Archives archives);
|
||||
|
||||
|
||||
/**
|
||||
* 编辑我的档案
|
||||
*
|
||||
* @param archives
|
||||
* @return
|
||||
*/
|
||||
R updateArchivesAndPicture(Archives archives);
|
||||
void updateArchivesAndPicture(Archives archives);
|
||||
|
||||
/**
|
||||
* 根据档案编号删除档案
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
R deleteArchivesById(String id);
|
||||
void deleteArchivesById(String id);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.ruoyi.mybasic.service.Impl;
|
||||
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.mybasic.common.domain.Archives;
|
||||
import com.ruoyi.mybasic.mapper.ArchivesMapper;
|
||||
|
@ -33,23 +32,27 @@ public class ArchivesServiceImpl implements ArchivesService {
|
|||
|
||||
/**
|
||||
* 查询我的档案列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R<Archives> findArchivesList() {
|
||||
public Archives findArchivesList() {
|
||||
//获取用户id
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
Archives archivesList = archivesMapper.findArchivesList(userId);
|
||||
return R.ok(archivesList);
|
||||
Archives archives = archivesMapper.findArchivesList(userId);
|
||||
if (null == archives){
|
||||
throw new RuntimeException("查无此档案!");
|
||||
}
|
||||
return archives;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加我的档案
|
||||
*
|
||||
* @param archives
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R insertArchivesAndPicture(Archives archives) {
|
||||
public void insertArchivesAndPicture(Archives archives) {
|
||||
//获取用户id
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
//添加当前用户
|
||||
|
@ -66,17 +69,19 @@ public class ArchivesServiceImpl implements ArchivesService {
|
|||
archives.setPictureUrl(join);
|
||||
}
|
||||
//添加档案
|
||||
archivesMapper.insertArchives(archives);
|
||||
return R.ok();
|
||||
int i = archivesMapper.insertArchives(archives);
|
||||
if (i < 0){
|
||||
throw new RuntimeException("未添加成功!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑我的档案
|
||||
*
|
||||
* @param archives
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R updateArchivesAndPicture(Archives archives) {
|
||||
public void updateArchivesAndPicture(Archives archives) {
|
||||
/**
|
||||
* 若前台传输为[]
|
||||
*/
|
||||
|
@ -89,21 +94,24 @@ public class ArchivesServiceImpl implements ArchivesService {
|
|||
archives.setPictureUrl(join);
|
||||
}
|
||||
//编辑档案
|
||||
archivesMapper.updateArchives(archives);
|
||||
return R.ok();
|
||||
int i = archivesMapper.updateArchives(archives);
|
||||
if (i < 0){
|
||||
throw new RuntimeException("编辑无效!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据档案编号删除档案
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R deleteArchivesById(String id) {
|
||||
public void deleteArchivesById(String id) {
|
||||
//档案删除
|
||||
archivesMapper.deleteArchivesById(id);
|
||||
return R.ok();
|
||||
int i = archivesMapper.deleteArchivesById(id);
|
||||
if (i < 0){
|
||||
throw new RuntimeException("删除失败!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
package com.ruoyi.mybasic.service.Impl;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.mybasic.common.domain.UserMoneyLogs;
|
||||
import com.ruoyi.mybasic.common.domain.emal.IncomeAmount;
|
||||
import com.ruoyi.mybasic.common.domain.request.InvitationRecordRequest;
|
||||
import com.ruoyi.mybasic.common.domain.request.PurseRequest;
|
||||
import com.ruoyi.mybasic.common.domain.request.RequestInvitationRecord;
|
||||
import com.ruoyi.mybasic.mapper.InvitationMapper;
|
||||
import com.ruoyi.mybasic.service.InvitationService;
|
||||
|
@ -13,13 +9,16 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName InvitationServiceImpl
|
||||
* @Description 邀请记录业务层
|
||||
* @Author WenHao.Sao
|
||||
*/
|
||||
/**
|
||||
* 邀请获利实现层
|
||||
* @author Lou_Zs
|
||||
*/
|
||||
@Service
|
||||
public class InvitationServiceImpl implements InvitationService {
|
||||
|
||||
|
@ -27,57 +26,31 @@ public class InvitationServiceImpl implements InvitationService {
|
|||
@Autowired
|
||||
private InvitationMapper invitationMapper;
|
||||
|
||||
/***
|
||||
* 获取到当用户邀请的人的列表
|
||||
* 1.入参 对象:邀请人id 被邀请人id
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R<List<InvitationRecordRequest>> show(String userId) {
|
||||
//获取到邀请记录表
|
||||
List<InvitationRecordRequest> list = invitationMapper.show(userId);
|
||||
|
||||
//所有的邀请记录表进行循环查询
|
||||
for (InvitationRecordRequest invitationRecord : list) {
|
||||
|
||||
//调用枚举类
|
||||
IncomeAmount tenDollars = IncomeAmount.TEN_DOLLARS;
|
||||
//赋值
|
||||
int value = tenDollars.getValue();
|
||||
|
||||
//获取到邀请人钱包余额
|
||||
PurseRequest inviter = invitationMapper.Inviteramount(invitationRecord.getInviterId());
|
||||
//加上枚举值
|
||||
inviter.setBalanceFee(inviter.getBalanceFee() + value);
|
||||
|
||||
//获取到被邀请人钱包余额
|
||||
PurseRequest invitee = invitationMapper.Inviteeamount(invitationRecord.getInviteeId());
|
||||
//加上枚举值
|
||||
invitee.setBalanceFee(inviter.getBalanceFee() + value);
|
||||
|
||||
}
|
||||
R<List<InvitationRecordRequest>> ok = R.ok(list);
|
||||
return ok;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新用户注册邀请获利
|
||||
* @param requestInvitationRecord
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional //事务
|
||||
public R UserInviteTask(RequestInvitationRecord requestInvitationRecord) {
|
||||
public void UserInviteTask(RequestInvitationRecord requestInvitationRecord) {
|
||||
int i = 0;
|
||||
//新增一条邀请记录
|
||||
invitationMapper.insertInvitationRecord(requestInvitationRecord);
|
||||
i = invitationMapper.insertInvitationRecord(requestInvitationRecord);
|
||||
if (i < 0){
|
||||
throw new RuntimeException("该用户未完成邀请");
|
||||
}
|
||||
//被邀请人id
|
||||
Integer userPid = requestInvitationRecord.getUserPid();
|
||||
//邀请人id
|
||||
Integer userId = requestInvitationRecord.getUserId();
|
||||
|
||||
//修改邀请人钱包 (1.可用余额+300 2.总计收入+300 3.修改时间)
|
||||
invitationMapper.updateUserPurse(userId);
|
||||
i = invitationMapper.updateUserPurse(userId);
|
||||
if (i < 0){
|
||||
throw new RuntimeException("获利金额未增加到可用余额");
|
||||
}
|
||||
//同时添加钱包变更记录表
|
||||
UserMoneyLogs PurseMoneyLogs = new UserMoneyLogs();
|
||||
PurseMoneyLogs.setUserId(userId);
|
||||
|
@ -89,7 +62,10 @@ public class InvitationServiceImpl implements InvitationService {
|
|||
|
||||
|
||||
//修改被邀请人钱包 (1.可用余额+300 2.总计收入+300 3.修改时间)
|
||||
invitationMapper.updateUserPurse(userPid);
|
||||
i = invitationMapper.updateUserPurse(userPid);
|
||||
if (i < 0){
|
||||
throw new RuntimeException("获利金额未增加到可用余额");
|
||||
}
|
||||
//同时添加钱包变更记录表
|
||||
UserMoneyLogs PurseMoneyLogsTwo = new UserMoneyLogs();
|
||||
PurseMoneyLogsTwo.setUserId(userPid);
|
||||
|
@ -99,6 +75,5 @@ public class InvitationServiceImpl implements InvitationService {
|
|||
PurseMoneyLogsTwo.setCreateTime(new Date());
|
||||
invitationMapper.insertUserMoneyLogs(PurseMoneyLogsTwo);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,24 @@
|
|||
package com.ruoyi.mybasic.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.mybasic.common.domain.request.InvitationRecordRequest;
|
||||
import com.ruoyi.mybasic.common.domain.request.RequestInvitationRecord;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName InvitationService
|
||||
* @Description 描述
|
||||
* @Author WenHao.Sao
|
||||
*/
|
||||
|
||||
/**
|
||||
* 邀请获利持久层
|
||||
* @author Lou_Zs
|
||||
*/
|
||||
public interface InvitationService {
|
||||
R<List<InvitationRecordRequest>> show(@Param("userId") String userId);
|
||||
|
||||
/**
|
||||
* 新用户注册邀请获利
|
||||
*
|
||||
* @param requestInvitationRecord
|
||||
* @return
|
||||
*/
|
||||
R UserInviteTask(RequestInvitationRecord requestInvitationRecord);
|
||||
void UserInviteTask(RequestInvitationRecord requestInvitationRecord);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue