entity
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("device")
public class BK_DEVICE {
@ApiModelProperty(hidden = true)
@TableId(type = IdType.AUTO)
private Integer pid;
@ApiModelProperty(value = "设备类型", example = "W3RCB1")
private String category;
...
}
dao
- 代码注意 BaseMapper<对应实体类>
- @Select(=#{数据库字段名})
- @Param("数据库字段名")
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nqdl.nqdliot.model.entity.BK_DEVICE;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;
@Component
public interface BKDeviceDao extends BaseMapper<BK_DEVICE> {
@Select("SELECT `gtype` FROM `device` WHERE `gno` = #{gno}")
String getGatewayType(@Param("gno") String gno);
}
<?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.dao.BKDeviceDao">
<update id="方法名">
update db_talkativeplan.t_account set wechat=#{wechat} where uid=#{uid}
</update>
<update id="方法名">
update db_talkativeplan.t_account set qq=#{qq} where uid=#{uid}
</update>
<select id="方法名" resultType="com..entity.Account">
select * from t_account where uid=#{uid}
</select>
</mapper>
service
controller