11 changed files with 362 additions and 5 deletions
@ -0,0 +1,116 @@ |
|||||
|
package com.qs.serve.modules.goods.controller; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.qs.serve.common.model.annotation.SysLog; |
||||
|
import com.qs.serve.common.model.dto.PageVo; |
||||
|
import com.qs.serve.common.model.dto.R; |
||||
|
import com.qs.serve.common.model.enums.BizType; |
||||
|
import com.qs.serve.common.model.enums.SystemModule; |
||||
|
import com.qs.serve.common.util.PageUtil; |
||||
|
import com.qs.serve.common.util.CopierUtil; |
||||
|
import com.qs.serve.common.util.StringUtils; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.security.access.prepost.PreAuthorize; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import com.qs.serve.modules.goods.entity.GoodsSaleGroup; |
||||
|
import com.qs.serve.modules.goods.service.GoodsSaleGroupService; |
||||
|
|
||||
|
import javax.validation.Valid; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 商品 商品销售分组 |
||||
|
* @author YenHex |
||||
|
* @since 2023-08-21 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@AllArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("goods/saleGroup") |
||||
|
public class GoodsSaleGroupController { |
||||
|
|
||||
|
private GoodsSaleGroupService goodsSaleGroupService; |
||||
|
|
||||
|
/** |
||||
|
* 列表 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
//@GetMapping("/list")
|
||||
|
public R<List<GoodsSaleGroup>> getList(GoodsSaleGroup param){ |
||||
|
LambdaQueryWrapper<GoodsSaleGroup> lqw = new LambdaQueryWrapper<>(param); |
||||
|
lqw.orderByDesc(GoodsSaleGroup::getSort); |
||||
|
List<GoodsSaleGroup> list = goodsSaleGroupService.list(lqw); |
||||
|
return R.ok(list); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 翻页 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/page") |
||||
|
public R<PageVo<GoodsSaleGroup>> getPage(GoodsSaleGroup param){ |
||||
|
LambdaQueryWrapper<GoodsSaleGroup> lqw = new LambdaQueryWrapper<>(param); |
||||
|
PageUtil.startPage(); |
||||
|
lqw.orderByDesc(GoodsSaleGroup::getSort); |
||||
|
List<GoodsSaleGroup> list = goodsSaleGroupService.list(lqw); |
||||
|
return R.byPageHelperList(list); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* ID查询 |
||||
|
* @param id |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/getById/{id}") |
||||
|
@SysLog(module = SystemModule.GOODS, title = "商品销售分组", biz = BizType.QUERY) |
||||
|
@PreAuthorize("hasRole('goods:saleGroup:query')") |
||||
|
public R<GoodsSaleGroup> getById(@PathVariable("id") String id){ |
||||
|
GoodsSaleGroup goodsSaleGroup = goodsSaleGroupService.getById(id); |
||||
|
return R.ok(goodsSaleGroup); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 更新 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/updateById") |
||||
|
@SysLog(module = SystemModule.GOODS, title = "商品销售分组", biz = BizType.UPDATE) |
||||
|
public R<?> updateById(@RequestBody @Valid GoodsSaleGroup param){ |
||||
|
boolean result = goodsSaleGroupService.updateById(param); |
||||
|
return R.isTrue(result); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 新增 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/save") |
||||
|
@SysLog(module = SystemModule.GOODS, title = "商品销售分组", biz = BizType.INSERT) |
||||
|
public R<?> save(@RequestBody @Valid GoodsSaleGroup param){ |
||||
|
boolean result = goodsSaleGroupService.save(param); |
||||
|
return R.isTrue(result); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除 |
||||
|
* @param ids |
||||
|
* @return |
||||
|
*/ |
||||
|
@DeleteMapping("/deleteById/{ids}") |
||||
|
@SysLog(module = SystemModule.GOODS, title = "商品销售分组", biz = BizType.DELETE) |
||||
|
public R<?> deleteById(@PathVariable("ids") String ids){ |
||||
|
List<Long> idsLong = StringUtils.splitIdLong(ids); |
||||
|
boolean result = goodsSaleGroupService.removeByIds(idsLong); |
||||
|
return R.isTrue(result); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,48 @@ |
|||||
|
package com.qs.serve.modules.goods.controller.api; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.qs.serve.common.model.annotation.SysLog; |
||||
|
import com.qs.serve.common.model.dto.PageVo; |
||||
|
import com.qs.serve.common.model.dto.R; |
||||
|
import com.qs.serve.common.model.enums.BizType; |
||||
|
import com.qs.serve.common.model.enums.SystemModule; |
||||
|
import com.qs.serve.common.util.PageUtil; |
||||
|
import com.qs.serve.common.util.StringUtils; |
||||
|
import com.qs.serve.modules.goods.entity.GoodsSaleGroup; |
||||
|
import com.qs.serve.modules.goods.service.GoodsSaleGroupService; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.security.access.prepost.PreAuthorize; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import javax.validation.Valid; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* API商品销售分组 |
||||
|
* @author YenHex |
||||
|
* @since 2023-08-21 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@AllArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("my/saleGroup") |
||||
|
public class GoodsSaleGroupApi { |
||||
|
|
||||
|
private GoodsSaleGroupService goodsSaleGroupService; |
||||
|
|
||||
|
/** |
||||
|
* 列表 |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/list") |
||||
|
public R<List<GoodsSaleGroup>> getList(){ |
||||
|
LambdaQueryWrapper<GoodsSaleGroup> lqw = new LambdaQueryWrapper<>(); |
||||
|
lqw.eq(GoodsSaleGroup::getShowFlag,1); |
||||
|
lqw.orderByDesc(GoodsSaleGroup::getSort); |
||||
|
List<GoodsSaleGroup> list = goodsSaleGroupService.list(lqw); |
||||
|
return R.ok(list); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,91 @@ |
|||||
|
package com.qs.serve.modules.goods.entity; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.io.Serializable; |
||||
|
import java.math.BigDecimal; |
||||
|
import java.time.LocalDateTime; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.*; |
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
|
import com.fasterxml.jackson.annotation.JsonProperty; |
||||
|
import lombok.Data; |
||||
|
import org.hibernate.validator.constraints.Length; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import javax.validation.constraints.NotNull; |
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
|
||||
|
/** |
||||
|
* 商品销售分组 实体类 |
||||
|
* @author YenHex |
||||
|
* @since 2023-08-21 |
||||
|
*/ |
||||
|
@Data |
||||
|
@TableName("goods_sale_group") |
||||
|
public class GoodsSaleGroup implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** id */ |
||||
|
@TableId(type = IdType.AUTO) |
||||
|
private Long id; |
||||
|
|
||||
|
/** 标题 */ |
||||
|
@Length(max = 255,message = "标题长度不能超过255字") |
||||
|
private String label; |
||||
|
|
||||
|
/** 显示在页面标识 */ |
||||
|
private Integer showFlag; |
||||
|
|
||||
|
/** 排序 */ |
||||
|
private Integer sort; |
||||
|
|
||||
|
/** 创建时间 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
@TableField(fill = FieldFill.INSERT) |
||||
|
private LocalDateTime createTime; |
||||
|
|
||||
|
/** 最后更新时间 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
@TableField(fill = FieldFill.UPDATE) |
||||
|
private LocalDateTime updateTime; |
||||
|
|
||||
|
/** 所属租户 */ |
||||
|
@JsonIgnore |
||||
|
@JsonProperty |
||||
|
private String tenantId; |
||||
|
|
||||
|
/** 逻辑删除标记(0:显示;1:隐藏) */ |
||||
|
@JsonIgnore |
||||
|
@JsonProperty |
||||
|
private String delFlag; |
||||
|
|
||||
|
/** 创建人 */ |
||||
|
@TableField(fill = FieldFill.INSERT) |
||||
|
private String createBy; |
||||
|
|
||||
|
/** 更新人 */ |
||||
|
@TableField(fill = FieldFill.UPDATE) |
||||
|
private String updateBy; |
||||
|
|
||||
|
|
||||
|
public static GoodsSaleGroup toNewObject(GoodsSaleGroup source){ |
||||
|
GoodsSaleGroup saleGroup = new GoodsSaleGroup(); |
||||
|
saleGroup.setId(source.getId()); |
||||
|
saleGroup.setLabel(source.getLabel()); |
||||
|
saleGroup.setShowFlag(source.getShowFlag()); |
||||
|
saleGroup.setSort(source.getSort()); |
||||
|
saleGroup.setCreateTime(source.getCreateTime()); |
||||
|
saleGroup.setUpdateTime(source.getUpdateTime()); |
||||
|
saleGroup.setTenantId(source.getTenantId()); |
||||
|
saleGroup.setDelFlag(source.getDelFlag()); |
||||
|
saleGroup.setCreateBy(source.getCreateBy()); |
||||
|
saleGroup.setUpdateBy(source.getUpdateBy()); |
||||
|
return saleGroup; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,14 @@ |
|||||
|
package com.qs.serve.modules.goods.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.qs.serve.modules.goods.entity.GoodsSaleGroup; |
||||
|
|
||||
|
/** |
||||
|
* 商品销售分组 Mapper |
||||
|
* @author YenHex |
||||
|
* @date 2023-08-21 |
||||
|
*/ |
||||
|
public interface GoodsSaleGroupMapper extends BaseMapper<GoodsSaleGroup> { |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,14 @@ |
|||||
|
package com.qs.serve.modules.goods.service; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
import com.qs.serve.modules.goods.entity.GoodsSaleGroup; |
||||
|
|
||||
|
/** |
||||
|
* 商品销售分组 服务接口 |
||||
|
* @author YenHex |
||||
|
* @date 2023-08-21 |
||||
|
*/ |
||||
|
public interface GoodsSaleGroupService extends IService<GoodsSaleGroup> { |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,22 @@ |
|||||
|
package com.qs.serve.modules.goods.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import com.qs.serve.modules.goods.entity.GoodsSaleGroup; |
||||
|
import com.qs.serve.modules.goods.service.GoodsSaleGroupService; |
||||
|
import com.qs.serve.modules.goods.mapper.GoodsSaleGroupMapper; |
||||
|
|
||||
|
/** |
||||
|
* 商品销售分组 服务实现类 |
||||
|
* @author YenHex |
||||
|
* @since 2023-08-21 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Service |
||||
|
@AllArgsConstructor |
||||
|
public class GoodsSaleGroupServiceImpl extends ServiceImpl<GoodsSaleGroupMapper,GoodsSaleGroup> implements GoodsSaleGroupService { |
||||
|
|
||||
|
} |
||||
|
|
Loading…
Reference in new issue