个人信息初始化、修改密码、头像等
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package com.yxt.yythmall.api.lpkcustomer;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @description:
|
||||
* @author: dimengzhe
|
||||
* @date: 2024/1/18
|
||||
**/
|
||||
@Data
|
||||
public class CustomerInfoVo {
|
||||
|
||||
@ApiModelProperty("头像")
|
||||
private String photo;
|
||||
@ApiModelProperty("昵称")
|
||||
private String nick;
|
||||
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.yxt.yythmall.api.lpkcustomer.CustomerInfoVo;
|
||||
import com.yxt.yythmall.api.lpkcustomer.LpkCustomer;
|
||||
import com.yxt.yythmall.api.lpkcustomer.LpkCustomerVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
@@ -24,4 +25,6 @@ public interface LpkCustomerMapper extends BaseMapper<LpkCustomer> {
|
||||
LpkCustomerVo getCustomerInfo (@Param("sid")String sid);
|
||||
@Select("select * from lpk_customer where wxMpOpenid=#{wxMpOpenid}")
|
||||
List<LpkCustomer> getCustomer(@Param("wxMpOpenid") String wxMpOpenid);
|
||||
|
||||
CustomerInfoVo getCustomerInfos(String userSid);
|
||||
}
|
||||
|
||||
@@ -5,18 +5,23 @@
|
||||
<!-- ${ew.customSqlSegment} -->
|
||||
|
||||
<select id="customerListPage" resultType="com.yxt.yythmall.api.lpkcustomer.LpkCustomerVo">
|
||||
select
|
||||
sid,
|
||||
createTime,
|
||||
date_format(bindDate, '%Y-%m-%d') as bindDate,
|
||||
realName,
|
||||
nick,
|
||||
photo,
|
||||
mobile,
|
||||
wxMpOpenid as wxMpOpenid
|
||||
select sid,
|
||||
createTime,
|
||||
date_format(bindDate, '%Y-%m-%d') as bindDate,
|
||||
realName,
|
||||
nick,
|
||||
photo,
|
||||
mobile,
|
||||
wxMpOpenid as wxMpOpenid
|
||||
from lpk_customer
|
||||
<where>
|
||||
${ew.sqlSegment}
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="getCustomerInfos" resultType="com.yxt.yythmall.api.lpkcustomer.CustomerInfoVo">
|
||||
select photo,nick
|
||||
from lpk_customer
|
||||
where sid = #{userSid}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.util.IdUtil;
|
||||
import com.yxt.common.core.query.PagerQuery;
|
||||
import com.yxt.common.core.result.ResultBean;
|
||||
import com.yxt.common.core.vo.PagerVo;
|
||||
import com.yxt.yythmall.api.lpkcustomer.CustomerInfoVo;
|
||||
import com.yxt.yythmall.api.lpkcustomer.LpkCustomerQuery;
|
||||
import com.yxt.yythmall.api.lpkcustomer.LpkCustomerVo;
|
||||
import com.yxt.yythmall.api.lpkcustomer.WxBindMobileDto;
|
||||
@@ -12,6 +13,7 @@ import io.swagger.annotations.ApiOperation;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* @author wangpengfei
|
||||
@@ -55,4 +57,22 @@ public class LpkCustomerRest {
|
||||
System.out.println(id);
|
||||
}
|
||||
|
||||
@ApiOperation("更改头像")
|
||||
@PostMapping("/modifyHeadImage")
|
||||
ResultBean<String> modifyHeadImage(@RequestParam("userSid")String userSid,@RequestPart(value = "file") MultipartFile file){
|
||||
return lpkCustomerService.modifyHeadImage(userSid,file);
|
||||
}
|
||||
|
||||
@ApiOperation("更改昵称")
|
||||
@PostMapping("/modifyUserNickName")
|
||||
ResultBean modifyUserNickName(@RequestParam("userSid")String userSid,@RequestParam("userNickName")String userNickName){
|
||||
return lpkCustomerService.modifyUserNickName(userSid,userNickName);
|
||||
}
|
||||
|
||||
@ApiOperation("获取客户个人信息")
|
||||
@GetMapping("/getCustomerInfo/{userSid}")
|
||||
ResultBean<CustomerInfoVo> getCustomerInfo(@PathVariable("userSid")String userSid){
|
||||
return lpkCustomerService.getCustomerInfos(userSid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,17 +10,17 @@ import com.yxt.common.base.service.MybatisBaseService;
|
||||
import com.yxt.common.base.utils.PagerUtil;
|
||||
import com.yxt.common.base.utils.StringUtils;
|
||||
import com.yxt.common.core.query.PagerQuery;
|
||||
import com.yxt.common.core.result.FileUploadResult;
|
||||
import com.yxt.common.core.result.ResultBean;
|
||||
import com.yxt.common.core.vo.PagerVo;
|
||||
import com.yxt.yythmall.api.lpkcustomer.LpkCustomer;
|
||||
import com.yxt.yythmall.api.lpkcustomer.LpkCustomerQuery;
|
||||
import com.yxt.yythmall.api.lpkcustomer.LpkCustomerVo;
|
||||
import com.yxt.yythmall.api.lpkcustomer.WxBindMobileDto;
|
||||
import com.yxt.yythmall.api.lpkcustomer.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
@@ -97,20 +97,34 @@ public class LpkCustomerService extends MybatisBaseService<LpkCustomerMapper, Lp
|
||||
newCustomer.setWxMpOpenid(openid);
|
||||
// newCustomer.setUnionId(unionid);
|
||||
newCustomer.setCreateTime(new Date());
|
||||
newCustomer.setPhoto("headImage.jpg");
|
||||
newCustomer.setNick("小菜窖000"+newCustomer.getId());
|
||||
baseMapper.insert(newCustomer);
|
||||
// return rb.setData(newCustomer).setCode("110");
|
||||
StpUtil.login(newCustomer.getId());
|
||||
SaTokenInfo tokenInfo = StpUtil.getTokenInfo();
|
||||
newCustomer.setToken(tokenInfo.getTokenValue());
|
||||
|
||||
return rb.success().setData(newCustomer);
|
||||
}
|
||||
// //判断是否绑定手机号
|
||||
// if(StringUtils.isBlank(lpkCustomer.getMobile())){
|
||||
// return rb.setData(lpkCustomer).setCode("110");
|
||||
// }
|
||||
if(StringUtils.isBlank(lpkCustomer.getPhoto())){
|
||||
lpkCustomer.setPhoto("headImage.jpg");
|
||||
baseMapper.updateById(lpkCustomer);
|
||||
lpkCustomer = fetchBySid(lpkCustomer.getSid());
|
||||
}
|
||||
if(StringUtils.isBlank(lpkCustomer.getNick())){
|
||||
lpkCustomer.setNick("小菜窖000"+lpkCustomer.getId());
|
||||
baseMapper.updateById(lpkCustomer);
|
||||
lpkCustomer = fetchBySid(lpkCustomer.getSid());
|
||||
}
|
||||
StpUtil.login(lpkCustomer.getId());
|
||||
SaTokenInfo tokenInfo = StpUtil.getTokenInfo();
|
||||
lpkCustomer.setToken(tokenInfo.getTokenValue());
|
||||
|
||||
return rb.success().setData(lpkCustomer);
|
||||
}
|
||||
public ResultBean wxBindMobile(WxBindMobileDto wxBindMobileDto) {
|
||||
@@ -155,4 +169,48 @@ public class LpkCustomerService extends MybatisBaseService<LpkCustomerMapper, Lp
|
||||
}
|
||||
return rb.success().setData(p);
|
||||
}
|
||||
|
||||
public ResultBean modifyHeadImage(String userSid,MultipartFile file) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
LpkCustomer lpkCustomer= fetchBySid(userSid);
|
||||
if(lpkCustomer == null){
|
||||
return rb.setMsg("该客户信息不存在");
|
||||
}
|
||||
if (file == null || file.isEmpty()) {
|
||||
return rb.setMsg("文件为空");
|
||||
}
|
||||
ResultBean<FileUploadResult> resultBean =fileUploadComponent.uploadFile(file,null);
|
||||
FileUploadResult fileUploadResult = resultBean.getData();
|
||||
if(fileUploadResult != null && StringUtils.isNotBlank(fileUploadResult.getFullUrl())){
|
||||
if(fileUploadResult.getFullUrl().contains(fileUploadComponent.getUrlPrefix())){
|
||||
String headImageUrl = fileUploadResult.getFullUrl().replace(fileUploadComponent.getUrlPrefix(),"");
|
||||
lpkCustomer.setPhoto(headImageUrl);
|
||||
}
|
||||
}
|
||||
baseMapper.updateById(lpkCustomer);
|
||||
return rb.success().setData(fileUploadComponent.getUrlPrefix()+lpkCustomer.getPhoto());
|
||||
}
|
||||
|
||||
public ResultBean modifyUserNickName(String userSid, String userNickName) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
LpkCustomer lpkCustomer= fetchBySid(userSid);
|
||||
if(lpkCustomer == null){
|
||||
return rb.setMsg("该客户信息不存在");
|
||||
}
|
||||
lpkCustomer.setNick(userNickName);
|
||||
baseMapper.updateById(lpkCustomer);
|
||||
return rb.success();
|
||||
}
|
||||
|
||||
public ResultBean<CustomerInfoVo> getCustomerInfos(String userSid) {
|
||||
ResultBean<CustomerInfoVo> rb = ResultBean.fireFail();
|
||||
LpkCustomer lpkCustomer= fetchBySid(userSid);
|
||||
if(lpkCustomer == null){
|
||||
return rb.setMsg("该客户信息不存在");
|
||||
}
|
||||
CustomerInfoVo customerInfoVo = baseMapper.getCustomerInfos(userSid);
|
||||
String photo = fileUploadComponent.getUrlPrefix()+customerInfoVo.getPhoto();
|
||||
customerInfoVo.setPhoto(photo);
|
||||
return rb.success().setData(customerInfoVo);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user