From 37cb4ca71501015d6a6c57f055f6c11a07955f4e Mon Sep 17 00:00:00 2001 From: "JinLu.Yin" <411641505@qq.com> Date: Fri, 6 May 2022 22:14:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AE=A1=E7=90=86=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mes/md/controller/MdClientController.java | 129 +++++++ .../java/com/ktg/mes/md/domain/MdClient.java | 361 ++++++++++++++++++ .../com/ktg/mes/md/mapper/MdClientMapper.java | 83 ++++ .../ktg/mes/md/service/IMdClientService.java | 67 ++++ .../md/service/impl/MdClientServiceImpl.java | 130 +++++++ .../resources/mapper/md/MdClientMapper.xml | 197 ++++++++++ 6 files changed, 967 insertions(+) create mode 100644 ktg-mes/src/main/java/com/ktg/mes/md/controller/MdClientController.java create mode 100644 ktg-mes/src/main/java/com/ktg/mes/md/domain/MdClient.java create mode 100644 ktg-mes/src/main/java/com/ktg/mes/md/mapper/MdClientMapper.java create mode 100644 ktg-mes/src/main/java/com/ktg/mes/md/service/IMdClientService.java create mode 100644 ktg-mes/src/main/java/com/ktg/mes/md/service/impl/MdClientServiceImpl.java create mode 100644 ktg-mes/src/main/resources/mapper/md/MdClientMapper.xml diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/controller/MdClientController.java b/ktg-mes/src/main/java/com/ktg/mes/md/controller/MdClientController.java new file mode 100644 index 0000000..5b1c0c9 --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/md/controller/MdClientController.java @@ -0,0 +1,129 @@ +package com.ktg.mes.md.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import com.ktg.common.constant.UserConstants; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ktg.common.annotation.Log; +import com.ktg.common.core.controller.BaseController; +import com.ktg.common.core.domain.AjaxResult; +import com.ktg.common.enums.BusinessType; +import com.ktg.mes.md.domain.MdClient; +import com.ktg.mes.md.service.IMdClientService; +import com.ktg.common.utils.poi.ExcelUtil; +import com.ktg.common.core.page.TableDataInfo; + +/** + * 客户Controller + * + * @author yinjinlu + * @date 2022-05-06 + */ +@RestController +@RequestMapping("/md/client") +public class MdClientController extends BaseController +{ + @Autowired + private IMdClientService mdClientService; + + /** + * 查询客户列表 + */ + @PreAuthorize("@ss.hasPermi('md:client:list')") + @GetMapping("/list") + public TableDataInfo list(MdClient mdClient) + { + startPage(); + List list = mdClientService.selectMdClientList(mdClient); + return getDataTable(list); + } + + /** + * 导出客户列表 + */ + @PreAuthorize("@ss.hasPermi('md:client:export')") + @Log(title = "客户", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, MdClient mdClient) + { + List list = mdClientService.selectMdClientList(mdClient); + ExcelUtil util = new ExcelUtil(MdClient.class); + util.exportExcel(response, list, "客户数据"); + } + + /** + * 获取客户详细信息 + */ + @PreAuthorize("@ss.hasPermi('md:client:query')") + @GetMapping(value = "/{clientId}") + public AjaxResult getInfo(@PathVariable("clientId") Long clientId) + { + return AjaxResult.success(mdClientService.selectMdClientByClientId(clientId)); + } + + /** + * 新增客户 + */ + @PreAuthorize("@ss.hasPermi('md:client:add')") + @Log(title = "客户", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody MdClient mdClient) + { + if(UserConstants.NOT_UNIQUE.equals(mdClientService.checkClientCodeUnique(mdClient))){ + return AjaxResult.error("客户编码已存在!"); + } + + if(UserConstants.NOT_UNIQUE.equals(mdClientService.checkClientNameUnique(mdClient))){ + return AjaxResult.error("客户名称已存在!"); + } + + if(UserConstants.NOT_UNIQUE.equals(mdClientService.checkClientNickUnique(mdClient))){ + return AjaxResult.error("客户简称已存在!"); + } + + return toAjax(mdClientService.insertMdClient(mdClient)); + } + + /** + * 修改客户 + */ + @PreAuthorize("@ss.hasPermi('md:client:edit')") + @Log(title = "客户", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody MdClient mdClient) + { + if(UserConstants.NOT_UNIQUE.equals(mdClientService.checkClientCodeUnique(mdClient))){ + return AjaxResult.error("客户编码已存在!"); + } + + if(UserConstants.NOT_UNIQUE.equals(mdClientService.checkClientNameUnique(mdClient))){ + return AjaxResult.error("客户名称已存在!"); + } + + if(UserConstants.NOT_UNIQUE.equals(mdClientService.checkClientNickUnique(mdClient))){ + return AjaxResult.error("客户简称已存在!"); + } + return toAjax(mdClientService.updateMdClient(mdClient)); + } + + /** + * 删除客户 + */ + @PreAuthorize("@ss.hasPermi('md:client:remove')") + @Log(title = "客户", businessType = BusinessType.DELETE) + @DeleteMapping("/{clientIds}") + public AjaxResult remove(@PathVariable Long[] clientIds) + { + return toAjax(mdClientService.deleteMdClientByClientIds(clientIds)); + } +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/domain/MdClient.java b/ktg-mes/src/main/java/com/ktg/mes/md/domain/MdClient.java new file mode 100644 index 0000000..3799e79 --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/md/domain/MdClient.java @@ -0,0 +1,361 @@ +package com.ktg.mes.md.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ktg.common.annotation.Excel; +import com.ktg.common.core.domain.BaseEntity; + +/** + * 客户对象 md_client + * + * @author yinjinlu + * @date 2022-05-06 + */ +public class MdClient extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 客户ID */ + private Long clientId; + + /** 客户编码 */ + @Excel(name = "客户编码") + private String clientCode; + + /** 客户名称 */ + @Excel(name = "客户名称") + private String clientName; + + /** 客户简称 */ + @Excel(name = "客户简称") + private String clientNick; + + /** 客户英文名称 */ + @Excel(name = "客户英文名称") + private String clientEn; + + /** 客户简介 */ + @Excel(name = "客户简介") + private String clientDes; + + /** 客户LOGO地址 */ + @Excel(name = "客户LOGO地址") + private String clientLogo; + + /** 客户类型 */ + @Excel(name = "客户类型") + private String clientType; + + /** 客户地址 */ + @Excel(name = "客户地址") + private String address; + + /** 客户官网地址 */ + @Excel(name = "客户官网地址") + private String website; + + /** 客户邮箱地址 */ + @Excel(name = "客户邮箱地址") + private String email; + + /** 客户电话 */ + @Excel(name = "客户电话") + private String tel; + + /** 联系人1 */ + @Excel(name = "联系人1") + private String contact1; + + /** 联系人1-电话 */ + @Excel(name = "联系人1-电话") + private String contact1Tel; + + /** 联系人1-邮箱 */ + @Excel(name = "联系人1-邮箱") + private String contact1Email; + + /** 联系人2 */ + @Excel(name = "联系人2") + private String contact2; + + /** 联系人2-电话 */ + @Excel(name = "联系人2-电话") + private String contact2Tel; + + /** 联系人2-邮箱 */ + @Excel(name = "联系人2-邮箱") + private String contact2Email; + + /** 统一社会信用代码 */ + @Excel(name = "统一社会信用代码") + private String creditCode; + + /** 是否启用 */ + @Excel(name = "是否启用") + private String enableFlag; + + /** 预留字段1 */ + @Excel(name = "预留字段1") + private String attr1; + + /** 预留字段2 */ + private String attr2; + + /** 预留字段3 */ + private Long attr3; + + /** 预留字段4 */ + private Long attr4; + + public void setClientId(Long clientId) + { + this.clientId = clientId; + } + + public Long getClientId() + { + return clientId; + } + public void setClientCode(String clientCode) + { + this.clientCode = clientCode; + } + + public String getClientCode() + { + return clientCode; + } + public void setClientName(String clientName) + { + this.clientName = clientName; + } + + public String getClientName() + { + return clientName; + } + public void setClientNick(String clientNick) + { + this.clientNick = clientNick; + } + + public String getClientNick() + { + return clientNick; + } + public void setClientEn(String clientEn) + { + this.clientEn = clientEn; + } + + public String getClientEn() + { + return clientEn; + } + public void setClientDes(String clientDes) + { + this.clientDes = clientDes; + } + + public String getClientDes() + { + return clientDes; + } + public void setClientLogo(String clientLogo) + { + this.clientLogo = clientLogo; + } + + public String getClientLogo() + { + return clientLogo; + } + public void setClientType(String clientType) + { + this.clientType = clientType; + } + + public String getClientType() + { + return clientType; + } + public void setAddress(String address) + { + this.address = address; + } + + public String getAddress() + { + return address; + } + public void setWebsite(String website) + { + this.website = website; + } + + public String getWebsite() + { + return website; + } + public void setEmail(String email) + { + this.email = email; + } + + public String getEmail() + { + return email; + } + public void setTel(String tel) + { + this.tel = tel; + } + + public String getTel() + { + return tel; + } + public void setContact1(String contact1) + { + this.contact1 = contact1; + } + + public String getContact1() + { + return contact1; + } + public void setContact1Tel(String contact1Tel) + { + this.contact1Tel = contact1Tel; + } + + public String getContact1Tel() + { + return contact1Tel; + } + public void setContact1Email(String contact1Email) + { + this.contact1Email = contact1Email; + } + + public String getContact1Email() + { + return contact1Email; + } + public void setContact2(String contact2) + { + this.contact2 = contact2; + } + + public String getContact2() + { + return contact2; + } + public void setContact2Tel(String contact2Tel) + { + this.contact2Tel = contact2Tel; + } + + public String getContact2Tel() + { + return contact2Tel; + } + public void setContact2Email(String contact2Email) + { + this.contact2Email = contact2Email; + } + + public String getContact2Email() + { + return contact2Email; + } + public void setCreditCode(String creditCode) + { + this.creditCode = creditCode; + } + + public String getCreditCode() + { + return creditCode; + } + public void setEnableFlag(String enableFlag) + { + this.enableFlag = enableFlag; + } + + public String getEnableFlag() + { + return enableFlag; + } + public void setAttr1(String attr1) + { + this.attr1 = attr1; + } + + public String getAttr1() + { + return attr1; + } + public void setAttr2(String attr2) + { + this.attr2 = attr2; + } + + public String getAttr2() + { + return attr2; + } + public void setAttr3(Long attr3) + { + this.attr3 = attr3; + } + + public Long getAttr3() + { + return attr3; + } + public void setAttr4(Long attr4) + { + this.attr4 = attr4; + } + + public Long getAttr4() + { + return attr4; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("clientId", getClientId()) + .append("clientCode", getClientCode()) + .append("clientName", getClientName()) + .append("clientNick", getClientNick()) + .append("clientEn", getClientEn()) + .append("clientDes", getClientDes()) + .append("clientLogo", getClientLogo()) + .append("clientType", getClientType()) + .append("address", getAddress()) + .append("website", getWebsite()) + .append("email", getEmail()) + .append("tel", getTel()) + .append("contact1", getContact1()) + .append("contact1Tel", getContact1Tel()) + .append("contact1Email", getContact1Email()) + .append("contact2", getContact2()) + .append("contact2Tel", getContact2Tel()) + .append("contact2Email", getContact2Email()) + .append("creditCode", getCreditCode()) + .append("enableFlag", getEnableFlag()) + .append("remark", getRemark()) + .append("attr1", getAttr1()) + .append("attr2", getAttr2()) + .append("attr3", getAttr3()) + .append("attr4", getAttr4()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/mapper/MdClientMapper.java b/ktg-mes/src/main/java/com/ktg/mes/md/mapper/MdClientMapper.java new file mode 100644 index 0000000..cdbfc63 --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/md/mapper/MdClientMapper.java @@ -0,0 +1,83 @@ +package com.ktg.mes.md.mapper; + +import java.util.List; +import com.ktg.mes.md.domain.MdClient; + +/** + * 客户Mapper接口 + * + * @author yinjinlu + * @date 2022-05-06 + */ +public interface MdClientMapper +{ + /** + * 查询客户 + * + * @param clientId 客户主键 + * @return 客户 + */ + public MdClient selectMdClientByClientId(Long clientId); + + /** + * 查询客户列表 + * + * @param mdClient 客户 + * @return 客户集合 + */ + public List selectMdClientList(MdClient mdClient); + + /** + * 检查客户编码是否重复 + * @param mdClient + * @return + */ + public MdClient checkClientCodeUnique(MdClient mdClient); + + /** + * 检查客户名称是否重复 + * @param mdClient + * @return + */ + public MdClient checkClientNameUnique(MdClient mdClient); + + /** + * 检查客户简称是否重复 + * @param mdClient + * @return + */ + public MdClient checkClientNickUnique(MdClient mdClient); + + + /** + * 新增客户 + * + * @param mdClient 客户 + * @return 结果 + */ + public int insertMdClient(MdClient mdClient); + + /** + * 修改客户 + * + * @param mdClient 客户 + * @return 结果 + */ + public int updateMdClient(MdClient mdClient); + + /** + * 删除客户 + * + * @param clientId 客户主键 + * @return 结果 + */ + public int deleteMdClientByClientId(Long clientId); + + /** + * 批量删除客户 + * + * @param clientIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteMdClientByClientIds(Long[] clientIds); +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/service/IMdClientService.java b/ktg-mes/src/main/java/com/ktg/mes/md/service/IMdClientService.java new file mode 100644 index 0000000..de5e504 --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/md/service/IMdClientService.java @@ -0,0 +1,67 @@ +package com.ktg.mes.md.service; + +import java.util.List; +import com.ktg.mes.md.domain.MdClient; + +/** + * 客户Service接口 + * + * @author yinjinlu + * @date 2022-05-06 + */ +public interface IMdClientService +{ + /** + * 查询客户 + * + * @param clientId 客户主键 + * @return 客户 + */ + public MdClient selectMdClientByClientId(Long clientId); + + /** + * 查询客户列表 + * + * @param mdClient 客户 + * @return 客户集合 + */ + public List selectMdClientList(MdClient mdClient); + + public String checkClientCodeUnique(MdClient mdClient); + + public String checkClientNameUnique(MdClient mdClient); + + public String checkClientNickUnique(MdClient mdClient); + + /** + * 新增客户 + * + * @param mdClient 客户 + * @return 结果 + */ + public int insertMdClient(MdClient mdClient); + + /** + * 修改客户 + * + * @param mdClient 客户 + * @return 结果 + */ + public int updateMdClient(MdClient mdClient); + + /** + * 批量删除客户 + * + * @param clientIds 需要删除的客户主键集合 + * @return 结果 + */ + public int deleteMdClientByClientIds(Long[] clientIds); + + /** + * 删除客户信息 + * + * @param clientId 客户主键 + * @return 结果 + */ + public int deleteMdClientByClientId(Long clientId); +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/MdClientServiceImpl.java b/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/MdClientServiceImpl.java new file mode 100644 index 0000000..999b9d8 --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/MdClientServiceImpl.java @@ -0,0 +1,130 @@ +package com.ktg.mes.md.service.impl; + +import java.util.List; + +import com.ktg.common.constant.UserConstants; +import com.ktg.common.utils.DateUtils; +import com.ktg.common.utils.StringUtils; +import org.apache.catalina.User; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ktg.mes.md.mapper.MdClientMapper; +import com.ktg.mes.md.domain.MdClient; +import com.ktg.mes.md.service.IMdClientService; + +/** + * 客户Service业务层处理 + * + * @author yinjinlu + * @date 2022-05-06 + */ +@Service +public class MdClientServiceImpl implements IMdClientService +{ + @Autowired + private MdClientMapper mdClientMapper; + + /** + * 查询客户 + * + * @param clientId 客户主键 + * @return 客户 + */ + @Override + public MdClient selectMdClientByClientId(Long clientId) + { + return mdClientMapper.selectMdClientByClientId(clientId); + } + + /** + * 查询客户列表 + * + * @param mdClient 客户 + * @return 客户 + */ + @Override + public List selectMdClientList(MdClient mdClient) + { + return mdClientMapper.selectMdClientList(mdClient); + } + + @Override + public String checkClientCodeUnique(MdClient mdClient) { + MdClient client = mdClientMapper.checkClientCodeUnique(mdClient); + Long clientId = mdClient.getClientId()==null?-1L:mdClient.getClientId(); + if(StringUtils.isNotNull(client) && client.getClientId().longValue() !=clientId.longValue()){ + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + @Override + public String checkClientNameUnique(MdClient mdClient) { + MdClient client = mdClientMapper.checkClientNameUnique(mdClient); + Long clientId = mdClient.getClientId()==null?-1L:mdClient.getClientId(); + if(StringUtils.isNotNull(client) && client.getClientId().longValue() !=clientId.longValue()){ + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + @Override + public String checkClientNickUnique(MdClient mdClient) { + MdClient client = mdClientMapper.checkClientNickUnique(mdClient); + Long clientId = mdClient.getClientId()==null?-1L:mdClient.getClientId(); + if(StringUtils.isNotNull(client) && client.getClientId().longValue() !=clientId.longValue()){ + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 新增客户 + * + * @param mdClient 客户 + * @return 结果 + */ + @Override + public int insertMdClient(MdClient mdClient) + { + mdClient.setCreateTime(DateUtils.getNowDate()); + return mdClientMapper.insertMdClient(mdClient); + } + + /** + * 修改客户 + * + * @param mdClient 客户 + * @return 结果 + */ + @Override + public int updateMdClient(MdClient mdClient) + { + mdClient.setUpdateTime(DateUtils.getNowDate()); + return mdClientMapper.updateMdClient(mdClient); + } + + /** + * 批量删除客户 + * + * @param clientIds 需要删除的客户主键 + * @return 结果 + */ + @Override + public int deleteMdClientByClientIds(Long[] clientIds) + { + return mdClientMapper.deleteMdClientByClientIds(clientIds); + } + + /** + * 删除客户信息 + * + * @param clientId 客户主键 + * @return 结果 + */ + @Override + public int deleteMdClientByClientId(Long clientId) + { + return mdClientMapper.deleteMdClientByClientId(clientId); + } +} diff --git a/ktg-mes/src/main/resources/mapper/md/MdClientMapper.xml b/ktg-mes/src/main/resources/mapper/md/MdClientMapper.xml new file mode 100644 index 0000000..61d939a --- /dev/null +++ b/ktg-mes/src/main/resources/mapper/md/MdClientMapper.xml @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select client_id, client_code, client_name, client_nick, client_en, client_des, client_logo, client_type, address, website, email, tel, contact1, contact1_tel, contact1_email, contact2, contact2_tel, contact2_email, credit_code, enable_flag, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from md_client + + + + + + + + + + + + + + insert into md_client + + client_code, + client_name, + client_nick, + client_en, + client_des, + client_logo, + client_type, + address, + website, + email, + tel, + contact1, + contact1_tel, + contact1_email, + contact2, + contact2_tel, + contact2_email, + credit_code, + enable_flag, + remark, + attr1, + attr2, + attr3, + attr4, + create_by, + create_time, + update_by, + update_time, + + + #{clientCode}, + #{clientName}, + #{clientNick}, + #{clientEn}, + #{clientDes}, + #{clientLogo}, + #{clientType}, + #{address}, + #{website}, + #{email}, + #{tel}, + #{contact1}, + #{contact1Tel}, + #{contact1Email}, + #{contact2}, + #{contact2Tel}, + #{contact2Email}, + #{creditCode}, + #{enableFlag}, + #{remark}, + #{attr1}, + #{attr2}, + #{attr3}, + #{attr4}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update md_client + + client_code = #{clientCode}, + client_name = #{clientName}, + client_nick = #{clientNick}, + client_en = #{clientEn}, + client_des = #{clientDes}, + client_logo = #{clientLogo}, + client_type = #{clientType}, + address = #{address}, + website = #{website}, + email = #{email}, + tel = #{tel}, + contact1 = #{contact1}, + contact1_tel = #{contact1Tel}, + contact1_email = #{contact1Email}, + contact2 = #{contact2}, + contact2_tel = #{contact2Tel}, + contact2_email = #{contact2Email}, + credit_code = #{creditCode}, + enable_flag = #{enableFlag}, + remark = #{remark}, + attr1 = #{attr1}, + attr2 = #{attr2}, + attr3 = #{attr3}, + attr4 = #{attr4}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where client_id = #{clientId} + + + + delete from md_client where client_id = #{clientId} + + + + delete from md_client where client_id in + + #{clientId} + + + \ No newline at end of file