第二次提交

main
尚志豪123 2024-11-13 11:08:59 +08:00
parent 9a6f3a2db2
commit 5895475559
8 changed files with 115 additions and 8 deletions

View File

@ -0,0 +1,29 @@
package com.muyu.product.domain.model;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @Author
* @Packagecom.muyu.product.domain.model
* @Projectcloud-server
* @nameids
* @Date2024/11/12 23:08
*/
@Data
public class Ids {
private Long id;
/** 组名称 */
@ApiModelProperty(name = "组名称", value = "组名称", required = true)
private String name;
/** 状态 */
@ApiModelProperty(name = "状态", value = "状态", required = true)
private String states;
@ApiModelProperty(name = "属性ID集合", value = "属性ID集合", required = true)
private List<Long> attributeIdList;
}

View File

@ -4,6 +4,8 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.muyu.product.domain.model.AttributeGroupSaveModel;
import com.muyu.product.domain.model.Ids;
import com.muyu.product.domain.req.AttributeInfoEditReq;
import com.muyu.product.domain.resp.AttributeGroupPageResp;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
@ -98,8 +100,10 @@ public class AttributeGroupController extends BaseController {
@Log(title = "属性组", businessType = BusinessType.UPDATE)
@PutMapping("/{id}")
@ApiOperation("修改属性组")
public Result<String> edit(@PathVariable Long id, @RequestBody AttributeGroupEditReq attributeGroupEditReq) {
return toAjax(attributeGroupService.updateById(AttributeGroup.editBuild(id,attributeGroupEditReq)));
public Result<String> edit(@PathVariable Long id, @RequestBody AttributeGroupSaveReq attributeGroupSaveReq) {
// return toAjax(attributeGroupService.updateById(AttributeGroup.editBuild(id,attributeGroupEditReq)));
return toAjax(attributeGroupService.updateByIdss(id,attributeGroupSaveReq));
}
/**

View File

@ -3,6 +3,10 @@ package com.muyu.product.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.product.domain.AttributeGroup;
import com.muyu.product.domain.model.Ids;
import com.muyu.product.domain.req.AttributeGroupSaveReq;
import com.muyu.product.domain.req.AttributeInfoEditReq;
import org.apache.ibatis.annotations.Param;
/**
* Mapper
@ -11,5 +15,13 @@ import com.muyu.product.domain.AttributeGroup;
* @date 2024-02-27
*/
public interface AttributeGroupMapper extends BaseMapper<AttributeGroup> {
/**
* ()
*/
int updateByIds(@Param("id") Long id, @Param("attributeIdList") List<Long> attributeIdList);
/**
* ()
*/
int updateByIdss(@Param("id") Long id);
}

View File

@ -3,6 +3,8 @@ package com.muyu.product.service;
import java.util.List;
import com.muyu.product.domain.AsAttributeGroup;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.product.domain.req.AttributeGroupSaveReq;
import org.apache.ibatis.annotations.Param;
/**
* Service
@ -19,4 +21,5 @@ public interface AsAttributeGroupService extends IService<AsAttributeGroup> {
*/
public List<AsAttributeGroup> list(AsAttributeGroup asAttributeGroup);
}

View File

@ -1,13 +1,16 @@
package com.muyu.product.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.product.domain.AttributeGroup;
import com.muyu.product.domain.model.AttributeGroupSaveModel;
import com.muyu.product.domain.model.Ids;
import com.muyu.product.domain.req.AttributeGroupSaveReq;
import com.muyu.product.domain.req.AttributeInfoEditReq;
import com.muyu.product.domain.resp.AttributeGroupPageResp;
import java.util.List;
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.resp.AttributeGroupPageResp;
/**
* Service
@ -38,5 +41,10 @@ public interface AttributeGroupService extends IService<AttributeGroup> {
* @return
*/
public Boolean save(AttributeGroupSaveModel attributeGroupSaveModel);
/**
*
*/
int updateByIds(Ids id);
int updateByIdss(Long id, AttributeGroupSaveReq attributeGroupSaveReq);
}

View File

@ -3,6 +3,7 @@ package com.muyu.product.service.impl;
import java.util.List;
import com.muyu.common.core.utils.ObjUtils;
import com.muyu.product.domain.req.AttributeGroupSaveReq;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import com.muyu.product.mapper.AsAttributeGroupMapper;
@ -42,4 +43,6 @@ public class AsAttributeGroupServiceImpl extends ServiceImpl<AsAttributeGroupMap
return list(queryWrapper);
}
}

View File

@ -1,6 +1,7 @@
package com.muyu.product.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageInfo;
import com.muyu.common.core.utils.ObjUtils;
@ -9,6 +10,9 @@ 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.model.Ids;
import com.muyu.product.domain.req.AttributeGroupSaveReq;
import com.muyu.product.domain.req.AttributeInfoEditReq;
import com.muyu.product.domain.resp.AttributeGroupPageResp;
import com.muyu.product.mapper.AttributeGroupMapper;
import com.muyu.product.service.AsAttributeGroupService;
@ -38,6 +42,8 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
@Autowired
private AttributeInfoService attributeInfoService;
@Autowired
private AttributeGroupMapper attributeGroupMapper;
/**
*
@ -107,4 +113,25 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
);
return save;
}
/**
*
*/
@Override
public int updateByIds( Ids ids) {
return attributeGroupMapper.updateByIds(ids.getId(),ids.getAttributeIdList());
}
@Override
public int updateByIdss(Long id, AttributeGroupSaveReq attributeGroupSaveReq) {
attributeGroupMapper.updateByIdss(id);
List<Long> attributeIdList = attributeGroupSaveReq.getAttributeIdList();
attributeGroupService.saveBatch(
attributeIdList.stream()
.map(attributeId -> AsAttributeGroup.buildGroup(id, attributeId))
.toList()
);
return 0;
// return attributeGroupMapper.updateByIdss(id,attributeGroupSaveReq);
}
}

View File

@ -18,4 +18,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectAttributeGroupVo">
select id, name, states, create_by, create_time, updata_by, updata_time, remark from attribute_group
</sql>
<!-- 修改属性组(批量添加)-->
<insert id="updateByIds">
INSERT INTO `product`.`as_attribute_group`
( `group_id`, `attribute_id`) VALUES
<foreach collection="ids" item="e" separator=",">
( #{id}, #{e})
</foreach>
</insert>
<delete id="updateByIdss">
delete from as_attribute_group where
INSERT INTO `product`.`as_attribute_group`
( `group_id`, `attribute_id`) VALUES
<foreach collection="attributeGroupSaveReq" item="e" separator=",">
( #{id}, #{e.})
</foreach>
delete
</delete>
</mapper>