————获取所有的数据
@GetMapping("/getAll1")
public AjaxResult list1(String name,String userId) {
User user = userMapper.selectByPrimaryKey(Integer.valueOf(userId));
Map<String,String> param = new HashMap<String, String>();
param.put("name", name);
param.put("parentId", "0");
if(!user.getType().equals(1)) {
param.put("userId", userId);
}
List<Application> list = applicationMapper.wxSelectData(param);
return AjaxResult.success(list);
}
List<Application> wxSelectData(@Param("param") Map<String, String> param);
<select id="wxSelectData" parameterType="hashmap" resultType="com.ruoyi.weixin.model.Application">
select id,name,icon,parent_id parentId,type from application
where parent_id=#{param.parentId}
<if test="param.name!=null and param.name !=''">
and name like '%${param.name}%'
</if>
<if test="param.userId!=null and param.userId !=''">
and id in (select application_id from application_user where user_id = #{param.userId})
</if>
</select>
----------------删除数据
@PostMapping(value = "save")
@ApiOperation(value = "修改保存应用")
public AjaxResult save(@RequestBody User user)
{
applicationUserMapper.deleteApplicationUserByUserId(user.getId());
for(Integer i: user.getCheckedKeys()){
applicationUserMapper.insert(new ApplicationUser(user.getId(),i,null));
}
return AjaxResult.success("修改成功");
}
void deleteApplicationUserByUserId(@Param("userId") Integer userId);
<delete id="deleteApplicationUserByUserId" parameterType="int">
delete from application_user where
user_id=#{userId}
</delete>
---------返回Map 类型,返回单条记录为Map
public Map<String, Object> selectEmployee(Integer id);
<select id="selectEmployee" resultType="java.util.Map">
select * from employee where id=#{id}
</select>
----执意任意的SQL查询语句,返回List<HashMap<String,Object>>对象
List<Map<String,Object>> CommonQuery(@Param(value = "strsql") String strsql);
<select id="CommonQuery" resultType="hashmap" >
<![CDATA[ ${strsql}]]>
</select>
StringBuilder sb = new StringBuilder(“SELECT af.DATA1 ‘total’,af.EFFECT_DATE1000 ‘aDate’,af.DATA2 ‘instantValue’,af.DATA4 ‘reverseValue’,af.DATA3 ‘positiveValue’,af.DATA6 ‘hydraulicValue’,af.STATUS
‘mStatus’,");
sb.append(" ii.NAME
‘iName’,ii.I_ID ‘iId’,");
sb.append(" ie.NAME
‘eName’,ie.STATUS
‘iStatus’,ie.ELECTRICITY ‘electricity’,ie.E_Id ‘iPhone’,ie.TIME1000 ‘updateTime’,ie.SIGNAL_VALUE ‘signalValue’,”);
sb.append(" de.NAME
‘dName’");
sb.append(" FROM i_instrument ii");
sb.append(" left join i_equipment ie");
sb.append(" ON ii.E_ID = ie.E_ID");
sb.append(" LEFT JOIN d_enterprise de");
sb.append(" ON ii.ENT_ID = de.E_ID");
sb.append(" LEFT JOIN “+type+” af");
sb.append(" ON ii.I_ID = af.I_ID");
sb.append(" where 1=1 “);
sb.append(” AND af.M_ID IS NOT NULL ");
sb.toString();
------返回多个map
List<Map<String, Object>> getWaterInfo(@Param("iId")String iId);
<select id="getWaterInfo" resultType="map">
SELECT <include refid="Base_Column_List" />
FROM h_flow
WHERE I_ID = #{iId}
ORDER BY D_DATE DESC
</select>
—————–删除
void deleteDeviceTypeByPid(@Param("pid")Integer pid);
<delete id="deleteDeviceTypeByPid" parameterType="int">
delete from device_type where
pid=#{pid}
</delete>