Search in sources :

Example 11 with AuthUser

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);
        }
    }
}
Also used : ProductExcelDto(com.besscroft.aurora.mall.common.domain.ProductExcelDto) Product(com.besscroft.aurora.mall.common.entity.Product) AuthUser(com.besscroft.aurora.mall.common.entity.AuthUser) IOException(java.io.IOException)

Example 12 with AuthUser

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;
}
Also used : AuthUser(com.besscroft.aurora.mall.common.entity.AuthUser) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with AuthUser

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);
}
Also used : AuthUser(com.besscroft.aurora.mall.common.entity.AuthUser) WebLog(com.besscroft.aurora.mall.common.annotation.WebLog) ApiOperation(io.swagger.annotations.ApiOperation) ApiImplicitParam(io.swagger.annotations.ApiImplicitParam)

Aggregations

AuthUser (com.besscroft.aurora.mall.common.entity.AuthUser)13 Test (org.junit.jupiter.api.Test)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 Transactional (org.springframework.transaction.annotation.Transactional)4 WebLog (com.besscroft.aurora.mall.common.annotation.WebLog)3 ApiOperation (io.swagger.annotations.ApiOperation)3 AuthRole (com.besscroft.aurora.mall.common.entity.AuthRole)2 IOException (java.io.IOException)2 BCryptPasswordEncoder (org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder)2 CollUtil (cn.hutool.core.collection.CollUtil)1 StrUtil (cn.hutool.core.util.StrUtil)1 JSONUtil (cn.hutool.json.JSONUtil)1 EasyExcel (com.alibaba.excel.EasyExcel)1 ServiceImpl (com.baomidou.mybatisplus.extension.service.impl.ServiceImpl)1 AuthFeignClient (com.besscroft.aurora.mall.admin.api.AuthFeignClient)1 UserConverterMapper (com.besscroft.aurora.mall.admin.converter.UserConverterMapper)1 AdminParam (com.besscroft.aurora.mall.admin.domain.param.AdminParam)1 AuthRoleMapper (com.besscroft.aurora.mall.admin.mapper.AuthRoleMapper)1 AuthUserMapper (com.besscroft.aurora.mall.admin.mapper.AuthUserMapper)1 MenuService (com.besscroft.aurora.mall.admin.service.MenuService)1