feat():增加内部新增功能接口

dev2
WeiRan 2024-08-21 00:58:48 +08:00
parent 01a6ad1abb
commit 9a1a0be010
7 changed files with 208 additions and 10 deletions

View File

@ -1,9 +1,9 @@
package com.muyu.cloud.market.domin; package com.muyu.cloud.market.domin;
import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.muyu.common.core.web.domain.BaseEntity; import com.muyu.common.core.web.domain.BaseEntity;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@ -23,6 +23,7 @@ import java.util.Date;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor
@SuperBuilder @SuperBuilder
@TableName(value = "",autoResultMap = true) @TableName(value = "",autoResultMap = true)
public class Customer extends BaseEntity { 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; private Date birthday;
/** /**
* *

View File

@ -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;
/**
* @Authorweiran
* @Packagecom.muyu.cloud.market.domin.req
* @Projectcloud-market
* @nameCustomerAddReq
* @Date2024/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;
}

View File

@ -56,15 +56,6 @@ public class FindCustomerMeaasgeController {
return Result.success(findCustomerMeaasgeService.findListByuserPhone(tel)); return Result.success(findCustomerMeaasgeService.findListByuserPhone(tel));
} }
/**
*
* @return
*/
@PostMapping
@Operation(summary = "查询客户信息",description = "根据手机号查询客户信息")
public Result addCustomerMessage(){
}

View File

@ -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;
/**
* @Authorweiran
* @Packagecom.muyu.cloud.market.controller
* @Projectcloud-market
* @nameInsideUseInterfaceController
* @Date2024/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,"操作成功");
}
}

View File

@ -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;
/**
* @Authorweiran
* @Packagecom.muyu.cloud.market.mapper
* @Projectcloud-market
* @nameInsideUseInterfaceMapper
* @Date2024/8/20 20:51
*/
@Mapper
public interface InsideUseInterfaceMapper extends BaseMapper<Customer> {
}

View File

@ -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;
/**
* @Authorweiran
* @Packagecom.muyu.cloud.market.service
* @Projectcloud-market
* @nameInsideUseInterfaceService
* @Date2024/8/20 20:45
*/
public interface InsideUseInterfaceService extends IService<Customer> {
/**
*
*
*/
void add(CustomerAddReq customerAddReq);
}

View File

@ -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;
/**
* @Authorweiran
* @Packagecom.muyu.cloud.market.service.impl
* @Projectcloud-market
* @nameInsideUseInterfaceServiceImpl
* @Date2024/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);
}
}