更新9.23

This commit is contained in:
许允枞 2024-09-23 16:05:05 +08:00
parent b9036b8725
commit 3cd4b240c7
6 changed files with 284 additions and 0 deletions

View File

@ -0,0 +1,68 @@
package com.fuint.business.userManager.controller;
import com.fuint.business.userManager.entity.MtUserCarNo;
import com.fuint.business.userManager.service.IMtUserCarNoService;
import com.fuint.framework.web.BaseController;
import com.fuint.framework.web.ResponseObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
/**
* <p>
* 用户车牌号 前端控制器
* </p>
*
* @author dianliang
* @since 2024-09-23
*/
@RestController
@RequestMapping("/business/userManager/userCarNo")
public class MtUserCarNoController extends BaseController {
@Autowired
private IMtUserCarNoService mtUserCarNoService;
/**
* 获取用户车牌号列表
*
* @return
*/
@GetMapping
public ResponseObject list(){
return getSuccessResult(mtUserCarNoService.getCarNoList());
}
/**
* 新增用户车牌号
* @param mtUserCarNo
* @return
*/
@PostMapping
public ResponseObject add(@RequestBody MtUserCarNo mtUserCarNo) {
return getSuccessResult(mtUserCarNoService.add(mtUserCarNo));
}
/**
* 编辑用户车牌号
* @param mtUserCarNo
* @return
*/
@PutMapping
public ResponseObject edit(@RequestBody MtUserCarNo mtUserCarNo) {
return getSuccessResult(mtUserCarNoService.edit(mtUserCarNo));
}
/**
* 删除用户车牌号
* @param id
* @return
*/
@DeleteMapping("/{id}")
public ResponseObject delete(@PathVariable Integer id) {
return getSuccessResult(mtUserCarNoService.delete(id));
}
}

View File

@ -0,0 +1,57 @@
package com.fuint.business.userManager.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
* 用户车牌号
* </p>
*
* @author dianliang
* @since 2024-09-23
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("mt_user_car_no")
@ApiModel(value="MtUserCarNo对象", description="用户车牌号")
public class MtUserCarNo implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "用户id")
private Integer userId;
@ApiModelProperty(value = "车牌号")
private String carNo;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建时间")
private LocalDateTime createTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新时间")
private LocalDateTime updateTime;
@ApiModelProperty(value = "创建人")
private String createBy;
@ApiModelProperty(value = "更新人")
private String updateBy;
}

View File

@ -0,0 +1,16 @@
package com.fuint.business.userManager.mapper;
import com.fuint.business.userManager.entity.MtUserCarNo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 用户车牌号 Mapper 接口
* </p>
*
* @author dianliang
* @since 2024-09-23
*/
public interface MtUserCarNoMapper extends BaseMapper<MtUserCarNo> {
}

View File

@ -0,0 +1,45 @@
package com.fuint.business.userManager.service;
import com.fuint.business.userManager.entity.MtUserCarNo;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 用户车牌号 服务类
* </p>
*
* @author dianliang
* @since 2024-09-23
*/
public interface IMtUserCarNoService extends IService<MtUserCarNo> {
/**
* 获取用户车牌号列表
*
* @return
*/
List<MtUserCarNo> getCarNoList();
/**
* 新增用户车牌号
* @param mtUserCarNo
* @return
*/
int add(MtUserCarNo mtUserCarNo);
/**
* 编辑用户车牌号
* @param mtUserCarNo
* @return
*/
int edit(MtUserCarNo mtUserCarNo);
/**
* 删除用户车牌号
* @param id
* @return
*/
int delete(Integer id);
}

View File

@ -0,0 +1,96 @@
package com.fuint.business.userManager.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fuint.business.userManager.entity.MtUserCarNo;
import com.fuint.business.userManager.mapper.MtUserCarNoMapper;
import com.fuint.business.userManager.service.IMtUserCarNoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fuint.common.dto.AccountInfo;
import com.fuint.common.util.TokenUtil;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;
/**
* <p>
* 用户车牌号 服务实现类
* </p>
*
* @author dianliang
* @since 2024-09-23
*/
@Service
public class MtUserCarNoServiceImpl extends ServiceImpl<MtUserCarNoMapper, MtUserCarNo> implements IMtUserCarNoService {
/**
* 获取用户车牌号列表
*
* @return
*/
@Override
public List<MtUserCarNo> getCarNoList() {
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
return baseMapper.selectList(new LambdaQueryWrapper<MtUserCarNo>()
.eq(MtUserCarNo::getUserId, nowAccountInfo.getId()));
}
/**
* 新增用户车牌号
*
* @param mtUserCarNo
* @return
*/
@Override
public int add(MtUserCarNo mtUserCarNo) {
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
mtUserCarNo.setUserId(nowAccountInfo.getId());
//查询当前用户当前车牌号是否已经存在
MtUserCarNo existCarNo = baseMapper.selectOne(new LambdaQueryWrapper<MtUserCarNo>()
.eq(MtUserCarNo::getUserId, nowAccountInfo.getId())
.eq(MtUserCarNo::getCarNo, mtUserCarNo.getCarNo()));
if (ObjectUtil.isNotEmpty(existCarNo)) {
throw new RuntimeException("当前车牌号已存在");
}
mtUserCarNo.setCreateTime(LocalDateTime.now());
mtUserCarNo.setCreateBy(nowAccountInfo.getId().toString());
return baseMapper.insert(mtUserCarNo);
}
/**
* 编辑用户车牌号
*
* @param mtUserCarNo
* @return
*/
@Override
public int edit(MtUserCarNo mtUserCarNo) {
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
mtUserCarNo.setUpdateTime(LocalDateTime.now());
mtUserCarNo.setUpdateBy(nowAccountInfo.getId().toString());
return baseMapper.updateById(mtUserCarNo);
}
/**
* 删除用户车牌号
*
* @param id
* @return
*/
@Override
public int delete(Integer id) {
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
MtUserCarNo mtUserCarNo = baseMapper.selectOne(new LambdaQueryWrapper<MtUserCarNo>()
.eq(MtUserCarNo::getId, id));
if (ObjectUtil.isNotEmpty(mtUserCarNo)) {
if (mtUserCarNo.getUserId().equals(nowAccountInfo.getId())) {
return baseMapper.deleteById(id);
}else {
throw new RuntimeException("不能删除他人车牌号信息");
}
}
return 0;
}
}

View File

@ -103,6 +103,8 @@ public class LJUserVo extends BaseEntity {
// 固定等级
private String fixingLevel;
private String payPassword;
/**
* 店铺Id
*/