用户配置
This commit is contained in:
parent
fa49d3208e
commit
ee4ac20435
@ -0,0 +1,104 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.controller;
|
||||
|
||||
import com.zhgd.annotation.OperLog;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import java.util.HashMap;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.UserConfig;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.vo.UserConfigVo;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.dto.UserConfigDto;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.IUserConfigService;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* @Title: Controller
|
||||
* @Description: 用户配置
|
||||
* @author: pds
|
||||
* @date: 2025-12-08
|
||||
* @version: V1.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/xmgl/userConfig")
|
||||
@Slf4j
|
||||
@Api(tags = "用户配置相关Api")
|
||||
public class UserConfigController {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IUserConfigService userConfigService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "用户配置管理", operType = "分页查询", operDesc = "分页列表查询用户配置信息")
|
||||
@ApiOperation(value = "分页列表查询用户配置信息", notes = "分页列表查询用户配置信息", httpMethod="GET")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "pageNo", value = "第几页", paramType = "query", required = true, dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页显示条数", paramType = "query", required = true, dataType = "Integer"),
|
||||
})
|
||||
@GetMapping(value = "/page")
|
||||
public Result<IPage<UserConfigVo>> queryPageList(@ApiIgnore @RequestParam HashMap<String, Object> param) {
|
||||
return Result.success(userConfigService.queryPageList(param));
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "用户配置管理", operType = "列表查询", operDesc = "列表查询用户配置信息")
|
||||
@ApiOperation(value = "列表查询用户配置信息", notes = "列表查询用户配置信息", httpMethod="GET")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<List<UserConfigVo>> queryList(@ApiIgnore @RequestParam HashMap<String, Object> param) {
|
||||
return Result.success(userConfigService.queryList(param));
|
||||
}
|
||||
|
||||
@OperLog(operModul = "用户配置管理", operType = "保存", operDesc = "保存用户配置信息")
|
||||
@ApiOperation(value = "保存用户配置信息", notes = "保存用户配置信息" , httpMethod="POST")
|
||||
@PostMapping(value = "/saveConfig")
|
||||
public Result saveConfig(@RequestBody UserConfigDto userConfigDto) {
|
||||
userConfigService.saveConfig(userConfigDto);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "用户配置管理", operType = "删除", operDesc = "删除用户配置信息")
|
||||
@ApiOperation(value = "删除用户配置信息", notes = "删除用户配置信息" , httpMethod="POST")
|
||||
@ApiImplicitParam(name = "id", value = "用户配置ID", paramType = "body", required = true, dataType = "String", example = "{\"id\":\"1\"}")
|
||||
@PostMapping(value = "/delete")
|
||||
public Result<UserConfig> delete(@ApiIgnore @RequestBody HashMap<String ,Object> map) {
|
||||
userConfigService.delete(MapUtils.getString(map, "id"));
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@OperLog(operModul = "用户配置管理", operType = "通过id查询", operDesc = "通过id查询用户配置信息")
|
||||
@ApiOperation(value = "通过id查询用户配置信息", notes = "通过id查询用户配置信息" , httpMethod="GET")
|
||||
@ApiImplicitParam(name = "id", value = "用户配置ID", paramType = "query", required = true, dataType = "Integer")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<UserConfigVo> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
return Result.success(userConfigService.queryById(id));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
/**
|
||||
* @Description: 用户配置
|
||||
* @author: pds
|
||||
* @date: 2025-12-08
|
||||
* @version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("user_config")
|
||||
@ApiModel(value="UserConfig实体类",description="UserConfig")
|
||||
public class UserConfig implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**id*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value="id")
|
||||
private Long id ;
|
||||
/**用户id*/
|
||||
@ApiModelProperty(value="用户id")
|
||||
private Long userId ;
|
||||
/**强制使用H5播放1是0否*/
|
||||
@ApiModelProperty(value="强制使用H5播放1是0否")
|
||||
private Integer forceH5Play ;
|
||||
/**创建时间 yyyy-MM-dd HH:mm:ss*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value="创建时间 yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime ;
|
||||
/**更新时间 yyyy-MM-dd HH:mm:ss*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value="更新时间 yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime ;
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.entity.dto;
|
||||
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.UserConfig;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@ApiModel(value="UserConfigDto实体类",description="UserConfigDto实体类")
|
||||
public class UserConfigDto extends UserConfig {
|
||||
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.entity.vo;
|
||||
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.UserConfig;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@ApiModel(value="UserConfigVo实体类",description="UserConfigVo实体类")
|
||||
public class UserConfigVo extends UserConfig {
|
||||
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.UserConfig;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.vo.UserConfigVo;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.dto.UserConfigDto;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 用户配置
|
||||
* @author: pds
|
||||
* @date: 2025-12-08
|
||||
* @version: V1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserConfigMapper extends BaseMapper<UserConfig> {
|
||||
|
||||
/**
|
||||
* 分页列表查询用户配置信息
|
||||
*
|
||||
* @param page
|
||||
* @param queryWrapper
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
IPage<UserConfigVo> queryList(Page<UserConfigVo> page, @Param(Constants.WRAPPER) QueryWrapper<UserConfigVo> queryWrapper, @Param("param") HashMap<String, Object> param);
|
||||
|
||||
/**
|
||||
* 列表查询用户配置信息
|
||||
*
|
||||
* @param queryWrapper
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
List<UserConfigVo> queryList(@Param(Constants.WRAPPER) QueryWrapper<UserConfigVo> queryWrapper, @Param("param") HashMap<String, Object> param);
|
||||
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
<?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.zhgd.xmgl.modules.basicdata.mapper.UserConfigMapper">
|
||||
<select id="queryList" resultType="com.zhgd.xmgl.modules.basicdata.entity.vo.UserConfigVo">
|
||||
select * from (
|
||||
select t.*
|
||||
from user_config t
|
||||
)t
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
</mapper>
|
||||
@ -0,0 +1,50 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.service;
|
||||
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.UserConfig;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.vo.UserConfigVo;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.dto.UserConfigDto;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 用户配置
|
||||
* @author: pds
|
||||
* @date: 2025-12-08
|
||||
* @version: V1.0
|
||||
*/
|
||||
public interface IUserConfigService extends IService<UserConfig> {
|
||||
/**
|
||||
* 分页列表查询用户配置信息
|
||||
* @param param 参数map
|
||||
* @return
|
||||
*/
|
||||
IPage<UserConfigVo> queryPageList(HashMap<String, Object> param);
|
||||
/**
|
||||
* 列表查询用户配置信息
|
||||
* @param param 参数map
|
||||
* @return
|
||||
*/
|
||||
List<UserConfigVo> queryList(HashMap<String, Object> param);
|
||||
|
||||
/**
|
||||
* 保存用户配置信息
|
||||
* @param userConfigDto 用户配置
|
||||
* @return
|
||||
*/
|
||||
void saveConfig(UserConfigDto userConfigDto);
|
||||
/**
|
||||
* 根据id删除用户配置信息
|
||||
* @param id 用户配置的id
|
||||
* @return
|
||||
*/
|
||||
void delete(String id);
|
||||
/**
|
||||
* 根据id查询用户配置信息
|
||||
* @param id 用户配置的id
|
||||
* @return
|
||||
*/
|
||||
UserConfigVo queryById(String id);
|
||||
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
package com.zhgd.xmgl.modules.basicdata.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.UserConfig;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.vo.UserConfigVo;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.dto.UserConfigDto;
|
||||
import com.zhgd.xmgl.modules.basicdata.mapper.UserConfigMapper;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.IUserConfigService;
|
||||
import com.zhgd.xmgl.security.util.SecurityUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.xmgl.util.MapBuilder;
|
||||
import com.zhgd.xmgl.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import com.zhgd.xmgl.util.RefUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* @Description: 用户配置
|
||||
* @author: pds
|
||||
* @date: 2025-12-08
|
||||
* @version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class UserConfigServiceImpl extends ServiceImpl<UserConfigMapper, UserConfig> implements IUserConfigService {
|
||||
@Autowired
|
||||
private UserConfigMapper userConfigMapper;
|
||||
@Override
|
||||
public IPage<UserConfigVo> queryPageList(HashMap<String, Object> param) {
|
||||
QueryWrapper<UserConfigVo> queryWrapper = this.getQueryWrapper(param);
|
||||
Page<UserConfigVo> page = PageUtil.getPage(param);
|
||||
IPage<UserConfigVo> pageList = baseMapper.queryList(page, queryWrapper,param);
|
||||
pageList.setRecords(this.dealList(pageList.getRecords()));
|
||||
return pageList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserConfigVo> queryList(HashMap<String, Object> param) {
|
||||
QueryWrapper<UserConfigVo> queryWrapper = getQueryWrapper(param);
|
||||
return dealList(baseMapper.queryList(queryWrapper,param));
|
||||
}
|
||||
|
||||
private QueryWrapper<UserConfigVo> getQueryWrapper(HashMap<String, Object> param) {
|
||||
QueryWrapper<UserConfigVo> queryWrapper = QueryGenerator.initPageQueryWrapper(UserConfigVo.class, param, true);
|
||||
queryWrapper.orderByDesc(RefUtil.fieldNameUlc(UserConfigVo::getId));
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
private List<UserConfigVo> dealList(List<UserConfigVo> list) {
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveConfig(UserConfigDto userConfigDto) {
|
||||
Long userId = SecurityUtils.getUser().getUserId();
|
||||
UserConfig config = this.getOne(new LambdaQueryWrapper<UserConfig>()
|
||||
.eq(UserConfig::getUserId, userId));
|
||||
if (config == null) {
|
||||
userConfigDto.setId(null);
|
||||
baseMapper.insert(userConfigDto);
|
||||
} else {
|
||||
userConfigDto.setId(config.getId());
|
||||
baseMapper.updateById(userConfigDto);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String id) {
|
||||
UserConfig userConfig = baseMapper.selectById(id);
|
||||
if(userConfig==null) {
|
||||
throw new OpenAlertException("未找到对应实体");
|
||||
}
|
||||
baseMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserConfigVo queryById(String id) {
|
||||
List<UserConfigVo> list = this.queryList(new MapBuilder<String, Object>()
|
||||
.put("id", id)
|
||||
.build());
|
||||
UserConfigVo entity = CollUtil.getFirst(list);
|
||||
if (entity == null) {
|
||||
throw new OpenAlertException("未找到对应实体");
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user