APP首页轮播图

This commit is contained in:
cwchen 2024-08-21 16:32:21 +08:00
parent 8846b2c18c
commit 0da710f9a5
8 changed files with 236 additions and 1 deletions

View File

@ -97,6 +97,26 @@ public class TokenController
return R.ok();
}
@PostMapping("appLogout")
public R<?> appLogout(HttpServletRequest request) {
try{
String token = SecurityUtils.getToken(request);
if (StringUtils.isNotEmpty(token) && !SystemGlobal.undefined.equals(token.toLowerCase()))
{
String username = JwtUtils.getUserName(token);
String userId= JwtUtils.getUserId(token);
// 删除用户缓存记录
AuthUtil.logoutByToken(token);
// 记录用户退出日志
sysLoginService.logout(username,userId);
}
}catch (Exception e){
sysLoginService.logout("","");
log.error(e.toString(),e);
}
return R.ok();
}
@PostMapping("refresh")
public R<?> refresh(HttpServletRequest request)
{

View File

@ -0,0 +1,18 @@
package com.bonus.common.entity.app.vo;
import lombok.Data;
/**
* @className:IndexVo
* @author:cwchen
* @date:2024-08-21-16:04
* @version:1.0
* @description:首页-轮播图
*/
@Data
public class CarouseVo {
private String filePath;
private String base64Url;
}

View File

@ -0,0 +1,42 @@
package com.bonus.app.controller;
import com.bonus.app.service.IAppIndexService;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.entity.app.AppParamsDto;
import com.bonus.common.entity.app.vo.CarouseVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
* @className:AppIndexController
* @author:cwchen
* @date:2024-08-21-15:55
* @version:1.0
* @description:APP首页
*/
@RestController
@RequestMapping("/appIndex/")
@Slf4j
public class AppIndexController {
@Resource(name = "IAppIndexService")
private IAppIndexService service;
/**
* 首页轮播图
* @param dto
* @return AjaxResult
* @author cwchen
* @date 2024/8/21 16:03
*/
@GetMapping("carouselList")
public AjaxResult carouselList(AppParamsDto dto) {
List<CarouseVo> list = service.carouselList(dto);
return AjaxResult.success(list);
}
}

View File

@ -0,0 +1,26 @@
package com.bonus.app.mapper;
import com.bonus.common.entity.app.AppParamsDto;
import com.bonus.common.entity.app.vo.CarouseVo;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @className:AppIndexMapper
* @author:cwchen
* @date:2024-08-21-15:57
* @version:1.0
* @description:App首页
*/
@Repository(value = "AppIndexMapper")
public interface AppIndexMapper {
/**
* APP首页轮播图
* @param dto
* @return List<CarouseVo>
* @author cwchen
* @date 2024/8/21 16:10
*/
List<CarouseVo> carouselList(AppParamsDto dto);
}

View File

@ -0,0 +1,24 @@
package com.bonus.app.service;
import com.bonus.common.entity.app.AppParamsDto;
import com.bonus.common.entity.app.vo.CarouseVo;
import java.util.List;
/**
* @className:IAppIndexService
* @author:cwchen
* @date:2024-08-21-15:56
* @version:1.0
* @description:App首页
*/
public interface IAppIndexService {
/**
*
* @param dto
* @return List<CarouseVo>
* @author cwchen
* @date 2024/8/21 16:04
*/
List<CarouseVo> carouselList(AppParamsDto dto);
}

View File

@ -0,0 +1,95 @@
package com.bonus.app.service.impl;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.bonus.app.mapper.AppIndexMapper;
import com.bonus.app.service.IAppIndexService;
import com.bonus.common.core.constant.HttpStatus;
import com.bonus.common.core.constant.SecurityConstants;
import com.bonus.common.core.domain.R;
import com.bonus.common.core.utils.encryption.Sm4Utils;
import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.common.entity.app.AppParamsDto;
import com.bonus.common.entity.app.vo.CarouseVo;
import com.bonus.common.entity.bracelet.vo.PersonVo;
import com.bonus.system.api.RemoteFileService;
import com.bonus.system.api.domain.SysFile;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
/**
* @className:AppIndexServiceImpl
* @author:cwchen
* @date:2024-08-21-15:56
* @version:1.0
* @description:App首页
*/
@Service(value = "IAppIndexService")
@Slf4j
public class AppIndexServiceImpl implements IAppIndexService {
@Resource(name = "AppIndexMapper")
private AppIndexMapper mapper;
@Resource
private RemoteFileService remoteFileService;
@Resource(name = "testTaskExecutor")
private ThreadPoolTaskExecutor testTaskExecutor;
@Override
public List<CarouseVo> carouselList(AppParamsDto dto) {
dto.setSourceType("5");
List<CarouseVo> list = new ArrayList<>();
List<Future> futureList = new ArrayList<>();
List<CarouseVo> newList = new ArrayList<>();
try {
list = mapper.carouselList(dto);
for (CarouseVo vo : list) {
Future<CarouseVo> future = testTaskExecutor.submit(new Callable<CarouseVo>() {
@Override
public CarouseVo call() throws Exception {
String imageBase64 = getImageBase64(vo.getFilePath());
vo.setBase64Url(imageBase64);
return vo;
}
});
futureList.add(future);
}
for (Future<CarouseVo> future : futureList) {
CarouseVo vo = future.get();
newList.add(vo);
}
} catch (Exception e) {
log.error(e.toString(), e);
}
return newList;
}
/**
* 获取图片的base64
*
* @param filePath
* @return String
* @author cwchen
* @date 2024/8/20 9:18
*/
public String getImageBase64(String filePath) {
R<SysFile> result = remoteFileService.getImgBase64(filePath, SecurityConstants.INNER);
if (result != null && result.getCode() == HttpStatus.SUCCESS && result.getData() != null) {
String jsonString = JSON.toJSONString(result.getData());
JSONObject item = JSON.parseObject(jsonString);
String base64 = item.getString("url");
return base64;
}
return null;
}
}

View File

@ -0,0 +1,11 @@
<?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.bonus.app.mapper.AppIndexMapper">
<!--APP首页轮播图-->
<select id="carouselList" resultType="com.bonus.common.entity.app.vo.CarouseVo">
SELECT file_path AS filePath FROM sys_file_source WHERE source_id = #{departId} AND source_type = #{sourceType} AND del_flag = 0
</select>
</mapper>

View File

@ -98,7 +98,6 @@ public class PersonMgeServiceImpl implements IPersonMgeService {
Future<PersonVo> future = testTaskExecutor.submit(new Callable<PersonVo>() {
@Override
public PersonVo call() throws Exception {
System.err.println("执行了");
vo.setIdCard(Sm4Utils.decode(vo.getIdCard()));
vo.setPhone(Sm4Utils.decode(vo.getPhone()));
String imageBase64 = getImageBase64(vo.getFilePath());