<?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.java1234.mapper.SmallTypeMapper">
<resultMap id="smallTypeResult" type="com.java1234.entity.SmallType">
<association property="bigType" column="bigTypeId" select="com.java1234.mapper.BigTypeMapper.findById">
</association>
</resultMap>
<select id="list" parameterType="Map" resultMap="smallTypeResult">
select * from t_smallType
<where>
<if test="name!=null and name!='' ">
and name like concat('%',#{name},'%')
</if>
</where>
<if test="start!=null and pageSize!=null">
limit #{start},#{pageSize}
</if>
</select>
<select id="getTotal" parameterType="Map" resultType="Long">
select count(*) from t_smallType
<where>
<if test="name!=null and name!='' ">
and name like concat('%',#{name},'%')
</if>
</where>
</select>
<insert id="add" parameterType="com.java1234.entity.SmallType">
insert into t_smallType values(null,#{name},#{remark},#{bigType.id});
</insert>
<update id="update" parameterType="com.java1234.entity.SmallType">
update t_smallType
<set>
<if test="name!=null and name!=''">
name=#{name},
</if>
<if test="remark!=null and remark!=''">
remark=#{remark},
</if>
<if test="bigType.id!=null">
bigTypeId=#{bigType.id},
</if>
</set>
where id=#{id}
</update>
</mapper>
package com.java1234.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.java1234.entity.BigType;
import com.java1234.entity.SmallType;
import java.util.List;
import java.util.Map;
/**
* 商品小类Mapper接口
*/
public interface SmallTypeMapper extends BaseMapper<SmallType> {
List<SmallType> list(Map<String, Object> map);
Long getTotal(Map<String, Object> map);
/**
* 添加商品小类
* @param smallType
* @return
*/
public Integer add(SmallType smallType);
/**
* 修改商品小类
* @param smallType
* @return
*/
public Integer update(SmallType smallType);
}
package com.java1234.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.java1234.entity.SmallType;
import com.java1234.mapper.SmallTypeMapper;
import com.java1234.service.ISmallTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* 商品小类Service实现类
*/
@Service("smallTypeService")
public class ISmallTypeServiceImpl extends ServiceImpl<SmallTypeMapper, SmallType> implements ISmallTypeService {
@Autowired
private SmallTypeMapper smallTypeMapper;
@Override
public List<SmallType> list(Map<String, Object> map) {
return smallTypeMapper.list(map);
}
@Override
public Long getTotal(Map<String, Object> map) {
return small