```txtfeat(user): 实现用户充值功能
新增一个用户充值功能,用户可以通过POST请求向其账户内余额进行充值。 在SysUserController中添加了addUserMoney接口,通过调用UserService中的addUserMoney服务来实现。 同时,更新了SysUserMapper及SysUserMapper.xml以支持数据库中用户余额的增加。 ```master
parent
7c9091b6bf
commit
71ead9ebfd
|
@ -283,6 +283,13 @@ public class SysUserController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
@PostMapping("/addUserMoney")
|
||||||
|
public Result<String> addUserMoney(@RequestBody SysUser user){
|
||||||
|
return Result.success(userService.addUserMoney(user));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -147,4 +147,8 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||||
|
|
||||||
|
|
||||||
BigDecimal selectBalance(Long userId);
|
BigDecimal selectBalance(Long userId);
|
||||||
|
|
||||||
|
|
||||||
|
int addUserMoney(SysUser user);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,4 +231,8 @@ public interface SysUserService extends IService<SysUser> {
|
||||||
|
|
||||||
|
|
||||||
BigDecimal selectBalance(Long userId);
|
BigDecimal selectBalance(Long userId);
|
||||||
|
|
||||||
|
|
||||||
|
String addUserMoney(SysUser user);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,6 +132,15 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
return userMapper.selectBalance(userId);
|
return userMapper.selectBalance(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String addUserMoney(SysUser user) {
|
||||||
|
int i = userMapper.addUserMoney(user);
|
||||||
|
if(i <= 0){
|
||||||
|
throw new RuntimeException("充值失败");
|
||||||
|
}
|
||||||
|
return "充值成功";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户所属角色组
|
* 查询用户所属角色组
|
||||||
*
|
*
|
||||||
|
|
|
@ -184,10 +184,16 @@
|
||||||
and del_flag = '0'
|
and del_flag = '0'
|
||||||
limit 1
|
limit 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectBalance" resultType="java.math.BigDecimal">
|
<select id="selectBalance" resultType="java.math.BigDecimal">
|
||||||
select user_balance from sys_user where user_id = #{userId}
|
select user_balance from sys_user where user_id = #{userId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<update id="addUserMoney">
|
||||||
|
update sys_user set user_balance = user_balance + #{userBalance} where user_id = #{userId}
|
||||||
|
</update>
|
||||||
|
|
||||||
<insert id="insertUser" parameterType="com.muyu.common.system.domain.SysUser" useGeneratedKeys="true" keyProperty="userId">
|
<insert id="insertUser" parameterType="com.muyu.common.system.domain.SysUser" useGeneratedKeys="true" keyProperty="userId">
|
||||||
insert into sys_user(
|
insert into sys_user(
|
||||||
<if test="userId != null and userId != 0">user_id,</if>
|
<if test="userId != null and userId != 0">user_id,</if>
|
||||||
|
|
Loading…
Reference in New Issue