use of com.besscroft.aurora.mall.common.entity.AuthUser in project aurora-mall by besscroft.
the class ProductServiceImpl method export.
@Override
public void export(List<String> ids, HttpServletResponse response) {
List<Product> productList = this.baseMapper.selectBatchIds(ids);
if (CollUtil.isNotEmpty(productList)) {
List<ProductExcelDto> productExcelDtos = ProductConverterMapper.INSTANCE.productToProductExcelListDto(productList);
productExcelDtos.forEach(productExcelDto -> {
String pushStatus = productExcelDto.getPushStatus();
switch(pushStatus) {
case "0":
productExcelDto.setPushStatus("下架");
break;
case "1":
productExcelDto.setPushStatus("上架");
break;
}
String newStatus = productExcelDto.getNewStatus();
switch(newStatus) {
case "0":
productExcelDto.setNewStatus("不是新品");
break;
case "1":
productExcelDto.setNewStatus("新品");
break;
}
String recommandStatus = productExcelDto.getRecommandStatus();
switch(recommandStatus) {
case "0":
productExcelDto.setRecommandStatus("不推荐");
break;
case "1":
productExcelDto.setRecommandStatus("推荐");
break;
}
String verifyStatus = productExcelDto.getVerifyStatus();
switch(verifyStatus) {
case "0":
productExcelDto.setVerifyStatus("未审核");
break;
case "1":
productExcelDto.setVerifyStatus("审核通过");
break;
}
String deleteStatus = productExcelDto.getDeleteStatus();
switch(deleteStatus) {
case "0":
productExcelDto.setDeleteStatus("未删除");
break;
case "1":
productExcelDto.setDeleteStatus("已删除");
break;
}
AuthUser user = authUserMapper.selectById(productExcelDto.getCreateUser());
productExcelDto.setCreateUser(user.getUsername());
});
try {
// 这里注意 有同学反应使用 swagger 会导致各种问题,请直接用浏览器或者用 postman
response.setContentType("application/vnd.ms-excel");
// 设置返回的数据编码
response.setCharacterEncoding("utf-8");
// 这里 URLEncoder.encode 可以防止中文乱码 当然和 easyexcel 没有关系
String fileName = URLEncoder.encode("商品信息", "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
EasyExcel.write(response.getOutputStream(), ProductExcelDto.class).autoCloseStream(true).sheet("商品信息").doWrite(productExcelDtos);
} catch (IOException e) {
log.error("excel 导出失败.", e);
}
}
}
use of com.besscroft.aurora.mall.common.entity.AuthUser in project aurora-mall by besscroft.
the class ProductServiceImpl method productAdd.
@Override
@Transactional(rollbackFor = Exception.class)
public boolean productAdd(Product product) {
// 获取当前用户
AuthUser currentAdmin = userService.getCurrentAdmin();
// 设置商品唯一id
product.setId("P" + IdUtil.simpleUUID());
// 设置新增商品的用户
product.setCreateUserId(currentAdmin.getId());
return this.baseMapper.insert(product) > 0;
}
use of com.besscroft.aurora.mall.common.entity.AuthUser in project aurora-mall by besscroft.
the class UserController method getUser.
@WebLog(description = "查询权限管理模块用户详情")
@ApiOperation("查询权限管理模块用户详情")
@ApiImplicitParam(name = "id", value = "用户id", required = true, dataType = "Long")
@GetMapping("/getUser/{id}")
public AjaxResult getUser(@PathVariable("id") Long id) {
AuthUser user = userService.getUserById(id);
user.setPassword("");
return AjaxResult.success(user);
}
Aggregations