改变成为Builder的方式
parent
7342e9822a
commit
7b135d597c
|
@ -3,11 +3,11 @@ package com.fate.firm.domain;
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import com.fate.common.core.annotation.Excel;
|
import com.fate.common.core.annotation.Excel;
|
||||||
import com.fate.common.core.web.domain.BaseEntity;
|
import com.fate.common.core.web.domain.BaseEntity;
|
||||||
import lombok.AllArgsConstructor;
|
import com.fate.firm.domain.request.FirmRequest;
|
||||||
import lombok.Data;
|
import lombok.*;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ import java.util.Date;
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@TableName("t_firm")
|
@TableName("t_firm")
|
||||||
public class Firm extends BaseEntity {
|
public class Firm extends BaseEntity {
|
||||||
|
@ -72,4 +73,18 @@ public class Firm extends BaseEntity {
|
||||||
@TableField("remark")
|
@TableField("remark")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
public static Firm addReqBuild(FirmRequest firmRequest){
|
||||||
|
return Firm.builder()
|
||||||
|
.firmName(firmRequest.getFirmName())
|
||||||
|
.firmAddress(firmRequest.getFirmAddress())
|
||||||
|
.firmPhone(firmRequest.getFirmPhone())
|
||||||
|
.firmStaus(firmRequest.getFirmStaus())
|
||||||
|
.firmRight(firmRequest.getFirmRight())
|
||||||
|
.createBy(firmRequest.getCreateBy())
|
||||||
|
.createTime(firmRequest.getCreateTime())
|
||||||
|
.updateBy(firmRequest.getUpdateBy())
|
||||||
|
.updateTime(firmRequest.getUpdateTime())
|
||||||
|
.remark(firmRequest.getRemark())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
package com.fate.firm.domain.request;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.fate.common.core.annotation.Excel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: TODO
|
||||||
|
* @author: SIKADI
|
||||||
|
* @date: 2023/11/20 19:14
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class FirmRequest {
|
||||||
|
|
||||||
|
@Excel(name = "企业名称")
|
||||||
|
@TableField("firm_name")
|
||||||
|
@NotEmpty(message = "企业名称不能为空")
|
||||||
|
private String firmName;
|
||||||
|
|
||||||
|
@Excel(name = "企业地址")
|
||||||
|
@TableField("firm_address")
|
||||||
|
@NotEmpty(message = "企业地址不能为空")
|
||||||
|
private String firmAddress;
|
||||||
|
|
||||||
|
@Excel(name = "企业电话")
|
||||||
|
@TableField("firm_phone")
|
||||||
|
@NotEmpty(message = "企业电话不能为空")
|
||||||
|
private String firmPhone;
|
||||||
|
|
||||||
|
@Excel(name = "企业类型")
|
||||||
|
@TableField("firm_right")
|
||||||
|
private Integer firmRight;
|
||||||
|
|
||||||
|
@Excel(name = "企业状态")
|
||||||
|
@TableField("firm_staus")
|
||||||
|
private Integer firmStaus;
|
||||||
|
|
||||||
|
@Excel(name = "创建人")
|
||||||
|
@TableField("create_by")
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
@Excel(name = "创建时间")
|
||||||
|
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@Excel(name = "修改人")
|
||||||
|
@TableField("update_by")
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
@Excel(name = "修改时间")
|
||||||
|
@TableField(value = "update_time", fill = FieldFill.INSERT)
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
@Excel(name = "备注")
|
||||||
|
@TableField("remark")
|
||||||
|
private String remark;
|
||||||
|
}
|
|
@ -6,9 +6,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.fate.common.core.domain.Result;
|
import com.fate.common.core.domain.Result;
|
||||||
import com.fate.common.core.web.controller.BaseController;
|
import com.fate.common.core.web.controller.BaseController;
|
||||||
import com.fate.firm.domain.Firm;
|
import com.fate.firm.domain.Firm;
|
||||||
|
import com.fate.firm.domain.request.FirmRequest;
|
||||||
import com.fate.firm.service.FirmService;
|
import com.fate.firm.service.FirmService;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
@ -42,9 +44,9 @@ public class FirmController extends BaseController {
|
||||||
* @return: com.fate.common.core.domain.Result
|
* @return: com.fate.common.core.domain.Result
|
||||||
**/
|
**/
|
||||||
@PostMapping("/addFirm")
|
@PostMapping("/addFirm")
|
||||||
public Result addFirm(@RequestBody Firm firm) {
|
public Result addFirm(@RequestBody @Validated FirmRequest firmRequest) {
|
||||||
log.info("功能:添加企业入驻,URI:{},方法:{},参数:{}", request.getRequestURI(), request.getMethod(), JSON.toJSONString(firm));
|
log.info("功能:添加企业入驻,URI:{},方法:{},参数:{}", request.getRequestURI(), request.getMethod(), JSON.toJSONString(firmRequest));
|
||||||
Result result = firmService.addFirm(firm);
|
Result result = firmService.addFirm(Firm.addReqBuild(firmRequest));
|
||||||
log.info("功能:查询我的公司,URI:{},方法:{},响应:{}", request.getRequestURI(), request.getMethod(), JSON.toJSONString(result.getData()));
|
log.info("功能:查询我的公司,URI:{},方法:{},响应:{}", request.getRequestURI(), request.getMethod(), JSON.toJSONString(result.getData()));
|
||||||
return Result.success("成功");
|
return Result.success("成功");
|
||||||
}
|
}
|
||||||
|
@ -58,9 +60,9 @@ public class FirmController extends BaseController {
|
||||||
* @return: com.fate.common.core.domain.Result
|
* @return: com.fate.common.core.domain.Result
|
||||||
**/
|
**/
|
||||||
@PostMapping("/updateFirm")
|
@PostMapping("/updateFirm")
|
||||||
public Result updateLL(@RequestBody Firm firm) {
|
public Result updateLL(@RequestBody @Validated FirmRequest firmRequest) {
|
||||||
log.info("功能:修改信息,URI:{},方法:{},参数:{}", request.getRequestURI(), request.getMethod(), JSON.toJSONString(firm));
|
log.info("功能:修改信息,URI:{},方法:{},参数:{}", request.getRequestURI(), request.getMethod(), JSON.toJSONString(firmRequest));
|
||||||
Result result = firmService.updateFirm(firm);
|
Result result = firmService.updateFirm(Firm.addReqBuild(firmRequest));
|
||||||
log.info("功能:修改信息,URI:{},方法:{},参数:{}", request.getRequestURI(), request.getMethod(), JSON.toJSONString(result.getData()));
|
log.info("功能:修改信息,URI:{},方法:{},参数:{}", request.getRequestURI(), request.getMethod(), JSON.toJSONString(result.getData()));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -74,9 +76,9 @@ public class FirmController extends BaseController {
|
||||||
* @return: com.fate.common.core.domain.Result
|
* @return: com.fate.common.core.domain.Result
|
||||||
**/
|
**/
|
||||||
@PostMapping("/updateStatus")
|
@PostMapping("/updateStatus")
|
||||||
public Result updateStatus(@RequestBody Firm firm) {
|
public Result updateStatus(@RequestBody @Validated FirmRequest firm) {
|
||||||
log.info("功能:修改状态,URI:{},方法:{},参数:{}", request.getRequestURI(), request.getMethod(), JSON.toJSONString(firm));
|
log.info("功能:修改状态,URI:{},方法:{},参数:{}", request.getRequestURI(), request.getMethod(), JSON.toJSONString(firm));
|
||||||
Result result = firmService.updateStatus(firm);
|
Result result = firmService.updateStatus(Firm.addReqBuild(firm));
|
||||||
log.info("功能:修改状态,URI:{},方法:{},响应:{}", request.getRequestURI(), request.getMethod(), JSON.toJSONString(firm));
|
log.info("功能:修改状态,URI:{},方法:{},响应:{}", request.getRequestURI(), request.getMethod(), JSON.toJSONString(firm));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue