2024-11-14(属性组完成)
parent
33aab5702c
commit
50c1706b77
|
@ -21,6 +21,10 @@ public enum BusinessType {
|
|||
*/
|
||||
UPDATE,
|
||||
|
||||
/**
|
||||
* 修改(吴彦祖)
|
||||
*/
|
||||
UPDATE_CUSTOMIZE,
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
|
|
|
@ -45,11 +45,11 @@ public class AsAttributeGroup extends BaseEntity {
|
|||
private Long attributeId;
|
||||
|
||||
|
||||
public static AsAttributeGroup buildGroup (Long attributeGroupId,
|
||||
Long attributeId) {
|
||||
public static AsAttributeGroup buildGroup (Long attributeGroupId, Long attributeId) {
|
||||
return AsAttributeGroup.builder()
|
||||
.groupId(attributeGroupId)
|
||||
.attributeId(attributeId)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -74,9 +74,9 @@ public class AttributeGroup extends BaseEntity {
|
|||
* 修改构造器
|
||||
*/
|
||||
public static AttributeGroup editBuild(Long id, AttributeGroupEditReq attributeGroupEditReq){
|
||||
return AttributeGroup.builder()
|
||||
.id(id)
|
||||
.name(attributeGroupEditReq.getName())
|
||||
|
||||
|
||||
return AttributeGroup.builder().id(id).name(attributeGroupEditReq.getName())
|
||||
.states(attributeGroupEditReq.getStates())
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.muyu.product.domain.req;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.muyu.product.domain.AttributeInfo;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
@ -33,5 +36,8 @@ public class AttributeGroupEditReq extends BaseEntity {
|
|||
@ApiModelProperty(name = "状态", value = "状态", required = true)
|
||||
private String states;
|
||||
|
||||
/** 属性id 集合 */
|
||||
@ApiModelProperty(name = "属性集合", value = "属性集合", required = true)
|
||||
private List<AttributeInfo> attributeList;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package com.muyu.product.domain.req;
|
||||
|
||||
import com.muyu.product.domain.AttributeInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class AttributeGroupUpdReq {
|
||||
|
||||
/**
|
||||
*属性组id
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 组名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 属性id 集合
|
||||
*/
|
||||
|
||||
private List<AttributeInfo> attributeList;
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.muyu.product.domain.resp;
|
||||
|
||||
import com.muyu.product.domain.AttributeInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AttributeGroupUpd {
|
||||
/** 属性组编号 */
|
||||
private Long id;
|
||||
|
||||
/** 组名称 */
|
||||
private String name;
|
||||
|
||||
/** 状态 */
|
||||
private String states;
|
||||
|
||||
/**
|
||||
* 属性id 集合
|
||||
*/
|
||||
|
||||
private List<AttributeInfo> attributeList;
|
||||
|
||||
}
|
|
@ -5,6 +5,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import com.muyu.product.domain.model.AttributeGroupSaveModel;
|
||||
import com.muyu.product.domain.resp.AttributeGroupPageResp;
|
||||
import com.muyu.product.domain.resp.AttributeGroupUpd;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -74,8 +75,8 @@ public class AttributeGroupController extends BaseController {
|
|||
@RequiresPermissions("product:attributeGroup:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||
public Result<AttributeGroup> getInfo(@PathVariable("id") Long id) {
|
||||
return Result.success(attributeGroupService.getById(id));
|
||||
public Result<AttributeGroupUpd> getInfo(@PathVariable("id") Long id) {
|
||||
return Result.success(attributeGroupService.getByIdUpd(id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -99,7 +100,8 @@ public class AttributeGroupController extends BaseController {
|
|||
@PutMapping("/{id}")
|
||||
@ApiOperation("修改属性组")
|
||||
public Result<String> edit(@PathVariable Long id, @RequestBody AttributeGroupEditReq attributeGroupEditReq) {
|
||||
return toAjax(attributeGroupService.updateById(AttributeGroup.editBuild(id,attributeGroupEditReq)));
|
||||
attributeGroupService.updateAttribute(id,attributeGroupEditReq);
|
||||
return Result.success("修改成功");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,4 +115,6 @@ public class AttributeGroupController extends BaseController {
|
|||
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||
return toAjax(attributeGroupService.removeBatchByIds(ids));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.muyu.product.mapper;
|
|||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.product.domain.AsAttributeGroup;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 属性与组中间Mapper接口
|
||||
|
@ -10,6 +12,11 @@ import com.muyu.product.domain.AsAttributeGroup;
|
|||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Mapper
|
||||
public interface AsAttributeGroupMapper extends BaseMapper<AsAttributeGroup> {
|
||||
//删除 属性组
|
||||
void delete(Long id);
|
||||
|
||||
//添加 属性组
|
||||
void add(@Param("groupId") Long groupId, @Param("id") Long id);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.mapper;
|
|||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.product.domain.AttributeGroup;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 属性组Mapper接口
|
||||
|
@ -10,6 +11,8 @@ import com.muyu.product.domain.AttributeGroup;
|
|||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Mapper
|
||||
public interface AttributeGroupMapper extends BaseMapper<AttributeGroup> {
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ public interface AsAttributeGroupService extends IService<AsAttributeGroup> {
|
|||
* 查询属性与组中间列表
|
||||
*
|
||||
* @param asAttributeGroup 属性与组中间
|
||||
*
|
||||
* @return 属性与组中间集合
|
||||
*/
|
||||
public List<AsAttributeGroup> list(AsAttributeGroup asAttributeGroup);
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package com.muyu.product.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.product.domain.AttributeGroup;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.product.domain.AttributeInfo;
|
||||
import com.muyu.product.domain.model.AttributeGroupSaveModel;
|
||||
import com.muyu.product.domain.req.AttributeGroupEditReq;
|
||||
import com.muyu.product.domain.resp.AttributeGroupPageResp;
|
||||
import com.muyu.product.domain.resp.AttributeGroupUpd;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 属性组Service接口
|
||||
|
@ -39,4 +40,16 @@ public interface AttributeGroupService extends IService<AttributeGroup> {
|
|||
*/
|
||||
public Boolean save(AttributeGroupSaveModel attributeGroupSaveModel);
|
||||
|
||||
/**
|
||||
* 吴彦祖 的 修改 属性
|
||||
*/
|
||||
void updateAttribute(Long id, AttributeGroupEditReq attributeGroupEditReq);
|
||||
/**
|
||||
* 吴彦祖 的 回显属性组
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
AttributeGroupUpd getByIdUpd(Long id);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,10 @@ import com.muyu.product.domain.AsAttributeGroup;
|
|||
import com.muyu.product.domain.AttributeGroup;
|
||||
import com.muyu.product.domain.AttributeInfo;
|
||||
import com.muyu.product.domain.model.AttributeGroupSaveModel;
|
||||
import com.muyu.product.domain.req.AttributeGroupEditReq;
|
||||
import com.muyu.product.domain.resp.AttributeGroupPageResp;
|
||||
import com.muyu.product.domain.resp.AttributeGroupUpd;
|
||||
import com.muyu.product.mapper.AsAttributeGroupMapper;
|
||||
import com.muyu.product.mapper.AttributeGroupMapper;
|
||||
import com.muyu.product.service.AsAttributeGroupService;
|
||||
import com.muyu.product.service.AttributeGroupService;
|
||||
|
@ -19,9 +22,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 属性组Service业务层处理
|
||||
|
@ -33,12 +35,17 @@ import java.util.stream.Stream;
|
|||
@Service
|
||||
public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper, AttributeGroup> implements AttributeGroupService {
|
||||
|
||||
//属性与组中间列表
|
||||
@Autowired
|
||||
private AsAttributeGroupService attributeGroupService;
|
||||
|
||||
//商品属性Service接口
|
||||
@Autowired
|
||||
private AttributeInfoService attributeInfoService;
|
||||
|
||||
@Autowired
|
||||
private AsAttributeGroupMapper attributeGroupMapper;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
|
@ -86,9 +93,7 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
|
|||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param attributeGroupSaveModel 属性组保存模型
|
||||
*
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
|
@ -107,4 +112,61 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
|
|||
);
|
||||
return save;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 吴彦祖 的 修改 属性
|
||||
*/
|
||||
@Override
|
||||
public void updateAttribute(Long id, AttributeGroupEditReq attributeGroupEditReq) {
|
||||
//删除原 属性组
|
||||
attributeGroupMapper.delete(id);
|
||||
//获取新数据组
|
||||
List<AttributeInfo> list = attributeGroupEditReq.getAttributeList();
|
||||
//添加
|
||||
for (AttributeInfo info : list) {
|
||||
attributeGroupMapper.add(id,info.getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 吴彦祖 的 回显属性组
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AttributeGroupUpd getByIdUpd(Long id) {
|
||||
//获取当前id的 组
|
||||
AttributeGroup byId = this.getById(id);
|
||||
//查询 该 组 的 属性 集合
|
||||
LambdaQueryWrapper<AsAttributeGroup> wrapper = new LambdaQueryWrapper<>();
|
||||
//返回
|
||||
wrapper.eq(AsAttributeGroup::getGroupId,id);
|
||||
List<AsAttributeGroup> asAttributeGroups=attributeGroupService.list(wrapper);
|
||||
//判断当前会显得 属性及 是否为空
|
||||
if (asAttributeGroups.size() != 0){
|
||||
List<Long> longList = asAttributeGroups.stream()
|
||||
.map(AsAttributeGroup::getAttributeId)//属性
|
||||
.toList();
|
||||
List<AttributeInfo> attributeInfos = attributeInfoService.listByIds(longList);
|
||||
return AttributeGroupUpd.builder()
|
||||
.id(byId.getId())
|
||||
.name(byId.getName())
|
||||
.attributeList(//属性
|
||||
attributeInfos
|
||||
).build();//修改回显时信息
|
||||
}
|
||||
List<Long> list =new ArrayList<>();
|
||||
List<AttributeInfo> attributeInfos = attributeInfoService.listByIds(list);
|
||||
|
||||
|
||||
return AttributeGroupUpd.builder()
|
||||
.id(byId.getId())
|
||||
.name(byId.getName())
|
||||
.attributeList(//属性
|
||||
attributeInfos
|
||||
).build();//修改回显时信息
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,4 +18,15 @@
|
|||
<sql id="selectAsAttributeGroupVo">
|
||||
select id, group_id, attribute_id, remark, create_by, create_time, update_by, update_time from as_attribute_group
|
||||
</sql>
|
||||
|
||||
<insert id="add">
|
||||
INSERT INTO `product`.`as_attribute_group` (`id`, `group_id`, `attribute_id`, `remark`, `create_by`,
|
||||
`create_time`, `update_by`, `update_time`)
|
||||
VALUES (0,#{groupId}, #{id}, NULL, NULL, NULL, NULL, NULL);
|
||||
</insert>
|
||||
<!-- 删除 属性组-->
|
||||
<delete id="delete">
|
||||
delete from `as_attribute_group` where group_id =#{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -1,21 +1,19 @@
|
|||
<?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">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.muyu.product.mapper.AttributeGroupMapper">
|
||||
|
||||
<resultMap type="com.muyu.product.domain.AttributeGroup" id="AttributeGroupResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="name" column="name" />
|
||||
<result property="states" column="states" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updataBy" column="updata_by" />
|
||||
<result property="updataTime" column="updata_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="states" column="states"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updataBy" column="updata_by"/>
|
||||
<result property="updataTime" column="updata_time"/>
|
||||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectAttributeGroupVo">
|
||||
select id, name, states, create_by, create_time, updata_by, updata_time, remark from attribute_group
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package com.muyu.system.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("wyz")
|
||||
public class SysWyzController {
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.muyu.system.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface SysWyzMapper {
|
||||
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package com.muyu.system.service;
|
||||
|
||||
public interface SysWyzService {
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.muyu.system.service.impl;
|
||||
|
||||
import com.muyu.system.service.SysWyzService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class SysWyzServiceImpl implements SysWyzService {
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
<?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.muyu.system.mapper.SysWyzMapper">
|
||||
</mapper>
|
Loading…
Reference in New Issue