Browse Source

企业相关

master
DX 3 days ago
parent
commit
848b8e622d
  1. 1
      ruoyi-admin/pom.xml
  2. 1
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/app/EnterpriseController.java
  3. 4
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
  4. 30
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/MinioController.java
  5. 17
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/EnterprisesController.java
  6. 5
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
  7. 9
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java
  8. 12
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java
  9. 42
      ruoyi-framework/src/main/java/com/ruoyi/framework/mybatis/handler/CustomMetaObjectHandler.java
  10. 45
      ruoyi-system/src/main/java/com/ruoyi/system/domain/EnterpriseQualification.java
  11. 113
      ruoyi-system/src/main/java/com/ruoyi/system/domain/Enterprises.java
  12. 20
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/EnterprisesQualificationMapper.java
  13. 8
      ruoyi-system/src/main/java/com/ruoyi/system/service/IEnterpriseQualificationService.java
  14. 4
      ruoyi-system/src/main/java/com/ruoyi/system/service/IEnterprisesService.java
  15. 11
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EnterpriseQualificationServiceImpl.java
  16. 20
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EnterprisesServiceImpl.java
  17. 21
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java

1
ruoyi-admin/pom.xml

@ -21,6 +21,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional> <!-- 表示依赖不会传递 -->
</dependency>

1
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));
}

4
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 是否删除
*/

30
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<MultipartFile> files) {
List<String> 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);
}
/**
* 下载文件
*/

17
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<Enterprises> 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));
}

5
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("操作成功");
}

9
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;
/** 备注 */

12
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;
}
}

42
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";
}
}
}

45
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;
}

113
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();
}
}

20
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<EnterpriseQualification>
{
}

8
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<EnterpriseQualification> {
}

4
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<Enterprises>
{
/**
* 查询企业

11
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<EnterprisesQualificationMapper, EnterpriseQualification> implements IEnterpriseQualificationService {
}

20
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<EnterprisesMapper, Enterprises> 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);
}
/**

21
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<UserAuditLog> 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);
}
}
}

Loading…
Cancel
Save