回收员业务功能开发v1

wxpay
LI-CCONG\李聪聪 8 months ago
parent bbfcc33cf1
commit eeba3f1613

@ -7,7 +7,7 @@ import cc.yunxi.common.utils.BeanUtils;
import cc.yunxi.domain.dto.UserDTO;
import cc.yunxi.domain.po.Client;
import cc.yunxi.domain.query.ClientQuery;
import cc.yunxi.domain.vo.ClientVO;
import cc.yunxi.domain.vo.client.ClientRespVO;
import cc.yunxi.domain.vo.client.ClientUpdateVO;
import cc.yunxi.service.IClientService;
import cc.yunxi.utils.UserContext;
@ -35,21 +35,21 @@ public class ClientController {
@ApiOperation("分页查询散户")
@PostMapping("/page")
public CommonResult<PageDTO<ClientVO>> queryClientByPage(@RequestBody ClientQuery clientQuery) {
public CommonResult<PageDTO<ClientRespVO>> queryClientByPage(@RequestBody ClientQuery clientQuery) {
// 1.分页查询
Page<Client> result = clientService.queryByPage(clientQuery);
// 2.封装并返回
PageDTO<ClientVO> clientPageVO = PageDTO.of(result, ClientVO.class);
PageDTO<ClientRespVO> clientPageVO = PageDTO.of(result, ClientRespVO.class);
return CommonResult.success(clientPageVO);
}
@ApiOperation("散户个人信息")
@GetMapping("/info")
public CommonResult<ClientVO> getClientInfo() {
public CommonResult<ClientRespVO> getClientInfo() {
UserDTO userDTO = UserContext.getUser();
Client client = clientService.getClientById(userDTO.getId());
ClientVO clientVO = BeanUtils.copyBean(client, ClientVO.class);
ClientRespVO clientVO = BeanUtils.copyBean(client, ClientRespVO.class);
return CommonResult.success(clientVO);
}

@ -6,16 +6,10 @@ import cc.yunxi.common.domain.PageDTO;
import cc.yunxi.common.exception.BizIllegalException;
import cc.yunxi.common.utils.BeanUtils;
import cc.yunxi.domain.dto.LocationDTO;
import cc.yunxi.domain.po.RecycleOrder;
import cc.yunxi.domain.po.RecycleStation;
import cc.yunxi.domain.po.Recycler;
import cc.yunxi.domain.query.RecycleStationQuery;
import cc.yunxi.domain.query.RecyclerQuery;
import cc.yunxi.domain.vo.RecyclerVO;
import cc.yunxi.domain.vo.recycleorder.RecycleOrderRespVO;
import cc.yunxi.domain.vo.recyclestation.RecycleStationRespVO;
import cc.yunxi.service.IRecycleStationService;
import cc.yunxi.service.IRecyclerService;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
@ -24,7 +18,6 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* <p>
@ -71,5 +64,4 @@ public class RecycleStationController {
return CommonResult.success(recycleStationRespVO);
}
}

@ -6,7 +6,8 @@ import cc.yunxi.common.utils.BeanUtils;
import cc.yunxi.domain.dto.UserDTO;
import cc.yunxi.domain.po.Recycler;
import cc.yunxi.domain.query.RecyclerQuery;
import cc.yunxi.domain.vo.RecyclerVO;
import cc.yunxi.domain.vo.recycler.RecyclerRespVO;
import cc.yunxi.domain.vo.recycler.RecyclerUpdateVO;
import cc.yunxi.service.IRecyclerService;
import cc.yunxi.utils.UserContext;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -25,23 +26,33 @@ public class RecyclerController {
@ApiOperation("分页查询回收员")
@PostMapping("/page")
public CommonResult<PageDTO<RecyclerVO>> queryRecyclerByPage(@RequestBody RecyclerQuery recyclerQuery) {
public CommonResult<PageDTO<RecyclerRespVO>> queryRecyclerByPage(@RequestBody RecyclerQuery recyclerQuery) {
// 1.分页查询
Page<Recycler> result = recyclerService.queryByPage(recyclerQuery);
Page<Recycler> result = recyclerService.queryRecyclerByPage(recyclerQuery);
// 2.封装并返回
PageDTO<RecyclerVO> recyclerPageDTO = PageDTO.of(result, RecyclerVO.class);
PageDTO<RecyclerRespVO> recyclerPageDTO = PageDTO.of(result, RecyclerRespVO.class);
return CommonResult.success(recyclerPageDTO);
}
@ApiOperation("查询回收员信息")
@GetMapping("/info")
public CommonResult<RecyclerVO> getRecyclerInfo() {
public CommonResult<RecyclerRespVO> getRecyclerInfo() {
// 获取当前用户信息
UserDTO userDTO = UserContext.getUser();
Recycler recycler = recyclerService.getById(userDTO.getId());
RecyclerVO recyclerDTO = BeanUtils.copyBean(recycler, RecyclerVO.class);
RecyclerRespVO recyclerDTO = BeanUtils.copyBean(recycler, RecyclerRespVO.class);
return CommonResult.success(recyclerDTO);
}
@ApiOperation("更新回收员信息")
@PostMapping("/update")
public CommonResult<Boolean> updateClientInfo(@RequestBody RecyclerUpdateVO recyclerUpdateVO) {
UserDTO userDTO = UserContext.getUser();
recyclerUpdateVO.setId(userDTO.getId());
recyclerService.updateRecycler(recyclerUpdateVO);
return CommonResult.success(true);
}
}

@ -1,84 +0,0 @@
package cc.yunxi.domain.vo;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* <p>
* VO
* </p>
*
* @author ccongli
* @since 2024-02-28 16:08:09
*/
@Data
@ApiModel(description = "散户实体")
public class ClientVO {
@ApiModelProperty("自然主键")
@TableId("id")
private String id;
@ApiModelProperty("微信openid")
private String wxOpenid;
@ApiModelProperty("微信名")
private String wxUserName;
@ApiModelProperty("昵称")
private String nickName;
@ApiModelProperty("手机")
private String mobilePhone;
@ApiModelProperty("头像")
private String headIcon;
@ApiModelProperty("性别")
private Integer gender;
@ApiModelProperty("生日")
private Date birthday;
@ApiModelProperty("账户余额")
private BigDecimal banlance;
@ApiModelProperty("会员码")
private String membershipNumber;
@ApiModelProperty("会员积分")
private Integer membershipPoint;
@ApiModelProperty("会员等级")
private Integer membershipLevel;
@ApiModelProperty("发票抬头")
private String taxTitle;
@ApiModelProperty("企业税号")
private String taxId;
@ApiModelProperty("当前位置-经度")
private Double longitude;
@ApiModelProperty("当前位置-纬度")
private Double latitude;
@ApiModelProperty("最后登录时间")
private Date lastLogTime;
@ApiModelProperty("最后登录IP")
private String lastLogIp;
@ApiModelProperty("有效标志(0-禁用1-启用)")
private Integer enabledMark;
@ApiModelProperty("创建时间")
private Date creatorTime;
}

@ -18,7 +18,7 @@ import java.util.Date;
* @since 2024-02-28 16:08:09
*/
@Data
@ApiModel(description = "散户 Response VO")
@ApiModel(description = "散户更新 Request VO")
public class ClientUpdateVO {
@ApiModelProperty(value = "id", required = false, example = "大马猴", hidden = true)

@ -1,4 +1,4 @@
package cc.yunxi.domain.vo;
package cc.yunxi.domain.vo.recycler;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -15,8 +15,8 @@ import java.math.BigDecimal;
* @since 2024-02-26 16:08:09
*/
@Data
@ApiModel(description = "回收员实体")
public class RecyclerVO {
@ApiModel(description = "回收员 Response VO")
public class RecyclerRespVO {
@ApiModelProperty("回收员id")
private String id;

@ -0,0 +1,25 @@
package cc.yunxi.domain.vo.recycler;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(description = "回收员更新 Request VO")
public class RecyclerUpdateVO {
@ApiModelProperty(value = "回收员id", hidden = true, example = "533242995646951685")
private String id;
@ApiModelProperty(value = "回收员姓名", required = false, example = "光头强")
private String staffsName; // 回收员姓名
@ApiModelProperty(value = "头像", required = false, example = "光头强")
private String headIcon; // 头像
@ApiModelProperty(value = "性别", required = false, example = "1")
private Integer gender; // 性别
@ApiModelProperty(value = "自动接单 (0-否1-是)", required = false, example = "0")
private Integer autoEnabled; // 自动接单(0-否1-是)
}

@ -1,8 +1,10 @@
package cc.yunxi.service;
import cc.yunxi.domain.po.Client;
import cc.yunxi.domain.po.Recycler;
import cc.yunxi.domain.po.Test;
import cc.yunxi.domain.query.RecyclerQuery;
import cc.yunxi.domain.vo.recycler.RecyclerUpdateVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
@ -16,7 +18,14 @@ public interface IRecyclerService extends IService<Recycler> {
* @param recyclerQuery
* @return Page<Recycler>
*/
Page<Recycler> queryByPage(RecyclerQuery recyclerQuery);
Page<Recycler> queryRecyclerByPage(RecyclerQuery recyclerQuery);
/**
* id
* @param id
* @return Client
*/
Recycler getRecyclerById(String id);
/**
* openid
@ -27,6 +36,16 @@ public interface IRecyclerService extends IService<Recycler> {
/**
*
* @param phoneNumber
* @param openId
* @return Recycler
*/
Recycler registerRecycler(String phoneNumber, String openId);
/**
*
* @param recyclerUpdateVO
*/
void updateRecycler(RecyclerUpdateVO recyclerUpdateVO);
}

@ -1,8 +1,13 @@
package cc.yunxi.service.impl;
import cc.yunxi.common.exception.BizIllegalException;
import cc.yunxi.common.exception.DbException;
import cc.yunxi.common.utils.BeanUtils;
import cc.yunxi.domain.po.Client;
import cc.yunxi.domain.po.Recycler;
import cc.yunxi.domain.query.RecyclerQuery;
import cc.yunxi.domain.vo.client.ClientUpdateVO;
import cc.yunxi.domain.vo.recycler.RecyclerUpdateVO;
import cc.yunxi.mapper.RecyclerMapper;
import cc.yunxi.service.IRecyclerService;
import cn.hutool.core.util.ObjectUtil;
@ -26,7 +31,8 @@ public class RecyclerServiceImpl extends ServiceImpl<RecyclerMapper, Recycler> i
@Resource
RecyclerMapper recyclerMapper;
public Page<Recycler> queryByPage(RecyclerQuery recyclerQuery) {
@Override
public Page<Recycler> queryRecyclerByPage(RecyclerQuery recyclerQuery) {
QueryWrapper<Recycler> wrapper = new QueryWrapper<>();
wrapper.lambda()
.eq(StrUtil.isNotEmpty(recyclerQuery.getStationId()), Recycler::getStationId, recyclerQuery.getStationId())
@ -39,6 +45,11 @@ public class RecyclerServiceImpl extends ServiceImpl<RecyclerMapper, Recycler> i
return recyclerPage;
}
@Override
public Recycler getRecyclerById(String id) {
return this.getById(id);
}
@Override
public Recycler getRecyclerByOpenid(String openid) {
@ -46,6 +57,16 @@ public class RecyclerServiceImpl extends ServiceImpl<RecyclerMapper, Recycler> i
return recycler;
}
@Override
@Transactional
public void updateRecycler(RecyclerUpdateVO recyclerUpdateVO) {
validateRecyclerExists(recyclerUpdateVO.getId());
Recycler recycler = BeanUtils.copyBean(recyclerUpdateVO, Recycler.class);
this.updateById(recycler);
}
@Override
@Transactional
public Recycler registerRecycler(String phoneNumber, String openId) {
@ -61,4 +82,11 @@ public class RecyclerServiceImpl extends ServiceImpl<RecyclerMapper, Recycler> i
recyclerMapper.insert(recycler);
return recycler;
}
// 校验散户是否存在
private void validateRecyclerExists(String id) {
if (this.getRecyclerById(id) == null) {
throw new DbException("散户不存在");
}
}
}

Loading…
Cancel
Save