screen-api
SQL优化
screen-manage
日志模块更新,SQL优化
5 files added
25 files modified
| | |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | |
| | | /** |
| | | * @Description: 根据mac查询报警信息 |
| | | * @Param: [mac] |
| | | * @return: com.moral.constant.ResultMessage |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/8/23 |
| | | */ |
| | | @GetMapping("queryAlarmByMac") |
| | | public ResultMessage queryAlarmByMac(String mac) { |
| | | if(mac==null) |
| | | return new ResultMessage(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg(),null); |
| | | List<Sensor> sensors = organizationUnitAlarmService.queryAlarmLevel(mac); |
| | | AlarmLevelVO vo = AlarmLevelVO.convert(sensors); |
| | | return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(), vo); |
| | |
| | | package com.moral.api.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.moral.api.entity.HistoryFiveMinutely; |
| | | import com.moral.api.entity.Sensor; |
| | | import com.moral.api.entity.Test; |
| | | import com.moral.api.mapper.HistoryFiveMinutelyMapper; |
| | | import com.moral.api.mapper.SensorMapper; |
| | | import com.moral.api.service.TestService; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.ResultMessage; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.kafka.core.KafkaTemplate; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.servlet.handler.WebRequestHandlerInterceptorAdapter; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | |
| | | @Slf4j |
| | |
| | | |
| | | @Autowired |
| | | private TestService testService; |
| | | |
| | | @Autowired |
| | | private SensorMapper sensorMapper; |
| | | |
| | | @Autowired |
| | | private HistoryFiveMinutelyMapper historyFiveMinutelyMapper; |
| | |
| | | |
| | | @GetMapping("test") |
| | | public void test(){ |
| | | QueryWrapper<HistoryFiveMinutely> queryWrapper = new QueryWrapper<>(); |
| | | List<HistoryFiveMinutely> historyFiveMinutelies = historyFiveMinutelyMapper.selectList(queryWrapper); |
| | | System.out.println(1111); |
| | | |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.entity; |
| | | |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.sql.Time; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * </p> |
| | | * |
| | | * @author moral |
| | | * @since 2021-06-07 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class DeviceAdjustValue extends Model<DeviceAdjustValue> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 序号 |
| | | */ |
| | | private Integer id; |
| | | |
| | | /** |
| | | * 设备id |
| | | */ |
| | | private String mac; |
| | | |
| | | /** |
| | | * 开始时间 |
| | | */ |
| | | @DateTimeFormat(pattern = "HH:mm:ss") |
| | | @JsonFormat(pattern = "HH:mm:ss",timezone = "GMT+8") |
| | | private Time startTime; |
| | | |
| | | /** |
| | | * 结束时间 |
| | | */ |
| | | private Time endTime; |
| | | |
| | | /** |
| | | * 传感器 |
| | | */ |
| | | private String sensorCode; |
| | | |
| | | /** |
| | | * 公式 |
| | | */ |
| | | private String value; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 更新时间 |
| | | */ |
| | | private Date updateTime; |
| | | |
| | | /** |
| | | * 是否删除 |
| | | */ |
| | | private String isDelete; |
| | | |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import java.time.LocalDateTime; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private LocalDateTime createTime; |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 更新时间 |
| | | */ |
| | | private LocalDateTime updateTime; |
| | | private Date updateTime; |
| | | |
| | | /** |
| | | * 是否删除 |
| | |
| | | public void listen(ConsumerRecord<String, String> record, Consumer consumer) throws Exception { |
| | | String messageStr = record.value(); |
| | | Map<String, Object> message = (Map<String, Object>) JSON.parse(messageStr); |
| | | long serverStartTime = System.currentTimeMillis(); |
| | | //long serverStartTime = System.currentTimeMillis(); |
| | | CopyOnWriteArraySet<SingleDeviceServer> sockets = SingleDeviceServer.sockets; |
| | | for (SingleDeviceServer socket : sockets) { |
| | | //判断消息是否数据该socket |
| | |
| | | if (!mac.equalsIgnoreCase(messageMac)) |
| | | continue; |
| | | //取出基本信息 |
| | | Map<String, Device> devicesInfo = socket.getDevicesInfo(); |
| | | Device device = devicesInfo.get(mac); |
| | | Device device = socket.getDeviceAlarmInfo(); |
| | | //创建最终消息对象 |
| | | Map<String, Object> resultMessgae = new HashMap<>(); |
| | | //拼接单位 |
| | |
| | | //获取监测因子趋势图数据 |
| | | List<Map<String, Object>> getTrendChartData(Map<String,Object> params); |
| | | |
| | | //通过mac获取设备信息 |
| | | Device getDeviceByMac(String mac); |
| | | |
| | | } |
| | |
| | | public interface MonitorPointService extends IService<MonitorPoint> { |
| | | |
| | | /** |
| | | * @Description: 根据组织id和地区码查询站点和设备 |
| | | * @Description: 根据组织id和地区码(非必须条件)查询站点和设备 |
| | | * @Param: [form] |
| | | * @return: java.util.List<com.moral.api.entity.MonitorPoint> |
| | | * @Author: 陈凯裕 |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.moral.api.entity.Device; |
| | | import com.moral.api.entity.Sensor; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | |
| | |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public Device getDeviceByMac(String mac) { |
| | | Map<String,Object> deviceMap = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.DEVICE,mac); |
| | | Device device = JSON.parseObject(JSON.toJSONString(deviceMap), Device.class); |
| | | //从map获取organizationId和monitorPointId以及versionId |
| | | Map<String,Object> organizationMap = (Map<String,Object>)deviceMap.get("organization"); |
| | | Map<String,Object> monitorPointMap = (Map<String,Object>)deviceMap.get("monitorPoint"); |
| | | Map<String,Object> versionMap = (Map<String,Object>)deviceMap.get("version"); |
| | | device.setDeviceVersionId((Integer) versionMap.get("id")); |
| | | device.setOrganizationId((Integer) organizationMap.get("id")); |
| | | device.setMonitorPointId((Integer) monitorPointMap.get("id")); |
| | | //如果缓存为空则查询数据库 |
| | | if(ObjectUtils.isEmpty(device)){ |
| | | return getDeviceByMacFromDB(mac); |
| | | } |
| | | return device; |
| | | } |
| | | |
| | | private Device getDeviceByMacFromDB(String mac){ |
| | | QueryWrapper<Device> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("mac",mac); |
| | | wrapper.eq("is_delete",Constants.NOT_DELETE); |
| | | return deviceMapper.selectOne(wrapper); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | public Map<String, Object> getHourlyAqiByMac(String mac) { |
| | | QueryWrapper<HistoryHourly> queryWrapper = new QueryWrapper<>(); |
| | | String time = DateUtils.dateToDateString(new Date(), DateUtils.yyyy_MM_dd_HH_EN) + ":00:00"; |
| | | queryWrapper.eq("mac", mac).eq("time", time); |
| | | queryWrapper.eq("time", time).eq("mac", mac); |
| | | //获取小时数据 |
| | | HistoryHourly historyHourly = historyHourlyMapper.selectOne(queryWrapper); |
| | | Map<String, Object> result = new HashMap<>(); |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.io.BufferedWriter; |
| | | import java.io.File; |
| | | import java.io.FileWriter; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | QueryWrapper<MonitorPoint> queryMonitorPointsWrapper = new QueryWrapper<>(); |
| | | |
| | | //如果region不为空,就查询当前组织,所选城市下所有站点及设备信息 |
| | | //如果region为空,则查询当前组织下所有的站点和设备 |
| | | if (region != null){ |
| | | queryMonitorPointsWrapper.eq(region, regionCode); |
| | | } |
| | |
| | | queryWrapper.eq(RegionCodeUtils.regionCodeConvertToName(regionCode), regionCode); |
| | | return monitorPointMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | @Override |
| | | public Organization getStateControlStation() { |
| | | QueryWrapper<Organization> wrapper = new QueryWrapper<>(); |
| | | wrapper.select("id"); |
| | | wrapper.eq("name","国控站"); |
| | | wrapper.eq("is_delete",Constants.NOT_DELETE); |
| | | Organization organization = organizationMapper.selectOne(wrapper); |
| | |
| | | */ |
| | | private void recursionQueryChildren(Integer parentId, List<Organization> children) { |
| | | QueryWrapper<Organization> queryWrapper = new QueryWrapper(); |
| | | queryWrapper.select("id"); |
| | | queryWrapper.eq("is_delete", Constants.NOT_DELETE); |
| | | queryWrapper.eq("parent_id", parentId); |
| | | List<Organization> organizations = organizationMapper.selectList(queryWrapper); |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.moral.api.entity.Device; |
| | | import com.moral.api.entity.OrganizationUnitAlarm; |
| | | import com.moral.api.entity.Sensor; |
| | | import com.moral.api.entity.Version; |
| | | import com.moral.api.mapper.OrganizationUnitAlarmMapper; |
| | | import com.moral.api.service.DeviceService; |
| | | import com.moral.api.service.OrganizationUnitAlarmService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.RedisConstants; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | RedisTemplate redisTemplate; |
| | | @Autowired |
| | | DeviceService deviceService; |
| | | @Autowired |
| | | OrganizationUnitAlarmMapper organizationUnitAlarmMapper; |
| | | |
| | | /** |
| | | * @Description: 从缓存查询设备报警信息 |
| | | * @Param: [mac] |
| | | * @return: java.util.List<com.moral.api.entity.Sensor> |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/8/23 |
| | | */ |
| | | @Override |
| | | public List<Sensor> queryAlarmLevel(String mac) { |
| | | Device device = (Device) redisTemplate.opsForHash().get(RedisConstants.DEVICE_INFO, mac); |
| | | Version version = device.getVersion(); |
| | | List<Sensor> sensors = version.getSensors(); |
| | | //如果缓存中不存在则在数据库中查询 |
| | | if (ObjectUtils.isEmpty(sensors)) { |
| | | sensors = queryAlarmLevelFromDb(mac); |
| | | } |
| | | return sensors; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @Description: 从数据库获取设备报警信息 |
| | | * @Param: [mac] |
| | | * @return: java.util.List<com.moral.api.entity.Sensor> |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/8/23 |
| | | */ |
| | | private List<Sensor> queryAlarmLevelFromDb(String mac) { |
| | | Device device = deviceService.getDeviceByMac(mac); |
| | | Integer organizationId = device.getOrganizationId(); |
| | | Integer deviceVersionId = device.getDeviceVersionId(); |
| | | QueryWrapper<OrganizationUnitAlarm> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("organization_id", organizationId); |
| | | wrapper.eq("version_id", deviceVersionId); |
| | | wrapper.eq("is_delete", Constants.NOT_DELETE); |
| | | List<OrganizationUnitAlarm> organizationUnitAlarms = organizationUnitAlarmMapper.selectList(wrapper); |
| | | List<Sensor> sensors = new ArrayList<>(); |
| | | //仅需要sensorcode和alarmlevel数据 |
| | | for (OrganizationUnitAlarm organizationUnitAlarm : organizationUnitAlarms) { |
| | | Sensor sensor = new Sensor(); |
| | | sensor.setCode(organizationUnitAlarm.getSensorCode()); |
| | | sensor.setAlarmLevel(organizationUnitAlarm.getAlarmLevel()); |
| | | sensors.add(sensor); |
| | | } |
| | | return sensors; |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.api.utils; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.googlecode.aviator.AviatorEvaluator; |
| | | import com.googlecode.aviator.Expression; |
| | | import com.moral.api.entity.DeviceAdjustValue; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.util.DateUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Slf4j |
| | | @Component |
| | | public class AdjustDataUtils { |
| | | /** |
| | | * @param deviceData 设备数据 |
| | | * @param adjustFormula 校准公式 |
| | | * @param aqiMap 设备所在地区对应的墨迹aqi数据 |
| | | * @return Map<String, Object> 校准后数据 |
| | | * */ |
| | | public Map<String, Object> adjust(Map<String, Object> deviceData, Map<String, Object> adjustFormula, Map<String, Object> aqiMap) { |
| | | try { |
| | | Date time = DateUtils.getDate((String) deviceData.get("DataTime"), DateUtils.yyyyMMddHHmmss_EN); |
| | | long finalTime = DateUtils.dataToTimeStampTime(time, DateUtils.HH_mm_ss_EN).getTime(); |
| | | for (String key : deviceData.keySet()) { |
| | | if (!key.equals("mac") && !key.equals("time") && !key.equals("DataTime") && !key.equals("ver") && !key.contains("Flag")) { |
| | | //测量值 |
| | | Object measuredValue = deviceData.get(key); |
| | | //单个因子校准公式 |
| | | List<DeviceAdjustValue> sensorFormulas = (List<DeviceAdjustValue>) adjustFormula.get(key); |
| | | if (ObjectUtils.isEmpty(sensorFormulas)) { |
| | | deviceData.put(key, measuredValue); |
| | | continue; |
| | | } |
| | | |
| | | //根据时间段筛选校准公式 |
| | | DeviceAdjustValue deviceAdjustValue = sensorFormulas.stream() |
| | | .filter(o -> o.getStartTime().getTime() <= finalTime && o.getEndTime().getTime() > finalTime) |
| | | .findFirst().get(); |
| | | String formula = deviceAdjustValue.getValue(); |
| | | if (StringUtils.isEmpty(formula)) { |
| | | deviceData.put(key, measuredValue); |
| | | continue; |
| | | } |
| | | |
| | | Expression expression = AviatorEvaluator.compile(formula); |
| | | Map<String, Object> env = new HashMap<>(); |
| | | if (formula.contains("aqi")) { |
| | | Object aqiValue = null; |
| | | if (aqiMap != null) { |
| | | aqiValue = aqiMap.get(key); |
| | | } |
| | | env.put("aqi", ObjectUtils.isEmpty(aqiValue) ? 0F : Float.parseFloat((String) aqiValue)); |
| | | } |
| | | if (formula.contains("vocs")) { |
| | | Object vocsValue = ObjectUtils.isEmpty(deviceData.get(Constants.SENSOR_CODE_VOCS)) ? 0F : deviceData.get(Constants.SENSOR_CODE_VOCS); |
| | | env.put("vocs", vocsValue); |
| | | } |
| | | if (formula.contains("cel")) { |
| | | env.put("cel", Float.parseFloat((String) measuredValue)); |
| | | } |
| | | //校准 |
| | | measuredValue = expression.execute(env); |
| | | //温度处理 |
| | | if (!Constants.SENSOR_CODE_TEMP.equals(measuredValue) && Float.parseFloat(measuredValue.toString()) < 0) { |
| | | measuredValue = 0F; |
| | | } |
| | | deviceData.put(key, Double.parseDouble(String.format("%.4f", measuredValue))); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("param[0] deviceData:" + JSON.toJSONString(deviceData)); |
| | | log.error(e.getMessage()); |
| | | } |
| | | return deviceData; |
| | | } |
| | | } |
| | |
| | | package com.moral.api.websocket; |
| | | |
| | | import com.moral.api.entity.Device; |
| | | import com.moral.api.entity.MonitorPoint; |
| | | import com.moral.api.entity.Sensor; |
| | | import com.moral.api.entity.UnitConversion; |
| | | import com.moral.constant.RedisConstants; |
| | | import lombok.Data; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | |
| | | import javax.websocket.*; |
| | |
| | | |
| | | private String mac; |
| | | |
| | | private Map<String, Device> devicesInfo; |
| | | private Device deviceAlarmInfo; |
| | | |
| | | private List<UnitConversion> unitConversions; |
| | | |
| | | private Map<String, Object> regionAqi; |
| | | |
| | | @OnOpen |
| | | public void onOpen(Session session, @PathParam("mac") String mac) throws Exception { |
| | | this.session = session; |
| | | this.mac = mac; |
| | | this.devicesInfo = redisTemplate.opsForHash().entries(RedisConstants.DEVICE_INFO); |
| | | this.deviceAlarmInfo = (Device) redisTemplate.opsForHash().get(RedisConstants.DEVICE_INFO, mac); |
| | | this.unitConversions = redisTemplate.opsForList().range(RedisConstants.UNIT_CONVERSION, 0, -1); |
| | | //获取设备地区对应的AQI用于补偿使用 |
| | | Map<String, Object> deviceInfo = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.DEVICE, mac); |
| | | Map<String, Object> monitorPointMap = (Map<String, Object>) deviceInfo.get("monitorPoint"); |
| | | String areaCode = String.valueOf(monitorPointMap.get("areaCode")); |
| | | String cityCode = String.valueOf(monitorPointMap.get("cityCode")); |
| | | try { |
| | | this.regionAqi = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.AQI_DATA, areaCode); |
| | | if (ObjectUtils.isEmpty(this.regionAqi)) |
| | | this.regionAqi = (Map<String, Object>) redisTemplate.opsForHash().get(RedisConstants.AQI_DATA, cityCode); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | sockets.add(this); |
| | | System.out.println(mac); |
| | | } |
| | | } |
| | | |
| | | @OnClose |
| | | public void onClose() { |
New file |
| | |
| | | package com.moral.anno; |
| | | |
| | | import java.lang.annotation.Retention; |
| | | import java.lang.annotation.RetentionPolicy; |
| | | |
| | | /** |
| | | * @Description: 该注解用于标注实体类属性的中文名称,用于插入日志使用 |
| | | * @Param: |
| | | * @return: |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/8/24 |
| | | */ |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | public @interface FieldName { |
| | | String value() default ""; |
| | | } |
New file |
| | |
| | | package com.moral.pojo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @ClassName CompareFieldResult |
| | | * @Description 对比两个对象属性不同结果的bean |
| | | * @Author 陈凯裕 |
| | | * @Date 2021/8/24 14:00 |
| | | * @Version TODO |
| | | **/ |
| | | @Data |
| | | public class CompareFieldResult { |
| | | /* |
| | | * 属性名称 |
| | | * */ |
| | | private String fieldName; |
| | | |
| | | /* |
| | | * 对象属性上fieldName注解中的值 |
| | | * */ |
| | | private String fieldAnnoName; |
| | | |
| | | /* |
| | | * 旧对象的值 |
| | | * */ |
| | | private String oldData; |
| | | |
| | | /* |
| | | * 新对象的值 |
| | | * */ |
| | | private String newData; |
| | | } |
| | |
| | | void insertHistoryHourly(List<HistoryHourly> list); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | import java.util.Date; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.moral.anno.FieldName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | |
| | | /** |
| | | * 用户名称 |
| | | */ |
| | | @FieldName("用户名称") |
| | | private String userName; |
| | | |
| | | /** |
| | | * 邮箱 |
| | | */ |
| | | @FieldName("邮箱") |
| | | private String email; |
| | | |
| | | /** |
| | | * 手机号 |
| | | */ |
| | | @FieldName("手机号") |
| | | private String mobile; |
| | | |
| | | /** |
| | | * 微信 |
| | | */ |
| | | @FieldName("微信") |
| | | private String wechat; |
| | | |
| | | /** |
| | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import java.time.LocalDateTime; |
| | | import java.io.Serializable; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import com.moral.anno.FieldName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | |
| | | /** |
| | | * 菜单名 |
| | | */ |
| | | @FieldName("菜单名称") |
| | | private String name; |
| | | |
| | | /** |
| | | * url地址 |
| | | */ |
| | | @FieldName("url") |
| | | private String url; |
| | | |
| | | /** |
| | | * 图标地址 |
| | | */ |
| | | @FieldName("图标url") |
| | | private String icon; |
| | | |
| | | /** |
| | | * 父菜单 |
| | | */ |
| | | @FieldName("父菜单id") |
| | | private Integer parentId; |
| | | |
| | | /** |
| | | * 同一级别菜单的顺序 |
| | | */ |
| | | @FieldName("菜单顺序") |
| | | @TableField(value="`order`") |
| | | private Integer order; |
| | | |
| | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | import com.moral.anno.FieldName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | |
| | | /** |
| | | * 用户名称 |
| | | */ |
| | | @FieldName("用户名称") |
| | | private String userName; |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 邮箱 |
| | | */ |
| | | @FieldName("邮箱") |
| | | private String email; |
| | | |
| | | /** |
| | | * 手机号 |
| | | */ |
| | | @FieldName("手机") |
| | | private String mobile; |
| | | |
| | | /** |
| | | * 微信 |
| | | */ |
| | | @FieldName("微信") |
| | | private String wechat; |
| | | |
| | | /** |
| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.config.mybatis.wrapper.NullFilterWrapper; |
| | | import com.moral.api.service.ManageMenuService; |
| | | import com.moral.api.util.CompareFieldUtils; |
| | | import com.moral.api.util.LogUtils; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.pojo.CompareFieldResult; |
| | | import com.moral.util.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | |
| | | //查询是否存在 |
| | | QueryWrapper<ManageAccount> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("account", account); |
| | | wrapper.eq("is_delete",Constants.NOT_DELETE); |
| | | wrapper.eq("is_delete", Constants.NOT_DELETE); |
| | | wrapper.select("id", "password"); |
| | | ManageAccount manageAccount = manageAccountMapper.selectOne(wrapper); |
| | | if (ObjectUtils.isEmpty(manageAccount)) { |
| | | loginDTO.setCode(ResponseCodeEnum.ACCOUNT_NOT_EXIST.getCode()); |
| | |
| | | } |
| | | ); |
| | | } |
| | | //操作插入日志 |
| | | insertLog(manageAccount); |
| | | //封装返回结果 |
| | | accountDTO.setCode(ResponseCodeEnum.SUCCESS.getCode()); |
| | | accountDTO.setMsg(ResponseCodeEnum.SUCCESS.getMsg()); |
| | | |
| | | //操作插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("添加了用户:").append(manageAccount.getUserName() + ";") |
| | | .append("account:" + manageAccount.getAccount() + ";"); |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | |
| | | return accountDTO; |
| | | } |
| | | |
| | |
| | | accountDTO.setCode(ResponseCodeEnum.SUCCESS.getCode()); |
| | | accountDTO.setMsg(ResponseCodeEnum.SUCCESS.getMsg()); |
| | | //操作插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("删除了用户:").append(existManageAccount.getUserName() + ";") |
| | | .append("账号:" + existManageAccount.getAccount() + ";"); |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.DELETE_OPERATE_TYPE); |
| | | |
| | | deleteLog(existManageAccount); |
| | | return accountDTO; |
| | | } |
| | | |
| | |
| | | |
| | | //更新ManageAccount表 |
| | | manageAccountMapper.updateById(manageAccount); |
| | | |
| | | //操作插入日志 |
| | | insertUpdateLog(accountUpdateForm, oldManageAccount); |
| | | updateLog(oldManageAccount,manageAccount); |
| | | //销毁token |
| | | TokenUtils.destoryToken(manageAccount.getId()); |
| | | //封装返回结果 |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @Description: 更新操作插入日志 |
| | | * @Param: [oldAccount, newAccount] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/8/25 |
| | | */ |
| | | private void updateLog(ManageAccount oldAccount,ManageAccount newAccount){ |
| | | List<CompareFieldResult> results = CompareFieldUtils.compare(ManageAccount.class, oldAccount, newAccount); |
| | | StringBuilder content = new StringBuilder("修改了后台用户"+";"); |
| | | content.append("账号:"+oldAccount.getAccount()+";"); |
| | | //密码特殊处理 |
| | | if(!ObjectUtils.isEmpty(newAccount.getPassword())) |
| | | content.append("修改了密码"); |
| | | String resultContent = CompareFieldUtils.resultsConvertContent(results,content.toString()); |
| | | logUtils.saveOperationForManage(resultContent, Constants.UPDATE_OPERATE_TYPE); |
| | | } |
| | | |
| | | /** |
| | | * @Description: 插入操作插入日志 |
| | | * @Param: [account] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/8/25 |
| | | */ |
| | | private void insertLog(ManageAccount manageAccount){ |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("添加了后台用户:").append(manageAccount.getUserName() + ";") |
| | | .append("account:" + manageAccount.getAccount() + ";"); |
| | | logUtils.saveOperationForManage(content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @Description: 删除操作插入日志 |
| | | * @Param: [manageAccount] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/8/25 |
| | | */ |
| | | private void deleteLog(ManageAccount manageAccount){ |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("删除了用户:").append(manageAccount.getUserName() + ";") |
| | | .append("账号:" + manageAccount.getAccount() + ";"); |
| | | logUtils.saveOperationForManage( content.toString(), Constants.DELETE_OPERATE_TYPE); |
| | | } |
| | | } |
| | | |
| | |
| | | import com.moral.api.service.GroupService; |
| | | import com.moral.api.service.MenuService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.util.CompareFieldUtils; |
| | | import com.moral.api.util.LogUtils; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.pojo.CompareFieldResult; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | GroupService groupService; |
| | | @Autowired |
| | | GroupMenuMapper groupMenuMapper; |
| | | @Autowired |
| | | LogUtils logUtils; |
| | | |
| | | |
| | | @Override |
| | |
| | | dto.setMsg(ResponseCodeEnum.MENU_IS_EXIST.getMsg()); |
| | | return dto; |
| | | } |
| | | |
| | | //执行插入逻辑 |
| | | menuMapper.insert(menu); |
| | | //插入日志 |
| | | insertLog(menu); |
| | | //封装返回对象 |
| | | dto.setMenu(menu); |
| | | dto.setCode(ResponseCodeEnum.SUCCESS.getCode()); |
| | |
| | | deleteGroupMenuWrapper.in("menu_id", allMenuIds); |
| | | deleteGroupMenuWrapper.set("is_delete", Constants.DELETE); |
| | | groupMenuMapper.update(null, deleteGroupMenuWrapper); |
| | | //插入日志 |
| | | StringBuilder content = new StringBuilder(); |
| | | if (existMenu.getParentId().equals(0)) |
| | | content.append("删除了父菜单:" + existMenu.getName() + ";"); |
| | | else |
| | | content.append("删除了子菜单:" + existMenu.getName() + ";"); |
| | | if (!ObjectUtils.isEmpty(childrenIds)) { |
| | | for (Integer childrenId : childrenIds) { |
| | | content.append("及其子菜单:" + menuMapper.selectById(childrenId).getName() + ";"); |
| | | } |
| | | } |
| | | logUtils.saveOperationForManage(content.toString(), Constants.DELETE_OPERATE_TYPE); |
| | | //封装返回对象 |
| | | dto.setCode(ResponseCodeEnum.SUCCESS.getCode()); |
| | | dto.setMsg(ResponseCodeEnum.SUCCESS.getMsg()); |
| | |
| | | menuMapper.updateById(menu); |
| | | //获取更新后的对象 |
| | | menu = menuMapper.selectById(menu.getId()); |
| | | //插入日志 |
| | | updateLog(oldMenu, menu); |
| | | //封装返回对象 |
| | | dto.setMenu(menu); |
| | | dto.setCode(ResponseCodeEnum.SUCCESS.getCode()); |
| | |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * @Description: 更新操作插入日志 |
| | | * @Param: [oldMenu, newMenu] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/8/24 |
| | | */ |
| | | private void updateLog(Menu oldMenu, Menu newMenu) { |
| | | List<CompareFieldResult> compareResult = CompareFieldUtils.compare(Menu.class, oldMenu, newMenu); |
| | | for (CompareFieldResult result : compareResult) { |
| | | //parentId做特殊处理 |
| | | if (result.getFieldName().equals("parentId")) { |
| | | //父菜单id转为菜单名称 |
| | | String oldData = result.getOldData(); |
| | | String newData = result.getNewData(); |
| | | |
| | | if (!oldData.equals("0")) |
| | | oldData = menuMapper.selectById(Integer.parseInt(oldData)).getName(); |
| | | else |
| | | oldData = "null"; |
| | | |
| | | if (!newData.equals("0")) |
| | | newData = menuMapper.selectById(Integer.parseInt(newData)).getName(); |
| | | else |
| | | newData = "null"; |
| | | |
| | | result.setNewData(newData); |
| | | result.setOldData(oldData); |
| | | result.setFieldAnnoName("父菜单"); |
| | | } |
| | | } |
| | | String content = CompareFieldUtils.resultsConvertContent(compareResult, "修改了前台菜单"); |
| | | logUtils.saveOperationForManage(content, Constants.UPDATE_OPERATE_TYPE); |
| | | } |
| | | |
| | | /** |
| | | * @Description: 插入操作插入日志 |
| | | * @Param: [menu] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/8/24 |
| | | */ |
| | | private void insertLog(Menu menu) { |
| | | StringBuilder content = new StringBuilder(); |
| | | //判断插入的是子菜单还是父菜单 |
| | | if (menu.getParentId() == null) { |
| | | content.append("添加了前台父菜单;"); |
| | | } else { |
| | | content.append("添加了前台子菜单;"); |
| | | //根据父菜单id查询菜单名称 |
| | | Menu parentMenu = menuMapper.selectById(menu.getParentId()); |
| | | content.append("父菜单:" + parentMenu.getName() + ";"); |
| | | } |
| | | content.append("名称:" + menu.getName() + ";"); |
| | | if (menu.getUrl() != null) |
| | | content.append("url:" + menu.getUrl() + ";"); |
| | | content.append("顺序:" + menu.getOrder() + ";"); |
| | | logUtils.saveOperationForManage(content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | } |
| | | |
| | | } |
| | |
| | | QueryWrapper<ManageAccount> wapper_manageAccount = new QueryWrapper<>(); |
| | | wapper_manageAccount.eq("is_delete",Constants.NOT_DELETE); |
| | | wapper_manageAccount.in("id",operateIdList); |
| | | wapper_manageAccount.select("id", "user_name"); |
| | | List<ManageAccount> manageAccounts = manageAccountMapper.selectList(wapper_manageAccount); |
| | | for (ManageAccount manageAccount:manageAccounts) { |
| | | Map<String,Object> operateMap = new HashMap<>(); |
| | |
| | | QueryWrapper<ManageAccount> wapper_manageAccount = new QueryWrapper<>(); |
| | | wapper_manageAccount.eq("is_delete",Constants.NOT_DELETE); |
| | | wapper_manageAccount.in("id",operateIdList); |
| | | wapper_manageAccount.select("id", "user_name"); |
| | | List<ManageAccount> manageAccounts = manageAccountMapper.selectList(wapper_manageAccount); |
| | | for (ManageAccount manageAccount:manageAccounts) { |
| | | Map<String,Object> operateMap = new HashMap<>(); |
| | |
| | | import com.moral.api.pojo.form.user.UserUpdateForm; |
| | | import com.moral.api.service.UserService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.util.CompareFieldUtils; |
| | | import com.moral.api.util.LogUtils; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.pojo.CompareFieldResult; |
| | | import com.moral.util.ConvertUtils; |
| | | import com.moral.util.DateUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.logging.SimpleFormatter; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | UserGroupMapper userGroupMapper; |
| | | @Autowired |
| | | GroupMenuMapper groupMenuMapper; |
| | | @Autowired |
| | | LogUtils logUtils; |
| | | |
| | | @Override |
| | | public UserQueryDTO queryUsers(UserQueryForm form) { |
| | |
| | | //更新 |
| | | userMapper.updateById(user); |
| | | |
| | | //获取更新后的用户 |
| | | user = userMapper.selectById(user.getId()); |
| | | |
| | | //插入日志 |
| | | updatelog(oldUser,user); |
| | | |
| | | //封装返回结果 |
| | | dto.setCode(ResponseCodeEnum.SUCCESS.getCode()); |
| | | dto.setMsg(ResponseCodeEnum.SUCCESS.getMsg()); |
| | |
| | | organization.setAdminUserId(user.getId()); |
| | | organization.setId(organizationId); |
| | | organizationMapper.updateById(organization); |
| | | //操作插入日志 |
| | | insertLog(user,organizationId); |
| | | //封装返回结果 |
| | | dto.setCode(ResponseCodeEnum.SUCCESS.getCode()); |
| | | dto.setMsg(ResponseCodeEnum.SUCCESS.getMsg()); |
| | |
| | | return dto; |
| | | } |
| | | |
| | | /** |
| | | * @Description: 插入操作插入日志 |
| | | * @Param: [user, organizationId] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/8/24 |
| | | */ |
| | | private void insertLog(User user,Integer organizationId) { |
| | | StringBuilder content = new StringBuilder("添加了前台用户;"); |
| | | content.append("角色:admin;"); |
| | | //查询添加admin用户的组织 |
| | | Organization organization = organizationMapper.selectById(organizationId); |
| | | content.append("组织:"+organization.getName()+";"); |
| | | content.append("账号:"+user.getAccount()+";"); |
| | | content.append("用户名称:"+user.getUserName()+";"); |
| | | content.append("过期时间:"+ DateUtils.dateToDateString(user.getExpireTime(),"yyyy-MM-dd")+";"); |
| | | if(user.getEmail()!=null) |
| | | content.append("邮箱:"+user.getEmail()+";"); |
| | | if(user.getMobile()!=null) |
| | | content.append("手机:"+user.getMobile()+";"); |
| | | if(user.getWechat()!=null) |
| | | content.append("微信:"+user.getWechat()+";"); |
| | | logUtils.saveOperationForManage(content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @Description: 更新操作插入日志 |
| | | * @Param: [oldUser, newUser] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/8/24 |
| | | */ |
| | | private void updatelog(User oldUser,User newUser){ |
| | | List<CompareFieldResult> results = CompareFieldUtils.compare(User.class, oldUser, newUser); |
| | | StringBuilder content = new StringBuilder("修改了前台用户;"); |
| | | content.append("所属组织:"+organizationMapper.selectById(oldUser.getOrganizationId()).getName()+";"); |
| | | //密码特殊处理 |
| | | if(newUser.getPassword()!=null) |
| | | content.append("修改了密码;"); |
| | | String resultContent = CompareFieldUtils.resultsConvertContent(results,content.toString()); |
| | | logUtils.saveOperationForManage(resultContent, Constants.UPDATE_OPERATE_TYPE); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | Integer id = form.getId(); |
| | | //查询型号是否被使用,如果被使用则无法删除 |
| | | QueryWrapper<OrganizationUnitAlarm> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("id"); |
| | | queryWrapper.eq("is_delete", Constants.NOT_DELETE); |
| | | queryWrapper.eq("version_id", id); |
| | | List<OrganizationUnitAlarm> organizationUnitAlarms = organizationUnitAlarmMapper.selectList(queryWrapper); |
| | |
| | | return dto; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.moral.api.util; |
| | | |
| | | import com.moral.anno.FieldName; |
| | | import com.moral.pojo.CompareFieldResult; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.beans.IntrospectionException; |
| | | import java.beans.PropertyDescriptor; |
| | | import java.lang.reflect.Field; |
| | | import java.lang.reflect.InvocationTargetException; |
| | | import java.lang.reflect.Method; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @ClassName ComparePropertyUtils |
| | | * @Description TODO |
| | | * @Author 陈凯裕 |
| | | * @Date 2021/8/24 13:34 |
| | | * @Version TODO |
| | | **/ |
| | | @Slf4j |
| | | public class CompareFieldUtils { |
| | | |
| | | /** |
| | | * @Description: 对比两个对象之间属性的区别 |
| | | * @Param: [t, oldObject, newObject] |
| | | * @return: java.util.List<com.moral.pojo.CompareFieldResult> |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/8/24 |
| | | */ |
| | | public static <T> List<CompareFieldResult> compare(T t, Object oldObject, Object newObject) { |
| | | List<CompareFieldResult> results = new ArrayList<>(); |
| | | try { |
| | | T oldObj = (T) oldObject; |
| | | T newObj = (T) newObject; |
| | | //获取class对象 |
| | | Class<?> TClass = oldObject.getClass(); |
| | | //获取类的属性 |
| | | Field[] fields = TClass.getDeclaredFields(); |
| | | for (Field field : fields) { |
| | | //过滤序列化信息Id |
| | | if ("serialVersionUID".equals(field.getName())) { |
| | | continue; |
| | | } |
| | | //如果没有fieldName注解则跳过 |
| | | FieldName annotation = field.getAnnotation(FieldName.class); |
| | | if(annotation==null) |
| | | continue; |
| | | //创建属性扫描器 |
| | | PropertyDescriptor pd = new PropertyDescriptor(field.getName(), TClass); |
| | | //获取该属性的get方法 |
| | | Method readMethod = pd.getReadMethod(); |
| | | //读取对象该属性的值 |
| | | Object oldDataObj = readMethod.invoke(oldObj); |
| | | Object newDataObj = readMethod.invoke(newObj); |
| | | //如果新的值为null则证明该属性没有更新 |
| | | if(newDataObj==null) |
| | | continue; |
| | | //如果旧值和新值相等则证明没有改变 |
| | | if(oldDataObj!=null&&oldDataObj.toString().equals(newDataObj.toString())) |
| | | continue; |
| | | //创建返回对象 |
| | | CompareFieldResult result = new CompareFieldResult(); |
| | | result.setFieldName(field.getName()); |
| | | result.setFieldAnnoName(annotation.value()); |
| | | result.setNewData(newDataObj.toString()); |
| | | if(oldDataObj==null) |
| | | result.setOldData("null"); |
| | | else |
| | | result.setOldData(oldDataObj.toString()); |
| | | results.add(result); |
| | | } |
| | | }catch (IntrospectionException e) { |
| | | log.error(e.getMessage()); |
| | | } catch (IllegalAccessException e) { |
| | | log.error(e.getMessage()); |
| | | } catch (InvocationTargetException e) { |
| | | log.error(e.getMessage()); |
| | | } |
| | | return results; |
| | | } |
| | | |
| | | /** |
| | | * @Description: 将对比结果类转换为content |
| | | * @Param: [results, content] content参数需要传入修改的基本描述。比如,修改了前台菜单,修改了后台角色 |
| | | * @return: java.lang.String |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/8/24 |
| | | */ |
| | | public static String resultsConvertContent(List<CompareFieldResult> results,String content){ |
| | | StringBuilder contentReulst = new StringBuilder(content+";"); |
| | | for (CompareFieldResult result : results) { |
| | | contentReulst.append(result.getFieldAnnoName()+":"+result.getOldData()+"->"+result.getNewData()+";"); |
| | | } |
| | | return contentReulst.toString(); |
| | | } |
| | | } |
| | |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.Scanner; |
| | | |
| | | /** |
| | | * @ClassName LogUtils |
| | |
| | | public void saveLoginForManage(HttpServletRequest request,String content,ManageAccount account,String userName){ |
| | | ManageLog log = new ManageLog(); |
| | | String ip = WebUtils.getIpAddr(request); |
| | | |
| | | log.setAccountId(account.getId()); |
| | | log.setAccount(account.getAccount()); |
| | | log.setUserName(userName); |
| | |
| | | log.setType(Constants.LOGIN_OPERTATE_TYPE); |
| | | manageLogMapper.insert(log); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | join |
| | | manage_role_menu mrm |
| | | on |
| | | mm.`id` = mrm.`menu_id` and mrm.`is_delete`=0 |
| | | mm.`id` = mrm.`menu_id` and mrm.`is_delete`= '0' |
| | | join |
| | | manage_role mr |
| | | on |
| | |
| | | #{role.id} |
| | | </foreach> |
| | | where |
| | | mm.`is_delete`=0 |
| | | mm.`is_delete`= '0' |
| | | </select> |
| | | |
| | | <select id="getManageMenuByName" resultMap="BaseResultMap"> |
| | |
| | | FROM |
| | | manage_role mr |
| | | JOIN manage_account_role mar |
| | | ON mar.role_id=mr.id AND mar.is_delete = 0 |
| | | ON mar.role_id=mr.id AND mar.is_delete = '0' |
| | | JOIN manage_account ma |
| | | ON ma.id=mar.account_id and ma.id = #{accountId} |
| | | where |
| | | mr.is_delete=0 |
| | | mr.is_delete='0' |
| | | </select> |
| | | |
| | | <select id="getAll" resultMap="BaseResultMap"> |
| | | select |
| | | <include refid="Base_Column_List"></include> |
| | | from manage_role mr |
| | | where mr.is_delete = 0 |
| | | where mr.is_delete = '0' |
| | | </select> |
| | | |
| | | <select id="getManageRoleByName" resultMap="BaseResultMap"> |
| | |
| | | <include refid="Base_Column_List"></include> |
| | | from manage_role mr |
| | | where name = #{name} |
| | | and mr.is_delete = 0 |
| | | and mr.is_delete = '0' |
| | | </select> |
| | | |
| | | <select id="getManageRoleById" resultMap="BaseResultMap"> |
| | |
| | | <include refid="Base_Column_List"></include> |
| | | from manage_role mr |
| | | where mr.id = #{id} |
| | | and mr.is_delete = 0 |
| | | and mr.is_delete = '0' |
| | | </select> |
| | | |
| | | <select id="getManageRoleByNameFuzzy" resultMap="BaseResultMap"> |
| | |
| | | <include refid="Base_Column_List"></include> |
| | | from manage_role mr |
| | | where mr.name like concat('%',#{name},'%') |
| | | and mr.is_delete = 0 |
| | | and mr.is_delete = '0' |
| | | </select> |
| | | |
| | | <insert id="insertOne" parameterType="com.moral.api.entity.ManageRole"> |