Commit 020b48f9 authored by zengtianlai3's avatar zengtianlai3

添加创建时间并排序

parent 40b5e282
...@@ -51,12 +51,12 @@ public class DeviceController { ...@@ -51,12 +51,12 @@ public class DeviceController {
@ApiOperation(value = "添加设备接口", notes = "用于添加设备") @ApiOperation(value = "添加设备接口", notes = "用于添加设备")
@PostMapping("add") @PostMapping("add")
@ApiOperationSupport(params = @DynamicParameters(name = "jsonObject",properties = { @ApiOperationSupport(params = @DynamicParameters(name = "jsonObject",properties = {
@DynamicParameter(name = "appId",value = "应用Id",required = true,dataTypeClass = Integer.class), @DynamicParameter(name = "appId",value = "应用Id",required = true,dataTypeClass = String.class),
@DynamicParameter(name = "count",value = "需要创建的设备数量",required = true,dataTypeClass = Integer.class), @DynamicParameter(name = "count",value = "需要创建的设备数量",required = true,dataTypeClass = Integer.class),
})) }))
@MyLog(title = "添加设备", optParam = "#{jsonObject}", businessType = BusinessType.INSERT) @MyLog(title = "添加设备", optParam = "#{jsonObject}", businessType = BusinessType.INSERT)
public BaseResult addDevice(@RequestBody JSONObject jsonObject) { public BaseResult addDevice(@RequestBody JSONObject jsonObject) {
int appId = jsonObject.getIntValue("appId"); String appId = jsonObject.getString("appId");
int count = jsonObject.getIntValue("count"); int count = jsonObject.getIntValue("count");
boolean res = deviceService.addDevice(appId,count); boolean res = deviceService.addDevice(appId,count);
if (res) { if (res) {
......
package iot.sixiang.license.entity; package iot.sixiang.license.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
...@@ -9,6 +7,7 @@ import lombok.EqualsAndHashCode; ...@@ -9,6 +7,7 @@ import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* <p> * <p>
...@@ -27,8 +26,7 @@ public class Apply implements Serializable { ...@@ -27,8 +26,7 @@ public class Apply implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty("应用Id") @ApiModelProperty("应用Id")
@TableId(type = IdType.AUTO) private String appId;
private Integer appId;
@ApiModelProperty("应用名") @ApiModelProperty("应用名")
private String appName; private String appName;
...@@ -39,4 +37,11 @@ public class Apply implements Serializable { ...@@ -39,4 +37,11 @@ public class Apply implements Serializable {
@ApiModelProperty("用户Id") @ApiModelProperty("用户Id")
private Integer userId; private Integer userId;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
} }
...@@ -9,6 +9,7 @@ import lombok.EqualsAndHashCode; ...@@ -9,6 +9,7 @@ import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* <p> * <p>
...@@ -34,6 +35,13 @@ public class Device implements Serializable { ...@@ -34,6 +35,13 @@ public class Device implements Serializable {
private String sn; private String sn;
@ApiModelProperty("应用Id") @ApiModelProperty("应用Id")
private Integer appId; private String appId;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
} }
...@@ -2,11 +2,14 @@ package iot.sixiang.license.entity; ...@@ -2,11 +2,14 @@ package iot.sixiang.license.entity;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/** /**
* <p> * <p>
* *
...@@ -23,9 +26,13 @@ public class DeviceBlack implements Serializable { ...@@ -23,9 +26,13 @@ public class DeviceBlack implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
@ApiModelProperty("主键Id")
private Integer id; private Integer id;
@ApiModelProperty("设备Id")
private Integer deviceId; private Integer deviceId;
@ApiModelProperty("创建时间")
private Date createTime;
} }
...@@ -9,6 +9,7 @@ import lombok.EqualsAndHashCode; ...@@ -9,6 +9,7 @@ import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* <p> * <p>
...@@ -38,4 +39,11 @@ public class User implements Serializable { ...@@ -38,4 +39,11 @@ public class User implements Serializable {
@ApiModelProperty("公司") @ApiModelProperty("公司")
private String company; private String company;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
} }
...@@ -16,7 +16,7 @@ import java.util.List; ...@@ -16,7 +16,7 @@ import java.util.List;
*/ */
public interface ApplyMapper extends BaseMapper<Apply> { public interface ApplyMapper extends BaseMapper<Apply> {
boolean addApply(String appName, String appKey, int userId); boolean addApply(String appId, String appName, String appKey, int userId);
List<AppVo> getAppList(String appName); List<AppVo> getAppList(String appName);
......
...@@ -18,5 +18,5 @@ public interface DeviceMapper extends BaseMapper<Device> { ...@@ -18,5 +18,5 @@ public interface DeviceMapper extends BaseMapper<Device> {
List<DeviceVo> getDeviceList(String appName, String userName); List<DeviceVo> getDeviceList(String appName, String userName);
boolean addDevice(String sn, int appId); boolean addDevice(String sn, String appId);
} }
...@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* Created by m33 on 2022/6/8 13:35 * Created by m33 on 2022/6/8 13:35
...@@ -28,4 +29,10 @@ public class DeviceVo implements Serializable { ...@@ -28,4 +29,10 @@ public class DeviceVo implements Serializable {
@ApiModelProperty("设备状态 0:正常 1:禁用") @ApiModelProperty("设备状态 0:正常 1:禁用")
private int blackFlag; private int blackFlag;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
} }
...@@ -27,4 +27,7 @@ public class ResourceVo { ...@@ -27,4 +27,7 @@ public class ResourceVo {
@ApiModelProperty("设备编号") @ApiModelProperty("设备编号")
private String sn; private String sn;
@ApiModelProperty("应用id")
private String appId;
} }
\ No newline at end of file
...@@ -57,15 +57,15 @@ public class ResourceManager { ...@@ -57,15 +57,15 @@ public class ResourceManager {
cell.setCellValue("应用名称"); cell.setCellValue("应用名称");
cell.setCellStyle(style); cell.setCellStyle(style);
cell = row.createCell((short)2); //第个单元格 cell = row.createCell((short)2); //第个单元格
cell.setCellValue("app_id"); cell.setCellValue("app_id");
cell.setCellStyle(style); cell.setCellStyle(style);
cell = row.createCell((short)3); //第个单元格 cell = row.createCell((short)3); //第个单元格
cell.setCellValue("app_key"); cell.setCellValue("app_key");
cell.setCellStyle(style); cell.setCellStyle(style);
cell = row.createCell((short)4); //第个单元格 cell = row.createCell((short)4); //第个单元格
cell.setCellValue("sn"); cell.setCellValue("sn");
cell.setCellStyle(style); cell.setCellStyle(style);
//第五步插入数据 //第五步插入数据
...@@ -85,7 +85,7 @@ public class ResourceManager { ...@@ -85,7 +85,7 @@ public class ResourceManager {
cell.setCellStyle(style); cell.setCellStyle(style);
cell = row.createCell((short)2); // 第三个单元格 cell = row.createCell((short)2); // 第三个单元格
cell.setCellValue(resourceVo.getAppKey()); cell.setCellValue(resourceVo.getAppId());
cell.setCellStyle(style); cell.setCellStyle(style);
cell = row.createCell((short)3); // 第四个单元格 cell = row.createCell((short)3); // 第四个单元格
......
...@@ -17,5 +17,5 @@ public interface DeviceService extends IService<Device> { ...@@ -17,5 +17,5 @@ public interface DeviceService extends IService<Device> {
PageInfoModel<DeviceVo> getDeviceList(int pageNo, int pageSize, String appName, String userName); PageInfoModel<DeviceVo> getDeviceList(int pageNo, int pageSize, String appName, String userName);
boolean addDevice(int appId, int count); boolean addDevice(String appId, int count);
} }
...@@ -30,7 +30,7 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, Alarm> implements ...@@ -30,7 +30,7 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, Alarm> implements
throw new IotLicenseException(ResultCode.VALIDATE_FAILED.getCode(), ResultCode.VALIDATE_FAILED.getMsg()); throw new IotLicenseException(ResultCode.VALIDATE_FAILED.getCode(), ResultCode.VALIDATE_FAILED.getMsg());
} }
List<AlarmVo> alarmVos = alarmMapper.getAlarmList(userId); List<AlarmVo> alarmVos = alarmMapper.getAlarmList(userId);
alarmVos = alarmVos.stream().sorted(Comparator.comparing(AlarmVo::getId, Comparator.reverseOrder())).collect(Collectors.toList()); alarmVos = alarmVos.stream().sorted(Comparator.comparing(AlarmVo::getCreateTime, Comparator.reverseOrder())).collect(Collectors.toList());
return alarmVos; return alarmVos;
} }
} }
...@@ -9,6 +9,7 @@ import iot.sixiang.license.mapper.ApplyMapper; ...@@ -9,6 +9,7 @@ import iot.sixiang.license.mapper.ApplyMapper;
import iot.sixiang.license.model.PageInfoModel; import iot.sixiang.license.model.PageInfoModel;
import iot.sixiang.license.model.vo.AppVo; import iot.sixiang.license.model.vo.AppVo;
import iot.sixiang.license.service.ApplyService; import iot.sixiang.license.service.ApplyService;
import iot.sixiang.license.util.CommonUtil;
import iot.sixiang.license.util.SpringUtil; import iot.sixiang.license.util.SpringUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -42,7 +43,8 @@ public class ApplyServiceImpl extends ServiceImpl<ApplyMapper, Apply> implements ...@@ -42,7 +43,8 @@ public class ApplyServiceImpl extends ServiceImpl<ApplyMapper, Apply> implements
if (res != null) { if (res != null) {
throw new IotLicenseException(ResultCode.FAILED.getCode(),ResultCode.FAILED.getMsg()); throw new IotLicenseException(ResultCode.FAILED.getCode(),ResultCode.FAILED.getMsg());
} }
boolean re = applyMapper.addApply(appName, appKey, userId); String appId = CommonUtil.genRandomNum(18).toLowerCase();
boolean re = applyMapper.addApply(appId, appName, appKey, userId);
if (!re) { if (!re) {
return false; return false;
} }
...@@ -57,7 +59,7 @@ public class ApplyServiceImpl extends ServiceImpl<ApplyMapper, Apply> implements ...@@ -57,7 +59,7 @@ public class ApplyServiceImpl extends ServiceImpl<ApplyMapper, Apply> implements
throw new IotLicenseException(ResultCode.VALIDATE_FAILED.getCode(),ResultCode.VALIDATE_FAILED.getMsg()); throw new IotLicenseException(ResultCode.VALIDATE_FAILED.getCode(),ResultCode.VALIDATE_FAILED.getMsg());
} }
List<AppVo> records = applyMapper.getAppList(appName); List<AppVo> records = applyMapper.getAppList(appName);
records = records.stream().sorted(Comparator.comparing(AppVo::getAppId, Comparator.reverseOrder())).collect(Collectors.toList()); records = records.stream().sorted(Comparator.comparing(AppVo::getCreateTime, Comparator.reverseOrder())).collect(Collectors.toList());
List<AppVo> result = new ArrayList<>(); List<AppVo> result = new ArrayList<>();
int begin = (pageNo - 1) * pageSize; int begin = (pageNo - 1) * pageSize;
if (begin >= 0 && records.size() > 0) { if (begin >= 0 && records.size() > 0) {
......
...@@ -83,7 +83,7 @@ public class DeviceBlackServiceImpl extends ServiceImpl<DeviceBlackMapper, Devic ...@@ -83,7 +83,7 @@ public class DeviceBlackServiceImpl extends ServiceImpl<DeviceBlackMapper, Devic
throw new IotLicenseException(ResultCode.VALIDATE_FAILED.getCode(),ResultCode.VALIDATE_FAILED.getMsg()); throw new IotLicenseException(ResultCode.VALIDATE_FAILED.getCode(),ResultCode.VALIDATE_FAILED.getMsg());
} }
List<DeviceBlack> records = deviceBlackMapper.getDeviceBlackList(); List<DeviceBlack> records = deviceBlackMapper.getDeviceBlackList();
records = records.stream().sorted(Comparator.comparing(DeviceBlack::getId)).collect(Collectors.toList()); records = records.stream().sorted(Comparator.comparing(DeviceBlack::getCreateTime)).collect(Collectors.toList());
List<DeviceBlack> result = new ArrayList<>(); List<DeviceBlack> result = new ArrayList<>();
int begin = (pageNo - 1) * pageSize; int begin = (pageNo - 1) * pageSize;
if (begin >= 0 && records.size() > 0) { if (begin >= 0 && records.size() > 0) {
......
...@@ -11,6 +11,7 @@ import iot.sixiang.license.model.vo.DeviceVo; ...@@ -11,6 +11,7 @@ import iot.sixiang.license.model.vo.DeviceVo;
import iot.sixiang.license.service.DeviceService; import iot.sixiang.license.service.DeviceService;
import iot.sixiang.license.util.CommonUtil; import iot.sixiang.license.util.CommonUtil;
import iot.sixiang.license.util.SpringUtil; import iot.sixiang.license.util.SpringUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -39,7 +40,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme ...@@ -39,7 +40,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
throw new IotLicenseException(ResultCode.VALIDATE_FAILED.getCode(),ResultCode.VALIDATE_FAILED.getMsg()); throw new IotLicenseException(ResultCode.VALIDATE_FAILED.getCode(),ResultCode.VALIDATE_FAILED.getMsg());
} }
List<DeviceVo> deviceTypes = deviceMapper.getDeviceList(appName,userName); List<DeviceVo> deviceTypes = deviceMapper.getDeviceList(appName,userName);
deviceTypes = deviceTypes.stream().sorted(Comparator.comparing(DeviceVo::getDeviceId, Comparator.reverseOrder())).collect(Collectors.toList()); deviceTypes = deviceTypes.stream().sorted(Comparator.comparing(DeviceVo::getCreateTime, Comparator.reverseOrder())).collect(Collectors.toList());
List<DeviceVo> result = new ArrayList<>(); List<DeviceVo> result = new ArrayList<>();
int begin = (pageNo - 1) * pageSize; int begin = (pageNo - 1) * pageSize;
if (begin >= 0 && deviceTypes.size() > 0) { if (begin >= 0 && deviceTypes.size() > 0) {
...@@ -52,8 +53,8 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme ...@@ -52,8 +53,8 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
} }
@Override @Override
public boolean addDevice(int appId, int count) { public boolean addDevice(String appId, int count) {
if(appId == 0 || count == 0) { if(StringUtils.isEmpty(appId) || count == 0) {
throw new IotLicenseException(ResultCode.VALIDATE_FAILED.getCode(),ResultCode.VALIDATE_FAILED.getMsg()); throw new IotLicenseException(ResultCode.VALIDATE_FAILED.getCode(),ResultCode.VALIDATE_FAILED.getMsg());
} }
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
......
...@@ -42,7 +42,7 @@ public class SysOperLogServiceImpl extends ServiceImpl<SysOperLogMapper, SysOper ...@@ -42,7 +42,7 @@ public class SysOperLogServiceImpl extends ServiceImpl<SysOperLogMapper, SysOper
throw new IotLicenseException(ResultCode.VALIDATE_FAILED.getCode(),ResultCode.VALIDATE_FAILED.getMsg()); throw new IotLicenseException(ResultCode.VALIDATE_FAILED.getCode(),ResultCode.VALIDATE_FAILED.getMsg());
} }
List<SysOperLog> records = sysOperLogMapper.getOperLogList(); List<SysOperLog> records = sysOperLogMapper.getOperLogList();
records = records.stream().sorted(Comparator.comparing(SysOperLog::getId, Comparator.reverseOrder())).collect(Collectors.toList()); records = records.stream().sorted(Comparator.comparing(SysOperLog::getOperTime, Comparator.reverseOrder())).collect(Collectors.toList());
List<SysOperLog> result = new ArrayList<>(); List<SysOperLog> result = new ArrayList<>();
int begin = (pageNo - 1) * pageSize; int begin = (pageNo - 1) * pageSize;
if (begin >= 0 && records.size() > 0) { if (begin >= 0 && records.size() > 0) {
......
...@@ -39,7 +39,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us ...@@ -39,7 +39,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
throw new IotLicenseException(ResultCode.VALIDATE_FAILED.getCode(),ResultCode.VALIDATE_FAILED.getMsg()); throw new IotLicenseException(ResultCode.VALIDATE_FAILED.getCode(),ResultCode.VALIDATE_FAILED.getMsg());
} }
List<UserVo> records = userMapper.getUserList(userName,company); List<UserVo> records = userMapper.getUserList(userName,company);
records = records.stream().sorted(Comparator.comparing(UserVo::getUserId, Comparator.reverseOrder())).collect(Collectors.toList()); records = records.stream().sorted(Comparator.comparing(UserVo::getCreateTime, Comparator.reverseOrder())).collect(Collectors.toList());
List<UserVo> result = new ArrayList<>(); List<UserVo> result = new ArrayList<>();
int begin = (pageNo - 1) * pageSize; int begin = (pageNo - 1) * pageSize;
if (begin >= 0 && records.size() > 0) { if (begin >= 0 && records.size() > 0) {
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
<mapper namespace="iot.sixiang.license.mapper.ApplyMapper"> <mapper namespace="iot.sixiang.license.mapper.ApplyMapper">
<sql id="AppVoColumn"> <sql id="AppVoColumn">
app.app_id, app.app_name, app.app_key, us.user_id, app.app_id, app.app_name, app.app_key, app.create_time, app.update_time, us.user_id,
COUNT(sn) AS deviceCount, us.user_name, us.company COUNT(sn) AS deviceCount, us.user_name, us.company
</sql> </sql>
<insert id="addApply" parameterType="iot.sixiang.license.entity.Apply"> <insert id="addApply" parameterType="iot.sixiang.license.entity.Apply">
insert into apply(app_name, app_key, user_id) values (#{appName}, #{appKey}, #{userId}) insert into apply(app_id,app_name, app_key, user_id, create_time, update_time) values (#{appId}, #{appName}, #{appKey}, #{userId}, now(), now())
</insert> </insert>
<select id="getAppList" resultType="iot.sixiang.license.model.vo.AppVo"> <select id="getAppList" resultType="iot.sixiang.license.model.vo.AppVo">
SELECT <include refid="AppVoColumn"/> SELECT <include refid="AppVoColumn"/>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<mapper namespace="iot.sixiang.license.mapper.DeviceBlackMapper"> <mapper namespace="iot.sixiang.license.mapper.DeviceBlackMapper">
<insert id="addDeviceBlack" parameterType="iot.sixiang.license.entity.DeviceBlack"> <insert id="addDeviceBlack" parameterType="iot.sixiang.license.entity.DeviceBlack">
insert into device_black(device_id) values (#{deviceId}) insert into device_black(device_id, create_time) values (#{deviceId}, now())
</insert> </insert>
<delete id="deleteDeviceBlack" parameterType="iot.sixiang.license.entity.DeviceBlack"> <delete id="deleteDeviceBlack" parameterType="iot.sixiang.license.entity.DeviceBlack">
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
</delete> </delete>
<select id="getDeviceBlackList" resultType="iot.sixiang.license.entity.DeviceBlack"> <select id="getDeviceBlackList" resultType="iot.sixiang.license.entity.DeviceBlack">
select id, device_id from device_black select id, device_id, create_time from device_black
</select> </select>
</mapper> </mapper>
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<mapper namespace="iot.sixiang.license.mapper.DeviceMapper"> <mapper namespace="iot.sixiang.license.mapper.DeviceMapper">
<select id="getDeviceList" resultType="iot.sixiang.license.model.vo.DeviceVo"> <select id="getDeviceList" resultType="iot.sixiang.license.model.vo.DeviceVo">
SELECT de.device_id,app_name,user_name,sn,de.device_id IN (select device_id from device_black) AS blackFlag FROM device AS de SELECT de.device_id,app_name,user_name,sn,de.create_time,de.update_time,de.device_id IN (select device_id from device_black) AS blackFlag FROM device AS de
JOIN apply AS app ON de.app_id = app.app_id JOIN apply AS app ON de.app_id = app.app_id
JOIN USER AS us ON us.user_id = app.user_id JOIN USER AS us ON us.user_id = app.user_id
where 1=1 where 1=1
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
</select> </select>
<insert id="addDevice" parameterType="iot.sixiang.license.entity.Device"> <insert id="addDevice" parameterType="iot.sixiang.license.entity.Device">
insert into device(sn, app_id) values (#{sn},#{appId}) insert into device(sn, app_id, create_time, update_time) values (#{sn},#{appId}, now(), now())
</insert> </insert>
</mapper> </mapper>
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<mapper namespace="iot.sixiang.license.mapper.ResourceMapper"> <mapper namespace="iot.sixiang.license.mapper.ResourceMapper">
<select id="getResource" resultType="iot.sixiang.license.model.vo.ResourceVo"> <select id="getResource" resultType="iot.sixiang.license.model.vo.ResourceVo">
SELECT a.user_name,a.password,a.company,b.app_name,b.app_key,c.sn SELECT a.user_name,a.password,a.company,b.app_name,b.app_key,c.sn, b.app_id
FROM USER a, apply b, device c WHERE a.user_id = b.user_id FROM USER a, apply b, device c WHERE a.user_id = b.user_id
AND b.app_id = c.app_id AND a.user_id = #{userId} AND b.app_id = c.app_id AND a.user_id = #{userId}
</select> </select>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<mapper namespace="iot.sixiang.license.mapper.UserMapper"> <mapper namespace="iot.sixiang.license.mapper.UserMapper">
<insert id="addUser" parameterType="iot.sixiang.license.entity.User"> <insert id="addUser" parameterType="iot.sixiang.license.entity.User">
insert into user(user_name, company, password) values (#{userName},#{company}, #{password}) insert into user(user_name, company, password,create_time, update_time) values (#{userName},#{company}, #{password}, now(), now())
</insert> </insert>
<delete id="deleteUser" parameterType="iot.sixiang.license.entity.User"> <delete id="deleteUser" parameterType="iot.sixiang.license.entity.User">
...@@ -11,11 +11,11 @@ ...@@ -11,11 +11,11 @@
</delete> </delete>
<update id="updateUser" parameterType="iot.sixiang.license.entity.User"> <update id="updateUser" parameterType="iot.sixiang.license.entity.User">
update user set password = #{password} where user_id = #{userId} update user set password = #{password}, update_time = now() where user_id = #{userId}
</update> </update>
<select id="getUserList" resultType="iot.sixiang.license.model.vo.UserVo"> <select id="getUserList" resultType="iot.sixiang.license.model.vo.UserVo">
SELECT user.user_id, user_name, password, company, COUNT(app_name) AS appCount SELECT user.user_id, user_name, password, company, user.create_time, user.update_time,app_id, COUNT(app_name) AS appCount
FROM USER LEFT JOIN apply ON user.user_id = apply.user_id FROM USER LEFT JOIN apply ON user.user_id = apply.user_id
where 1=1 where 1=1
<if test="null != userName and '' != userName"> <if test="null != userName and '' != userName">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment