Commit ab0810fd authored by 王飞's avatar 王飞

Merge branch 'gaixiankang' into 'dev'

用户照片存储-使用websocket实现服务端->客户端交互

See merge request !69
parents 77a664da 41eb0b8c
......@@ -61,7 +61,11 @@
<artifactId>itext-asian</artifactId>
<version>5.2.0</version>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-framework</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
</project>
package com.ruoyi.domain;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* 用户照片存储对象 t_user_photo_storage
*
* @author gxk
* @date 2024-01-29
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "用户照片存储")
@TableName(value = "t_user_photo_storage")
public class UserPhotoStorage
{
/** 主键 */
@TableId(type = IdType.ASSIGN_ID)
@JsonFormat(shape = JsonFormat.Shape.STRING)
@ApiModelProperty("ID")
private Long id;
/** 用户id */
@ApiModelProperty("用户ID")
private Long userId;
/** 用户账号 */
@ApiModelProperty("用户账号")
private String username;
/** 图片路径 */
@ApiModelProperty("图片路径")
private String path;
/** 创建时间 */
@ApiModelProperty("创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/** 逻辑删除标记 */
@ApiModelProperty("逻辑删除标记(0-存在、1-删除)")
@TableField(fill = FieldFill.INSERT)
private Integer deleted;
}
......@@ -23,11 +23,10 @@ public interface AutomobileEnterpriseMapper extends BaseMapper<AutomobileEnterpr
* @return 车企信息
*/
public AutomobileEnterprise selectAutomobileEnterpriseById(Long id);
/**
* 查询车企信息列表
*
* @param automobileEnterprise 车企信息
* @param request 车企信息
* @return 车企信息集合
*/
public List<AutomobileEnterprise> selectAutomobileEnterpriseList(AutomobileEnterpriseListRequest request);
......
package com.ruoyi.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.domain.UserPhotoStorage;
import com.ruoyi.web.request.UserPhotoStorageListRequest;
import org.springframework.stereotype.Repository;
/**
* 用户照片存储Mapper接口
*
* @author gxk
* @date 2024-01-29
*/
@Repository
public interface UserPhotoStorageMapper extends BaseMapper<UserPhotoStorage>
{
/**
* 查询用户照片存储列表
*
* @param request 用户照片存储
* @return 用户照片存储集合
*/
public List<UserPhotoStorage> selectUserPhotoStorageList(UserPhotoStorageListRequest request);
/**
* 新增用户照片存储
*
* @param userPhotoStorage 用户照片存储
* @return 结果
*/
public int insertUserPhotoStorage(UserPhotoStorage userPhotoStorage);
/**
* 修改用户照片存储
*
* @param userPhotoStorage 用户照片存储
* @return 结果
*/
public int updateUserPhotoStorage(UserPhotoStorage userPhotoStorage);
}
package com.ruoyi.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.domain.UserPhotoStorage;
import com.ruoyi.web.request.UserPhotoStorageCreateRequest;
import com.ruoyi.web.request.UserPhotoStorageListRequest;
/**
* 用户照片存储Service接口
*
* @author gxk
* @date 2024-01-29
*/
public interface UserPhotoStorageService extends IService<UserPhotoStorage>
{
/**
* 查询用户照片存储列表
*
* @param request 用户照片存储
* @return 用户照片存储集合
*/
public List<UserPhotoStorage> selectUserPhotoStorageList(UserPhotoStorageListRequest request);
/**
* 新增用户照片存储
*
* @param request 用户照片存储
* @return 结果
*/
public int insertUserPhotoStorage(UserPhotoStorageCreateRequest request);
/**
* 修改用户照片存储
*
* @param userPhotoStorage 用户照片存储
* @return 结果
*/
public int updateUserPhotoStorage(UserPhotoStorage userPhotoStorage);
}
package com.ruoyi.service.impl;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.websocket.WebSocketUsers;
import com.ruoyi.service.UserPhotoStorageService;
import com.ruoyi.web.request.UserPhotoStorageCreateRequest;
import com.ruoyi.web.request.UserPhotoStorageListRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.mapper.UserPhotoStorageMapper;
import com.ruoyi.domain.UserPhotoStorage;
import org.springframework.transaction.annotation.Transactional;
/**
* 用户照片存储Service业务层处理
*
* @author gxk
* @date 2024-01-29
*/
@Service
@Transactional
public class UserPhotoStorageServiceImpl extends ServiceImpl<UserPhotoStorageMapper, UserPhotoStorage> implements UserPhotoStorageService
{
@Autowired
private UserPhotoStorageMapper userPhotoStorageMapper;
/**
* 查询用户照片存储列表
*
* @param request 用户照片存储
* @return 用户照片存储
*/
@Override
public List<UserPhotoStorage> selectUserPhotoStorageList(UserPhotoStorageListRequest request)
{
return userPhotoStorageMapper.selectUserPhotoStorageList(request);
}
/**
* 新增用户照片存储
*
* @param request 用户照片存储
* @return 结果
*/
@Override
public int insertUserPhotoStorage(UserPhotoStorageCreateRequest request)
{
LoginUser loginUser = SecurityUtils.getLoginUser();
UserPhotoStorage userPhotoStorage = UserPhotoStorage.builder()
.userId(loginUser.getUserId())
.username(loginUser.getUsername())
.path(request.getPath())
.createTime(DateUtils.getNowDate())
.build();
WebSocketUsers.sendMessageToUserByUserId(loginUser.getUserId(), request.getPath());
return userPhotoStorageMapper.insert(userPhotoStorage);
}
/**
* 修改用户照片存储
*
* @param userPhotoStorage 用户照片存储
* @return 结果
*/
@Override
public int updateUserPhotoStorage(UserPhotoStorage userPhotoStorage)
{
return userPhotoStorageMapper.updateUserPhotoStorage(userPhotoStorage);
}
}
package com.ruoyi.web;
import java.util.Arrays;
import java.util.List;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.service.UserPhotoStorageService;
import com.ruoyi.web.request.UserPhotoStorageCreateRequest;
import com.ruoyi.web.request.UserPhotoStorageEditRequest;
import com.ruoyi.web.request.UserPhotoStorageListRequest;
import com.ruoyi.web.request.UserPhotoStorageRemoveRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.UserPhotoStorage;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 用户照片存储Controller
*
* @author gxk
* @date 2024-01-29
*/
@Api(tags = "用户照片存储")
@RestController
@RequestMapping("/review/storage")
public class UserPhotoStorageController extends BaseController
{
@Autowired
private UserPhotoStorageService userPhotoStorageService;
/**
* 查询用户照片存储列表
*/
@Anonymous
@ApiOperation("分页查询照片存储列表")
@PostMapping("/list")
public TableDataInfo<UserPhotoStorage> list(@Validated @RequestBody UserPhotoStorageListRequest request)
{
startPage();
List<UserPhotoStorage> list = userPhotoStorageService.selectUserPhotoStorageList(request);
return getDataTable(list);
}
/**
* 新增用户照片存储
*/
@Anonymous
@ApiOperation("新增用户照片存储")
@Log(title = "用户照片存储", businessType = BusinessType.INSERT)
@PostMapping("/create")
public R<Integer> create(@Validated @RequestBody UserPhotoStorageCreateRequest request)
{
return R.ok(userPhotoStorageService.insertUserPhotoStorage(request));
}
/**
* 修改用户照片存储
*/
@ApiOperation("修改用户照片存储")
@Log(title = "用户照片存储", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
public R<Boolean> edit(@Validated @RequestBody UserPhotoStorageEditRequest request)
{
UserPhotoStorage userPhotoStorage = UserPhotoStorage.builder()
.id(request.getId())
.path(request.getPath()).build();
return R.ok(userPhotoStorageService.updateById(userPhotoStorage));
}
/**
* 删除用户照片存储
*/
@ApiOperation("批量删除用户照片存储")
@Log(title = "用户照片存储", businessType = BusinessType.DELETE)
@PostMapping("/remove")
public R<Boolean> remove(@Validated @RequestBody UserPhotoStorageRemoveRequest request)
{
return R.ok(userPhotoStorageService.removeBatchByIds(Arrays.asList(request.getIds())));
}
}
package com.ruoyi.web.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* 用户照片存储新增所需的对象
* @author gxk
*/
@Data
@ApiModel
public class UserPhotoStorageCreateRequest {
/** 图片路径(以逗号分隔) */
@ApiModelProperty("图片路径")
@NotEmpty(message = "图片路径不能为空")
@NotNull(message = "图片路径不能为空")
private String path;
}
package com.ruoyi.web.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* 用户照片存储修改所需的对象
* @author gxk
*/
@Data
@ApiModel
public class UserPhotoStorageEditRequest {
@ApiModelProperty("ID")
@NotNull(message = "ID不能为空")
private Long id;
@ApiModelProperty("图片路径")
@NotEmpty(message = "路径不能为空")
@NotNull(message = "路径不能为空")
private String path;
}
package com.ruoyi.web.request;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.page.PageDomain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* 用户照片存储集合所需的对象
* @author gxk
*/
@Data
@ApiModel
public class UserPhotoStorageListRequest extends PageDomain {
/** 用户id */
@ApiModelProperty("用户ID")
private Long userId;
/** 用户账号 */
@ApiModelProperty("用户账号")
private String username;
}
package com.ruoyi.web.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* 用户照片存储删除所需的对象
* @author gxk
*/
@Data
@ApiModel
public class UserPhotoStorageRemoveRequest {
@ApiModelProperty("照片存储ID集合")
@NotEmpty(message = "照片存储ID集合不能为空")
@NotNull(message = "照片存储ID集合不能为空")
private Long[] ids;
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.mapper.UserPhotoStorageMapper">
<resultMap type="com.ruoyi.domain.UserPhotoStorage" id="UserPhotoStorageResult">
<result property="id" column="id" />
<result property="userId" column="user_id" />
<result property="username" column="username" />
<result property="path" column="path" />
<result property="createTime" column="create_time" />
<result property="deleted" column="deleted" />
</resultMap>
<sql id="selectUserPhotoStorageVo">
select id, user_id, username, path, create_time, deleted from t_user_photo_storage
</sql>
<select id="selectUserPhotoStorageList" parameterType="com.ruoyi.domain.UserPhotoStorage" resultMap="UserPhotoStorageResult">
<include refid="selectUserPhotoStorageVo"/>
<where>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="username != null and username != ''"> and username like concat('%', #{username}, '%')</if>
</where>
</select>
<insert id="insertUserPhotoStorage" parameterType="com.ruoyi.domain.UserPhotoStorage">
insert into t_user_photo_storage
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="userId != null">user_id,</if>
<if test="username != null">username,</if>
<if test="path != null">path,</if>
<if test="createTime != null">create_time,</if>
<if test="deleted != null">deleted,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="userId != null">#{userId},</if>
<if test="username != null">#{username},</if>
<if test="path != null">#{path},</if>
<if test="createTime != null">#{createTime},</if>
<if test="deleted != null">#{deleted},</if>
</trim>
</insert>
<update id="updateUserPhotoStorage" parameterType="com.ruoyi.domain.UserPhotoStorage">
update t_user_photo_storage
<trim prefix="SET" suffixOverrides=",">
<if test="userId != null">user_id = #{userId},</if>
<if test="username != null">username = #{username},</if>
<if test="path != null">path = #{path},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="deleted != null">deleted = #{deleted},</if>
</trim>
where id = #{id}
</update>
</mapper>
......@@ -59,11 +59,6 @@
<artifactId>ruoyi-system</artifactId>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>quality-review</artifactId>
</dependency>
<!-- skywalking log -->
<dependency>
<groupId>org.apache.skywalking</groupId>
......@@ -79,4 +74,4 @@
</dependencies>
</project>
\ No newline at end of file
</project>
......@@ -22,7 +22,7 @@ import com.ruoyi.framework.security.handle.LogoutSuccessHandlerImpl;
/**
* spring security配置
*
*
* @author ruoyi
*/
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
......@@ -33,7 +33,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
*/
@Autowired
private UserDetailsService userDetailsService;
/**
* 认证失败处理类
*/
......@@ -51,7 +51,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
*/
@Autowired
private JwtAuthenticationTokenFilter authenticationTokenFilter;
/**
* 跨域过滤器
*/
......@@ -114,7 +114,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
.antMatchers("/login", "/register", "/captchaImage").permitAll()
// 静态资源,可匿名访问
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
.antMatchers("/swagger-ui.html", "/websocket/**", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
// 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated()
.and()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment