13 changed files with 398 additions and 4 deletions
@ -0,0 +1,70 @@ |
|||||||
|
/** |
||||||
|
* Copyright (C) 2018-2020 |
||||||
|
* All rights reserved, Designed By www.yixiang.co |
||||||
|
* 注意: |
||||||
|
* 本软件为www.yixiang.co开发研制,未经购买不得使用 |
||||||
|
* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) |
||||||
|
* 一经发现盗用、分享等行为,将追究法律责任,后果自负 |
||||||
|
*/ |
||||||
|
package co.yixiang.modules.store.domain; |
||||||
|
import com.baomidou.mybatisplus.annotation.FieldFill; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import lombok.Data; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import cn.hutool.core.bean.BeanUtil; |
||||||
|
import cn.hutool.core.bean.copier.CopyOptions; |
||||||
|
import javax.validation.constraints.*; |
||||||
|
import java.sql.Timestamp; |
||||||
|
import java.io.Serializable; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author ssj |
||||||
|
* @date 2022-09-15 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@TableName("yx_store_brand") |
||||||
|
public class YxStoreBrand implements Serializable { |
||||||
|
|
||||||
|
/** 商品品牌表ID */ |
||||||
|
@TableId |
||||||
|
private Integer id; |
||||||
|
|
||||||
|
|
||||||
|
/** 品牌名称 */ |
||||||
|
@NotBlank |
||||||
|
private String brandName; |
||||||
|
|
||||||
|
|
||||||
|
/** 排序 */ |
||||||
|
private Integer sort; |
||||||
|
|
||||||
|
|
||||||
|
/** 图标 */ |
||||||
|
private String pic; |
||||||
|
|
||||||
|
|
||||||
|
/** 是否推荐 */ |
||||||
|
private Integer isShow; |
||||||
|
|
||||||
|
|
||||||
|
/** 添加时间 */ |
||||||
|
@TableField(fill= FieldFill.INSERT) |
||||||
|
private Timestamp createTime; |
||||||
|
|
||||||
|
|
||||||
|
@TableField(fill= FieldFill.INSERT_UPDATE) |
||||||
|
private Timestamp updateTime; |
||||||
|
|
||||||
|
|
||||||
|
/** 删除状态 */ |
||||||
|
private Integer isDel; |
||||||
|
|
||||||
|
|
||||||
|
private Long tenantId; |
||||||
|
|
||||||
|
|
||||||
|
public void copy(YxStoreBrand source){ |
||||||
|
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,86 @@ |
|||||||
|
/** |
||||||
|
* Copyright (C) 2018-2020 |
||||||
|
* All rights reserved, Designed By www.yixiang.co |
||||||
|
* 注意: |
||||||
|
* 本软件为www.yixiang.co开发研制,未经购买不得使用 |
||||||
|
* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) |
||||||
|
* 一经发现盗用、分享等行为,将追究法律责任,后果自负 |
||||||
|
*/ |
||||||
|
package co.yixiang.modules.store.rest; |
||||||
|
import java.util.Arrays; |
||||||
|
|
||||||
|
import co.yixiang.domain.PageResult; |
||||||
|
import co.yixiang.dozer.service.IGenerator; |
||||||
|
import co.yixiang.logging.aop.log.Log; |
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import co.yixiang.modules.store.domain.YxStoreBrand; |
||||||
|
import co.yixiang.modules.store.service.YxStoreBrandService; |
||||||
|
import co.yixiang.modules.store.service.dto.YxStoreBrandQueryCriteria; |
||||||
|
import co.yixiang.modules.store.service.dto.YxStoreBrandDto; |
||||||
|
import org.springframework.data.domain.Pageable; |
||||||
|
import org.springframework.http.HttpStatus; |
||||||
|
import org.springframework.http.ResponseEntity; |
||||||
|
import org.springframework.security.access.prepost.PreAuthorize; |
||||||
|
import org.springframework.validation.annotation.Validated; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
import io.swagger.annotations.*; |
||||||
|
import java.io.IOException; |
||||||
|
import javax.servlet.http.HttpServletResponse; |
||||||
|
/** |
||||||
|
* @author ssj |
||||||
|
* @date 2022-09-15 |
||||||
|
*/ |
||||||
|
@AllArgsConstructor |
||||||
|
@Api(tags = "brand管理") |
||||||
|
@RestController |
||||||
|
@RequestMapping("/api/yxStoreBrand") |
||||||
|
public class YxStoreBrandController { |
||||||
|
|
||||||
|
private final YxStoreBrandService yxStoreBrandService; |
||||||
|
private final IGenerator generator; |
||||||
|
|
||||||
|
|
||||||
|
@Log("导出数据") |
||||||
|
@ApiOperation("导出数据") |
||||||
|
@GetMapping(value = "/download") |
||||||
|
@PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreBrand:list')") |
||||||
|
public void download(HttpServletResponse response, YxStoreBrandQueryCriteria criteria) throws IOException { |
||||||
|
yxStoreBrandService.download(generator.convert(yxStoreBrandService.queryAll(criteria), YxStoreBrandDto.class), response); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping |
||||||
|
@Log("查询brand") |
||||||
|
@ApiOperation("查询brand") |
||||||
|
@PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreBrand:list')") |
||||||
|
public ResponseEntity<PageResult<YxStoreBrandDto>> getYxStoreBrands(YxStoreBrandQueryCriteria criteria, Pageable pageable){ |
||||||
|
return new ResponseEntity<>(yxStoreBrandService.queryAll(criteria,pageable),HttpStatus.OK); |
||||||
|
} |
||||||
|
|
||||||
|
@PostMapping |
||||||
|
@Log("新增brand") |
||||||
|
@ApiOperation("新增brand") |
||||||
|
@PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreBrand:add')") |
||||||
|
public ResponseEntity<Object> create(@Validated @RequestBody YxStoreBrand resources){ |
||||||
|
return new ResponseEntity<>(yxStoreBrandService.save(resources),HttpStatus.CREATED); |
||||||
|
} |
||||||
|
|
||||||
|
@PutMapping |
||||||
|
@Log("修改brand") |
||||||
|
@ApiOperation("修改brand") |
||||||
|
@PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreBrand:edit')") |
||||||
|
public ResponseEntity<Object> update(@Validated @RequestBody YxStoreBrand resources){ |
||||||
|
yxStoreBrandService.updateById(resources); |
||||||
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
||||||
|
} |
||||||
|
|
||||||
|
@Log("删除brand") |
||||||
|
@ApiOperation("删除brand") |
||||||
|
@PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreBrand:del')") |
||||||
|
@DeleteMapping |
||||||
|
public ResponseEntity<Object> deleteAll(@RequestBody Integer[] ids) { |
||||||
|
Arrays.asList(ids).forEach(id->{ |
||||||
|
yxStoreBrandService.removeById(id); |
||||||
|
}); |
||||||
|
return new ResponseEntity<>(HttpStatus.OK); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,48 @@ |
|||||||
|
/** |
||||||
|
* Copyright (C) 2018-2020 |
||||||
|
* All rights reserved, Designed By www.yixiang.co |
||||||
|
* 注意: |
||||||
|
* 本软件为www.yixiang.co开发研制,未经购买不得使用 |
||||||
|
* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) |
||||||
|
* 一经发现盗用、分享等行为,将追究法律责任,后果自负 |
||||||
|
*/ |
||||||
|
package co.yixiang.modules.store.service; |
||||||
|
import co.yixiang.common.service.BaseService; |
||||||
|
import co.yixiang.domain.PageResult; |
||||||
|
import co.yixiang.modules.store.domain.YxStoreBrand; |
||||||
|
import co.yixiang.modules.store.service.dto.YxStoreBrandDto; |
||||||
|
import co.yixiang.modules.store.service.dto.YxStoreBrandQueryCriteria; |
||||||
|
import org.springframework.data.domain.Pageable; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.List; |
||||||
|
import java.io.IOException; |
||||||
|
import javax.servlet.http.HttpServletResponse; |
||||||
|
/** |
||||||
|
* @author ssj |
||||||
|
* @date 2022-09-15 |
||||||
|
*/ |
||||||
|
public interface YxStoreBrandService extends BaseService<YxStoreBrand> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询数据分页 |
||||||
|
* @param criteria 条件 |
||||||
|
* @param pageable 分页参数 |
||||||
|
* @return Map<String,Object> |
||||||
|
*/ |
||||||
|
PageResult<YxStoreBrandDto> queryAll(YxStoreBrandQueryCriteria criteria, Pageable pageable); |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询所有数据不分页 |
||||||
|
* @param criteria 条件参数 |
||||||
|
* @return List<YxStoreBrandDto> |
||||||
|
*/ |
||||||
|
List<YxStoreBrand> queryAll(YxStoreBrandQueryCriteria criteria); |
||||||
|
|
||||||
|
/** |
||||||
|
* 导出数据 |
||||||
|
* @param all 待导出的数据 |
||||||
|
* @param response / |
||||||
|
* @throws IOException / |
||||||
|
*/ |
||||||
|
void download(List<YxStoreBrandDto> all, HttpServletResponse response) throws IOException; |
||||||
|
} |
@ -0,0 +1,46 @@ |
|||||||
|
/** |
||||||
|
* Copyright (C) 2018-2020 |
||||||
|
* All rights reserved, Designed By www.yixiang.co |
||||||
|
* 注意: |
||||||
|
* 本软件为www.yixiang.co开发研制,未经购买不得使用 |
||||||
|
* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) |
||||||
|
* 一经发现盗用、分享等行为,将追究法律责任,后果自负 |
||||||
|
*/ |
||||||
|
package co.yixiang.modules.store.service.dto; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
import java.sql.Timestamp; |
||||||
|
import java.io.Serializable; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author ssj |
||||||
|
* @date 2022-09-15 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
public class YxStoreBrandDto implements Serializable { |
||||||
|
|
||||||
|
/** 商品品牌表ID */ |
||||||
|
private Integer id; |
||||||
|
|
||||||
|
/** 品牌名称 */ |
||||||
|
private String brandName; |
||||||
|
|
||||||
|
/** 排序 */ |
||||||
|
private Integer sort; |
||||||
|
|
||||||
|
/** 图标 */ |
||||||
|
private String pic; |
||||||
|
|
||||||
|
/** 是否推荐 */ |
||||||
|
private Integer isShow; |
||||||
|
|
||||||
|
/** 添加时间 */ |
||||||
|
private Timestamp createTime; |
||||||
|
|
||||||
|
private Timestamp updateTime; |
||||||
|
|
||||||
|
/** 删除状态 */ |
||||||
|
private Integer isDel; |
||||||
|
|
||||||
|
private Long tenantId; |
||||||
|
} |
@ -0,0 +1,19 @@ |
|||||||
|
/** |
||||||
|
* Copyright (C) 2018-2020 |
||||||
|
* All rights reserved, Designed By www.yixiang.co |
||||||
|
* 注意: |
||||||
|
* 本软件为www.yixiang.co开发研制,未经购买不得使用 |
||||||
|
* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) |
||||||
|
* 一经发现盗用、分享等行为,将追究法律责任,后果自负 |
||||||
|
*/ |
||||||
|
package co.yixiang.modules.store.service.dto; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author ssj |
||||||
|
* @date 2022-09-15 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
public class YxStoreBrandQueryCriteria{ |
||||||
|
} |
@ -0,0 +1,84 @@ |
|||||||
|
/** |
||||||
|
* Copyright (C) 2018-2020 |
||||||
|
* All rights reserved, Designed By www.yixiang.co |
||||||
|
* 注意: |
||||||
|
* 本软件为www.yixiang.co开发研制,未经购买不得使用 |
||||||
|
* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) |
||||||
|
* 一经发现盗用、分享等行为,将追究法律责任,后果自负 |
||||||
|
*/ |
||||||
|
package co.yixiang.modules.store.service.impl; |
||||||
|
|
||||||
|
import co.yixiang.common.service.impl.BaseServiceImpl; |
||||||
|
import co.yixiang.common.utils.QueryHelpPlus; |
||||||
|
import co.yixiang.domain.PageResult; |
||||||
|
import co.yixiang.dozer.service.IGenerator; |
||||||
|
import co.yixiang.modules.store.domain.YxStoreBrand; |
||||||
|
import co.yixiang.modules.store.service.vo.YxStoreBrandVO; |
||||||
|
import co.yixiang.utils.FileUtil; |
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import com.github.pagehelper.PageInfo; |
||||||
|
import co.yixiang.modules.store.service.YxStoreBrandService; |
||||||
|
import co.yixiang.modules.store.service.dto.YxStoreBrandDto; |
||||||
|
import co.yixiang.modules.store.service.dto.YxStoreBrandQueryCriteria; |
||||||
|
import co.yixiang.modules.store.service.mapper.YxStoreBrandMapper; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
import org.springframework.transaction.annotation.Propagation; |
||||||
|
import org.springframework.transaction.annotation.Transactional; |
||||||
|
// 默认不使用缓存
|
||||||
|
//import org.springframework.cache.annotation.CacheConfig;
|
||||||
|
//import org.springframework.cache.annotation.CacheEvict;
|
||||||
|
//import org.springframework.cache.annotation.Cacheable;
|
||||||
|
import org.springframework.data.domain.Page; |
||||||
|
import org.springframework.data.domain.Pageable; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
import java.io.IOException; |
||||||
|
import javax.servlet.http.HttpServletResponse; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.LinkedHashMap; |
||||||
|
/** |
||||||
|
* @author ssj |
||||||
|
* @date 2022-09-15 |
||||||
|
*/ |
||||||
|
@Service |
||||||
|
@AllArgsConstructor |
||||||
|
//@CacheConfig(cacheNames = "yxStoreBrand")
|
||||||
|
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) |
||||||
|
public class YxStoreBrandServiceImpl extends BaseServiceImpl<YxStoreBrandMapper, YxStoreBrand> implements YxStoreBrandService { |
||||||
|
|
||||||
|
private final IGenerator generator; |
||||||
|
|
||||||
|
@Override |
||||||
|
//@Cacheable
|
||||||
|
public PageResult<YxStoreBrandDto> queryAll(YxStoreBrandQueryCriteria criteria, Pageable pageable) { |
||||||
|
getPage(pageable); |
||||||
|
PageInfo<YxStoreBrand> page = new PageInfo<>(queryAll(criteria)); |
||||||
|
return generator.convertPageInfo(page, YxStoreBrandDto.class); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
//@Cacheable
|
||||||
|
public List<YxStoreBrand> queryAll(YxStoreBrandQueryCriteria criteria){ |
||||||
|
return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreBrand.class, criteria)); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public void download(List<YxStoreBrandDto> all, HttpServletResponse response) throws IOException { |
||||||
|
List<Map<String, Object>> list = new ArrayList<>(); |
||||||
|
for (YxStoreBrandDto yxStoreBrand : all) { |
||||||
|
Map<String,Object> map = new LinkedHashMap<>(); |
||||||
|
map.put("品牌名称", yxStoreBrand.getBrandName()); |
||||||
|
map.put("排序", yxStoreBrand.getSort()); |
||||||
|
map.put("图标", yxStoreBrand.getPic()); |
||||||
|
map.put("是否推荐", yxStoreBrand.getIsShow()); |
||||||
|
map.put("添加时间", yxStoreBrand.getCreateTime()); |
||||||
|
map.put(" updateTime", yxStoreBrand.getUpdateTime()); |
||||||
|
map.put("删除状态", yxStoreBrand.getIsDel()); |
||||||
|
map.put(" tenantId", yxStoreBrand.getTenantId()); |
||||||
|
list.add(map); |
||||||
|
} |
||||||
|
FileUtil.downloadExcel(list, response); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,22 @@ |
|||||||
|
/** |
||||||
|
* Copyright (C) 2018-2020 |
||||||
|
* All rights reserved, Designed By www.yixiang.co |
||||||
|
* 注意: |
||||||
|
* 本软件为www.yixiang.co开发研制,未经购买不得使用 |
||||||
|
* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) |
||||||
|
* 一经发现盗用、分享等行为,将追究法律责任,后果自负 |
||||||
|
*/ |
||||||
|
package co.yixiang.modules.store.service.mapper; |
||||||
|
|
||||||
|
import co.yixiang.common.mapper.CoreMapper; |
||||||
|
import co.yixiang.modules.store.domain.YxStoreBrand; |
||||||
|
import org.springframework.stereotype.Repository; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author ssj |
||||||
|
* @date 2022-09-15 |
||||||
|
*/ |
||||||
|
@Repository |
||||||
|
public interface YxStoreBrandMapper extends CoreMapper<YxStoreBrand> { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,8 @@ |
|||||||
|
package co.yixiang.modules.store.service.vo; |
||||||
|
|
||||||
|
import co.yixiang.modules.store.domain.YxStoreBrand; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class YxStoreBrandVO extends YxStoreBrand { |
||||||
|
} |
Loading…
Reference in new issue