feat():增加内部新增功能接口
parent
01a6ad1abb
commit
9a1a0be010
|
@ -1,9 +1,9 @@
|
|||
package com.muyu.cloud.market.domin;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
@ -23,6 +23,7 @@ import java.util.Date;
|
|||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
@TableName(value = "",autoResultMap = true)
|
||||
public class Customer extends BaseEntity {
|
||||
|
@ -42,6 +43,9 @@ public class Customer extends BaseEntity {
|
|||
/**
|
||||
* 生日
|
||||
*/
|
||||
@JsonFormat(
|
||||
pattern = "yyyy-MM-dd HH:mm:ss"
|
||||
)
|
||||
private Date birthday;
|
||||
/**
|
||||
* 身份证
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
package com.muyu.cloud.market.domin.req;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.cloud.market.domin.req
|
||||
* @Project:cloud-market
|
||||
* @name:CustomerAddReq
|
||||
* @Date:2024/8/20 21:36
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@Tag(name = "添加客户信息请求对象",description = "根据入参进行客户信息的添加")
|
||||
public class CustomerAddReq {
|
||||
/**
|
||||
* 客户名称
|
||||
*/
|
||||
@NotEmpty(message = "客户名称不可为空")
|
||||
private String name;
|
||||
/**
|
||||
* 客户性别
|
||||
*/
|
||||
@NotEmpty(message = "客户性别不可为空")
|
||||
private String gender;
|
||||
/**
|
||||
* 身份证
|
||||
*/
|
||||
@NotEmpty(message = "客户身份证不可为空")
|
||||
private String idCard;
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@NotEmpty(message = "客户手机号不可为空")
|
||||
private String tel;
|
||||
/**
|
||||
* 客户地址
|
||||
*/
|
||||
@NotEmpty(message = "客户地址不可为空")
|
||||
private String address;
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
@NotEmpty(message = "客户邮箱不可为空")
|
||||
private String email;
|
||||
|
||||
|
||||
}
|
|
@ -56,15 +56,6 @@ public class FindCustomerMeaasgeController {
|
|||
return Result.success(findCustomerMeaasgeService.findListByuserPhone(tel));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加客户信息
|
||||
* @return
|
||||
*/
|
||||
@PostMapping
|
||||
@Operation(summary = "查询客户信息",description = "根据手机号查询客户信息")
|
||||
public Result addCustomerMessage(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package com.muyu.cloud.market.controller;
|
||||
|
||||
import com.muyu.cloud.market.domin.req.CustomerAddReq;
|
||||
import com.muyu.cloud.market.service.FindCustomerMeaasgeService;
|
||||
import com.muyu.cloud.market.service.InsideUseInterfaceService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.cloud.market.controller
|
||||
* @Project:cloud-market
|
||||
* @name:InsideUseInterfaceController
|
||||
* @Date:2024/8/20 20:42
|
||||
*/
|
||||
@Log4j2
|
||||
@RestController
|
||||
@RequestMapping("InsideUse")
|
||||
@Tag(name = "内部使用控制层",description = "进行公司内部接口使用管理、增删改等相关操作")
|
||||
public class InsideUseInterfaceController {
|
||||
|
||||
/**
|
||||
* 内部使用业务层
|
||||
*/
|
||||
@Autowired
|
||||
private InsideUseInterfaceService insideUseInterfaceService;
|
||||
|
||||
/**
|
||||
* 添加客户信息
|
||||
* @return
|
||||
*/
|
||||
@PostMapping
|
||||
@Operation(summary = "新增客户信息",description = "客户信息的添加操作")
|
||||
public Result addCustomerMessage(@Validated @RequestBody CustomerAddReq customerAddReq){
|
||||
insideUseInterfaceService.add(customerAddReq);
|
||||
return Result.success(null,"操作成功");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.muyu.cloud.market.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.cloud.market.domin.Customer;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.cloud.market.mapper
|
||||
* @Project:cloud-market
|
||||
* @name:InsideUseInterfaceMapper
|
||||
* @Date:2024/8/20 20:51
|
||||
*/
|
||||
@Mapper
|
||||
public interface InsideUseInterfaceMapper extends BaseMapper<Customer> {
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.muyu.cloud.market.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.cloud.market.domin.Customer;
|
||||
import com.muyu.cloud.market.domin.req.CustomerAddReq;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.cloud.market.service
|
||||
* @Project:cloud-market
|
||||
* @name:InsideUseInterfaceService
|
||||
* @Date:2024/8/20 20:45
|
||||
*/
|
||||
public interface InsideUseInterfaceService extends IService<Customer> {
|
||||
|
||||
/**
|
||||
* 添加客户信息
|
||||
*
|
||||
*/
|
||||
void add(CustomerAddReq customerAddReq);
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.muyu.cloud.market.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.cloud.market.domin.Customer;
|
||||
import com.muyu.cloud.market.domin.req.CustomerAddReq;
|
||||
import com.muyu.cloud.market.mapper.InsideUseInterfaceMapper;
|
||||
import com.muyu.cloud.market.service.InsideUseInterfaceService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.cloud.market.service.impl
|
||||
* @Project:cloud-market
|
||||
* @name:InsideUseInterfaceServiceImpl
|
||||
* @Date:2024/8/20 20:45
|
||||
*/
|
||||
@Service
|
||||
public class InsideUseInterfaceServiceImpl extends ServiceImpl<InsideUseInterfaceMapper, Customer> implements InsideUseInterfaceService {
|
||||
|
||||
/**
|
||||
* 内部使用持久层
|
||||
*/
|
||||
@Autowired
|
||||
private InsideUseInterfaceMapper insideUseInterfaceMapper;
|
||||
|
||||
/**
|
||||
* 添加客户信息
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void add(CustomerAddReq customerAddReq) {
|
||||
Customer customer = new Customer();
|
||||
//从身份证中截取出出生日期
|
||||
if (customerAddReq.getIdCard().length()!=18){
|
||||
|
||||
}
|
||||
String birthday = customerAddReq.getIdCard().substring(6, 14);
|
||||
String birthday1=birthday.substring(0, 4) + '-' + birthday.substring(4, 6) + '-' + birthday.substring(6);
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
//如果转化过程中出现异常,需要捕捉ParseException并进行处理
|
||||
try {
|
||||
Date birthday2 = simpleDateFormat.parse(birthday1);
|
||||
customer.setBirthday(birthday2);
|
||||
}catch (ParseException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
customer.setName(customerAddReq.getName());
|
||||
customer.setGender(customerAddReq.getGender());
|
||||
customer.setIdCard(customerAddReq.getIdCard());
|
||||
customer.setTel(customer.getTel());
|
||||
customer.setAddress(customerAddReq.getAddress());
|
||||
customer.setCredit(customer.getCredit());
|
||||
customer.setEmail(customer.getEmail());
|
||||
insideUseInterfaceMapper.insert(customer);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue