个人中心优化,增加上传头像接口1
This commit is contained in:
@@ -113,7 +113,7 @@ public class ShopUserController extends BaseController
|
|||||||
// 获取当前登录用户
|
// 获取当前登录用户
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
if (loginUser == null || loginUser.getUserId() == null) {
|
if (loginUser == null || loginUser.getUserId() == null) {
|
||||||
return AjaxResult.error("用户未登录或用户ID为空");
|
return AjaxResult.error(401,"用户未登录或用户ID为空");
|
||||||
}
|
}
|
||||||
ShopUser shopUser = loginUser.getShopUser();
|
ShopUser shopUser = loginUser.getShopUser();
|
||||||
|
|
||||||
@@ -206,7 +206,7 @@ public class ShopUserController extends BaseController
|
|||||||
// 获取当前登录用户
|
// 获取当前登录用户
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
if (loginUser == null || loginUser.getUserId() == null) {
|
if (loginUser == null || loginUser.getUserId() == null) {
|
||||||
return AjaxResult.error("用户未登录或用户ID为空");
|
return AjaxResult.error(401,"用户未登录或用户ID为空");
|
||||||
}
|
}
|
||||||
ShopUser shopUser = loginUser.getShopUser();
|
ShopUser shopUser = loginUser.getShopUser();
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ public class ClientOrderInfoController extends BaseController
|
|||||||
try {
|
try {
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
if (loginUser == null) {
|
if (loginUser == null) {
|
||||||
return AjaxResult.error("用户未登录");
|
return AjaxResult.error(401,"用户未登录");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<OrderInfo> orders = orderInfoService.selectUserOrders(loginUser.getUserId());
|
List<OrderInfo> orders = orderInfoService.selectUserOrders(loginUser.getUserId());
|
||||||
@@ -132,7 +132,7 @@ public class ClientOrderInfoController extends BaseController
|
|||||||
// 检查用户权限
|
// 检查用户权限
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
if (loginUser == null || !loginUser.getUserId().equals(orderInfo.getUserId())) {
|
if (loginUser == null || !loginUser.getUserId().equals(orderInfo.getUserId())) {
|
||||||
return AjaxResult.error("无权限查看此订单");
|
return AjaxResult.error(401,"无权限查看此订单");
|
||||||
}
|
}
|
||||||
|
|
||||||
return AjaxResult.success("查询成功", orderInfo);
|
return AjaxResult.success("查询成功", orderInfo);
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@RequestMapping("/client")
|
@RequestMapping("/client")
|
||||||
@RestController
|
@RestController
|
||||||
@@ -71,7 +73,7 @@ public class ClientShopUserController {
|
|||||||
public AjaxResult modifyUserInfo(@RequestBody ShopUser shopUser){
|
public AjaxResult modifyUserInfo(@RequestBody ShopUser shopUser){
|
||||||
Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
return AjaxResult.error("用户未登录");
|
return AjaxResult.error(401,"用户未登录");
|
||||||
}
|
}
|
||||||
shopUser.setUserId(userId);
|
shopUser.setUserId(userId);
|
||||||
return AjaxResult.success(shopUserService.modifyUser(shopUser));
|
return AjaxResult.success(shopUserService.modifyUser(shopUser));
|
||||||
@@ -86,7 +88,7 @@ public class ClientShopUserController {
|
|||||||
// 获取当前登录用户名
|
// 获取当前登录用户名
|
||||||
Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
return AjaxResult.error("用户未登录");
|
return AjaxResult.error(401,"用户未登录");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据用户ID查询完整的用户信息
|
// 根据用户ID查询完整的用户信息
|
||||||
@@ -132,12 +134,15 @@ public class ClientShopUserController {
|
|||||||
// 检查是否已经登录
|
// 检查是否已经登录
|
||||||
Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
return AjaxResult.error("用户未登录");
|
return AjaxResult.error(401,"用户未登录");
|
||||||
}
|
}
|
||||||
// 1. 处理文件上传
|
// 1. 处理文件上传
|
||||||
if (file != null && !file.isEmpty()) {
|
if (file != null && !file.isEmpty()) {
|
||||||
// 保存文件逻辑
|
// 保存文件逻辑
|
||||||
return AjaxResult.success("请求成功", AliConfig.ossUp("user/", file.getOriginalFilename(), file.getInputStream()));
|
String url = AliConfig.ossUp("user/", file.getOriginalFilename(), file.getInputStream());
|
||||||
|
Map<String,Object> head = new HashMap<>();
|
||||||
|
head.put("headImg",url);
|
||||||
|
return AjaxResult.success("请求成功", head);
|
||||||
}
|
}
|
||||||
return AjaxResult.error("文件不能为空");
|
return AjaxResult.error("文件不能为空");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,4 +76,5 @@ public class IndexController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class ShopUser {
|
|||||||
private Long sex;
|
private Long sex;
|
||||||
|
|
||||||
/** 生日 */
|
/** 生日 */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
@Excel(name = "生日", width = 30, dateFormat = "yyyy-MM-dd")
|
@Excel(name = "生日", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
private Date birthday;
|
private Date birthday;
|
||||||
|
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ public class OrderInfoServiceImpl implements IOrderInfoService
|
|||||||
// 获取当前用户
|
// 获取当前用户
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
if (loginUser == null) {
|
if (loginUser == null) {
|
||||||
return AjaxResult.error("用户未登录");
|
return AjaxResult.error(401,"用户未登录");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建订单
|
// 创建订单
|
||||||
|
|||||||
@@ -167,6 +167,7 @@
|
|||||||
<if test="phone != null">phone = #{phone},</if>
|
<if test="phone != null">phone = #{phone},</if>
|
||||||
<if test="nickname != null">nickname = #{nickname},</if>
|
<if test="nickname != null">nickname = #{nickname},</if>
|
||||||
<if test="sex != null">sex = #{sex},</if>
|
<if test="sex != null">sex = #{sex},</if>
|
||||||
|
<if test="headImg != null">head_img = #{headImg},</if>
|
||||||
<if test="birthday != null">birthday = #{birthday},</if>
|
<if test="birthday != null">birthday = #{birthday},</if>
|
||||||
<if test="addr != null">addr = #{addr},</if>
|
<if test="addr != null">addr = #{addr},</if>
|
||||||
<if test="registerTime != null">register_time = #{registerTime},</if>
|
<if test="registerTime != null">register_time = #{registerTime},</if>
|
||||||
@@ -178,7 +179,7 @@
|
|||||||
<if test="isDel != null">is_del = #{isDel},</if>
|
<if test="isDel != null">is_del = #{isDel},</if>
|
||||||
<if test="vipStartTime != null"> vip_start_time = #{vipStartTime},</if>
|
<if test="vipStartTime != null"> vip_start_time = #{vipStartTime},</if>
|
||||||
<if test="vipEndTime != null"> vip_end_time = #{vipEndTime},</if>
|
<if test="vipEndTime != null"> vip_end_time = #{vipEndTime},</if>
|
||||||
<if test="descinfo != null"> vip_end_time = #{descinfo},</if>
|
<if test="descinfo != null"> descinfo = #{descinfo},</if>
|
||||||
</trim>
|
</trim>
|
||||||
where shop_user.user_id = #{userId}
|
where shop_user.user_id = #{userId}
|
||||||
</update>
|
</update>
|
||||||
|
|||||||
Reference in New Issue
Block a user