From 848b8e622dad4695c0e2b9602a8959982112f7be Mon Sep 17 00:00:00 2001 From: dx <1242347652@qq.com> Date: Fri, 17 Jan 2025 16:00:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=81=E4=B8=9A=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-admin/pom.xml | 1 + .../controller/app/EnterpriseController.java | 1 + .../controller/common/CommonController.java | 4 +- .../controller/common/MinioController.java | 30 ++++- .../system/EnterprisesController.java | 17 ++- .../controller/system/SysUserController.java | 5 +- .../ruoyi/common/core/domain/BaseEntity.java | 9 ++ .../framework/config/ApplicationConfig.java | 12 ++ .../handler/CustomMetaObjectHandler.java | 42 +++++++ .../domain/EnterpriseQualification.java | 45 +++++++ .../com/ruoyi/system/domain/Enterprises.java | 113 +----------------- .../EnterprisesQualificationMapper.java | 20 ++++ .../IEnterpriseQualificationService.java | 8 ++ .../system/service/IEnterprisesService.java | 4 +- .../EnterpriseQualificationServiceImpl.java | 11 ++ .../service/impl/EnterprisesServiceImpl.java | 20 +++- .../service/impl/SysUserServiceImpl.java | 21 +++- 17 files changed, 234 insertions(+), 129 deletions(-) create mode 100644 ruoyi-framework/src/main/java/com/ruoyi/framework/mybatis/handler/CustomMetaObjectHandler.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain/EnterpriseQualification.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/mapper/EnterprisesQualificationMapper.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/service/IEnterpriseQualificationService.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EnterpriseQualificationServiceImpl.java diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index 95022c7..b340fd4 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -21,6 +21,7 @@ org.springframework.boot spring-boot-devtools + runtime true diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app/EnterpriseController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app/EnterpriseController.java index 52778e0..61743ee 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app/EnterpriseController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app/EnterpriseController.java @@ -91,6 +91,7 @@ public class EnterpriseController extends BaseController{ @PutMapping public AjaxResult edit(@RequestBody Enterprises enterprises) { + log.info("enterprisesenterprises:{}", enterprises); return toAjax(enterprisesService.updateEnterprises(enterprises)); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java index cec5006..d58b107 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java @@ -23,7 +23,7 @@ import com.ruoyi.framework.config.ServerConfig; /** * 通用请求处理 - * + * * @author ruoyi */ @RestController @@ -39,7 +39,7 @@ public class CommonController /** * 通用下载请求 - * + * * @param fileName 文件名称 * @param delete 是否删除 */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/MinioController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/MinioController.java index 0f6fdf3..584a79a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/MinioController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/MinioController.java @@ -1,5 +1,6 @@ package com.ruoyi.web.controller.common; +import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.utils.MinioUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; @@ -7,9 +8,12 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; @RestController -@RequestMapping("/minio") +@RequestMapping("/common_file") public class MinioController { @Autowired @@ -19,18 +23,36 @@ public class MinioController { * 上传文件 */ @PostMapping("/upload") - public String uploadFile(@RequestParam("file") MultipartFile file) { + public AjaxResult uploadFile(@RequestParam("file") MultipartFile file) { String objectName = "uploads/" + System.currentTimeMillis() + "_" + file.getOriginalFilename(); - try (InputStream inputStream = file.getInputStream()) { minioUtils.uploadFile( objectName, inputStream, file.getSize(), file.getContentType()); } catch (Exception e) { throw new RuntimeException("文件上传失败", e); } + final String url = minioUtils.generateShortUrl(objectName); + return AjaxResult.success("上传成功", url); + } + + @PostMapping("/uploads") + public AjaxResult uploadMultipleFiles(@RequestParam("files") List files) { + List uploadedUrls = new ArrayList<>(); + for (MultipartFile file : files) { + String objectName = "uploads/" + System.currentTimeMillis() + "_" + file.getOriginalFilename(); + + try (InputStream inputStream = file.getInputStream()) { + minioUtils.uploadFile(objectName, inputStream, file.getSize(), file.getContentType()); + String shortUrl = minioUtils.generateShortUrl(objectName); + uploadedUrls.add(shortUrl); + } catch (Exception e) { + throw new RuntimeException("文件上传失败: " + file.getOriginalFilename(), e); + } + } - return minioUtils.generateShortUrl(objectName); + return AjaxResult.success("上传成功", uploadedUrls); } + /** * 下载文件 */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/EnterprisesController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/EnterprisesController.java index 2ef0ef5..c72cf0c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/EnterprisesController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/EnterprisesController.java @@ -3,11 +3,15 @@ package com.ruoyi.web.controller.system; import java.util.List; import javax.servlet.http.HttpServletResponse; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.system.domain.EnterpriseUsers; import com.ruoyi.system.domain.vo.EnterpriseUserInsertVo; import com.ruoyi.system.domain.vo.LabelValueVo; +import com.ruoyi.system.mapper.EnterprisesMapper; +import org.apache.ibatis.annotations.Param; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; @@ -37,6 +41,8 @@ public class EnterprisesController extends BaseController { @Autowired private IEnterprisesService enterprisesService; + @Autowired + private EnterprisesMapper enterprisesMapper; /** * 查询企业列表 @@ -61,6 +67,15 @@ public class EnterprisesController extends BaseController return success(list); } + @GetMapping("/getDetailByUserId") + public AjaxResult getDetail(@Param("userId") Long userId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Enterprises::getCreateBy, userId); + queryWrapper.eq(Enterprises::getDelFlag, 0); + Enterprises enterprises = enterprisesMapper.selectOne(queryWrapper); + return success(enterprises); + } + /** * 导出企业列表 */ @@ -101,7 +116,7 @@ public class EnterprisesController extends BaseController @PreAuthorize("@ss.hasPermi('system:enterprises:edit')") @Log(title = "企业", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@RequestBody Enterprises enterprises) + public AjaxResult edit(@Validated @RequestBody Enterprises enterprises) { return toAjax(enterprisesService.updateEnterprises(enterprises)); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java index deedc72..cae9f36 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java @@ -7,6 +7,7 @@ import javax.servlet.http.HttpServletResponse; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.ruoyi.system.domain.UserAuditLog; import com.ruoyi.system.service.*; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ArrayUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; @@ -39,6 +40,7 @@ import com.ruoyi.common.utils.poi.ExcelUtil; */ @RestController @RequestMapping("/system/user") +@Slf4j public class SysUserController extends BaseController { @Autowired @@ -99,7 +101,8 @@ public class SysUserController extends BaseController @PreAuthorize("@ss.hasPermi('system:user:audit')") @PutMapping("/auditUser") - public AjaxResult auditUser(SysUser user) { + public AjaxResult auditUser(@RequestBody SysUser user) { + log.info("useruseruseruser:{}", user); userService.auditUser(user); return success("操作成功"); } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java index 4874890..307b85f 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java @@ -5,11 +5,16 @@ import java.util.Date; import java.util.HashMap; import java.util.Map; +import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; +import org.springframework.data.annotation.CreatedBy; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedBy; +import org.springframework.data.annotation.LastModifiedDate; /** * Entity基类 @@ -27,17 +32,21 @@ public class BaseEntity implements Serializable private String searchValue; /** 创建者 */ + @TableField(fill = FieldFill.INSERT) // 创建时自动填充 private String createBy; /** 创建时间 */ + @TableField(fill = FieldFill.INSERT) // 创建时自动填充 @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date createTime; /** 更新者 */ + @TableField(fill = FieldFill.INSERT_UPDATE) // 创建和修改时自动填充 private String updateBy; /** 更新时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @TableField(fill = FieldFill.INSERT_UPDATE) // 创建和修改时自动填充 private Date updateTime; /** 备注 */ diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java index 1d4dc1f..41ba74a 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java @@ -1,6 +1,9 @@ package com.ruoyi.framework.config; import java.util.TimeZone; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.ObjectMapper; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; import org.springframework.context.annotation.Bean; @@ -27,4 +30,13 @@ public class ApplicationConfig { return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(TimeZone.getDefault()); } + + @Bean + public ObjectMapper objectMapper() { + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true); + objectMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); + return objectMapper; + } + } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/mybatis/handler/CustomMetaObjectHandler.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/mybatis/handler/CustomMetaObjectHandler.java new file mode 100644 index 0000000..627f0d3 --- /dev/null +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/mybatis/handler/CustomMetaObjectHandler.java @@ -0,0 +1,42 @@ +package com.ruoyi.framework.mybatis.handler; + +import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; +import com.ruoyi.common.utils.SecurityUtils; +import org.apache.ibatis.reflection.MetaObject; +import org.springframework.stereotype.Component; + +import java.util.Date; + +/** + * 自定义元对象处理器,用于自动填充创建和修改时间、用户 + */ +@Component +public class CustomMetaObjectHandler implements MetaObjectHandler { + + @Override + public void insertFill(MetaObject metaObject) { + // 创建时自动填充 + this.strictInsertFill(metaObject, "createTime", Date.class, new Date()); + this.strictInsertFill(metaObject, "createBy", String.class, getCurrentUsername()); + this.strictInsertFill(metaObject, "updateTime", Date.class, new Date()); + this.strictInsertFill(metaObject, "updateBy", String.class, getCurrentUsername()); + } + + @Override + public void updateFill(MetaObject metaObject) { + // 修改时自动填充 + this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date()); + this.strictUpdateFill(metaObject, "updateBy", String.class, getCurrentUsername()); + } + + /** + * 获取当前登录用户名 + */ + private String getCurrentUsername() { + try { + return SecurityUtils.getUsername(); + } catch (Exception e) { + return "unknown"; + } + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/EnterpriseQualification.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/EnterpriseQualification.java new file mode 100644 index 0000000..3627634 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/EnterpriseQualification.java @@ -0,0 +1,45 @@ +package com.ruoyi.system.domain; + +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 企业资质映 + * @TableName enterprise_qualification + */ +@Data +public class EnterpriseQualification extends BaseEntity implements Serializable { + /** + * 主键 + */ + private Long id; + + /** + * 企业ID + */ + private Long enterpriseId; + + /** + * 资质名称,例如:排污许可证、环保合格证 + */ + private String qualificationName; + + /** + * 资质到期日期 + */ + private Date expiryDate; + + /** + * 资质描述,详细说明资质信息 + */ + private String qualificationDescription; + /** + * 是否删除 + */ + private Boolean delFlag; + + private static final long serialVersionUID = 1L; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/Enterprises.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/Enterprises.java index cab3aea..0e801f9 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/Enterprises.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/Enterprises.java @@ -35,11 +35,11 @@ public class Enterprises extends BaseEntity /** 企业类型:1.大型、2.中型、3.小型、4.环保重点 */ @Excel(name = "企业类型:1.大型、2.中型、3.小型、4.环保重点") - private Integer type; + private String type; /** 企业所属区域:1.东区、2.西区、3.北区、4.南区 */ @Excel(name = "企业所属区域:1.东区、2.西区、3.北区、4.南区") - private Integer region; + private String region; /** 企业名称 */ @Excel(name = "企业名称") @@ -64,113 +64,4 @@ public class Enterprises extends BaseEntity /** 删除标志(0代表存在 2代表删除) */ private String delFlag; - - public void setId(Long id) - { - this.id = id; - } - - public Long getId() - { - return id; - } - public void setDepartmentId(Long departmentId) - { - this.departmentId = departmentId; - } - - public Long getDepartmentId() - { - return departmentId; - } - public void setUserId(Long userId) - { - this.userId = userId; - } - - public Long getUserId() - { - return userId; - } - public void setType(Integer type) - { - this.type = type; - } - - public Integer getType() - { - return type; - } - public void setRegion(Integer region) - { - this.region = region; - } - - public Integer getRegion() - { - return region; - } - public void setEnterprisesName(String enterprisesName) - { - this.enterprisesName = enterprisesName; - } - - public String getEnterprisesName() - { - return enterprisesName; - } - public void setAddress(String address) - { - this.address = address; - } - - public String getAddress() - { - return address; - } - public void setRegistrationNumber(String registrationNumber) - { - this.registrationNumber = registrationNumber; - } - - public String getRegistrationNumber() - { - return registrationNumber; - } - public void setIntroduction(String introduction) - { - this.introduction = introduction; - } - - public String getIntroduction() - { - return introduction; - } - public void setEstablishmentDate(Date establishmentDate) - { - this.establishmentDate = establishmentDate; - } - - public Date getEstablishmentDate() - { - return establishmentDate; - } - - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("departmentId", getDepartmentId()) - .append("userId", getUserId()) - .append("type", getType()) - .append("region", getRegion()) - .append("enterprisesName", getEnterprisesName()) - .append("address", getAddress()) - .append("registrationNumber", getRegistrationNumber()) - .append("introduction", getIntroduction()) - .append("establishmentDate", getEstablishmentDate()) - - .toString(); - } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/EnterprisesQualificationMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/EnterprisesQualificationMapper.java new file mode 100644 index 0000000..2a827e3 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/EnterprisesQualificationMapper.java @@ -0,0 +1,20 @@ +package com.ruoyi.system.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.system.domain.EnterpriseQualification; +import com.ruoyi.system.domain.Enterprises; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 企业Mapper接口 + * + * @author ruoyi + * @date 2025-01-08 + */ +@Mapper +public interface EnterprisesQualificationMapper extends BaseMapper +{ + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IEnterpriseQualificationService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IEnterpriseQualificationService.java new file mode 100644 index 0000000..1041093 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IEnterpriseQualificationService.java @@ -0,0 +1,8 @@ +package com.ruoyi.system.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.system.domain.EnterpriseQualification; +import com.ruoyi.system.domain.FileInfo; + +public interface IEnterpriseQualificationService extends IService { +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IEnterprisesService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IEnterprisesService.java index f54dc2d..5c8170e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/IEnterprisesService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IEnterprisesService.java @@ -1,6 +1,8 @@ package com.ruoyi.system.service; import java.util.List; + +import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.system.domain.Enterprises; import com.ruoyi.system.domain.vo.EnterpriseUserInsertVo; import com.ruoyi.system.domain.vo.LabelValueVo; @@ -11,7 +13,7 @@ import com.ruoyi.system.domain.vo.LabelValueVo; * @author ruoyi * @date 2025-01-08 */ -public interface IEnterprisesService +public interface IEnterprisesService extends IService { /** * 查询企业 diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EnterpriseQualificationServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EnterpriseQualificationServiceImpl.java new file mode 100644 index 0000000..7b39d75 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EnterpriseQualificationServiceImpl.java @@ -0,0 +1,11 @@ +package com.ruoyi.system.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.system.domain.EnterpriseQualification; +import com.ruoyi.system.mapper.EnterprisesQualificationMapper; +import com.ruoyi.system.service.IEnterpriseQualificationService; +import org.springframework.stereotype.Service; + +@Service +public class EnterpriseQualificationServiceImpl extends ServiceImpl implements IEnterpriseQualificationService { +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EnterprisesServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EnterprisesServiceImpl.java index 7972160..93d1a89 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EnterprisesServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EnterprisesServiceImpl.java @@ -4,19 +4,25 @@ import java.util.ArrayList; import java.util.List; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.system.domain.EnterpriseQualification; import com.ruoyi.system.domain.EnterpriseUsers; import com.ruoyi.system.domain.vo.EnterpriseUserInsertVo; import com.ruoyi.system.domain.vo.LabelValueVo; import com.ruoyi.system.mapper.EnterpriseUsersMapper; +import com.ruoyi.system.mapper.EnterprisesQualificationMapper; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.system.mapper.EnterprisesMapper; import com.ruoyi.system.domain.Enterprises; import com.ruoyi.system.service.IEnterprisesService; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.RequestBody; /** * 企业Service业务层处理 @@ -27,12 +33,14 @@ import org.springframework.transaction.annotation.Transactional; @Service @Slf4j -public class EnterprisesServiceImpl implements IEnterprisesService +public class EnterprisesServiceImpl extends ServiceImpl implements IEnterprisesService { @Autowired private EnterprisesMapper enterprisesMapper; @Autowired private EnterpriseUsersMapper enterpriseUsersMapper; + @Autowired + private IEnterprisesService iEnterprisesService; /** * 查询企业 @@ -78,10 +86,14 @@ public class EnterprisesServiceImpl implements IEnterprisesService * @return 结果 */ @Override - public int updateEnterprises(Enterprises enterprises) + public int updateEnterprises(@RequestBody Enterprises enterprises) { - enterprises.setUpdateTime(DateUtils.getNowDate()); - return enterprisesMapper.updateEnterprises(enterprises); + final Enterprises enterprises1 = enterprisesMapper.selectById(enterprises.getId()); + if (enterprises == null) { + throw new ServiceException("企业信息不存在"); + } + BeanUtils.copyProperties(enterprises, enterprises1); + return enterprisesMapper.updateById(enterprises1); } /** diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index 18cd8e3..3c17068 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -132,11 +132,22 @@ public class SysUserServiceImpl implements ISysUserService final int res = userMapper.updateUser(sysUser); if (res > 0) { - UserAuditLog userAuditLog = new UserAuditLog(); - userAuditLog.setUserId(sysUser.getUserId()); - userAuditLog.setContent(sysUser.getContent()); - userAuditLog.setStatus(sysUser.getAudit()); - userAuditLogService.save(userAuditLog); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("user_id", sysUser.getUserId()); + final UserAuditLog one = userAuditLogService.getOne(queryWrapper); + if (one == null) { + UserAuditLog userAuditLog = new UserAuditLog(); + userAuditLog.setUserId(sysUser.getUserId()); + userAuditLog.setContent(user.getContent()); + userAuditLog.setStatus(sysUser.getAudit()); + userAuditLogService.save(userAuditLog); + } else { + one.setStatus(sysUser.getAudit()); + one.setContent(user.getContent()); + userAuditLogService.update(one, queryWrapper); + } + + } }