apkconfig

This commit is contained in:
wangjinlei
2024-07-09 13:33:20 +08:00
parent 8e86dc65e4
commit fe7f375f37
5 changed files with 106 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
package com.peanut.modules.common.dao;
import com.github.yulichang.base.MPJBaseMapper;
import com.peanut.modules.common.entity.ApkConfigEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ApkConfigDao extends MPJBaseMapper<ApkConfigEntity> {
}

View File

@@ -0,0 +1,24 @@
package com.peanut.modules.common.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
@Data
@TableName("apk_config")
public class ApkConfigEntity {
@TableId
private Integer id;
private String title;
private Integer type;
private String url;
private Date create_time;
}

View File

@@ -0,0 +1,11 @@
package com.peanut.modules.common.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.common.entity.ApkConfigEntity;
import java.util.Map;
public interface ApkConfigService extends IService<ApkConfigEntity> {
Map<String,Object> getConfig();
}

View File

@@ -0,0 +1,25 @@
package com.peanut.modules.common.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.common.dao.ApkConfigDao;
import com.peanut.modules.common.entity.ApkConfigEntity;
import com.peanut.modules.common.service.ApkConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Service("commonApkConfigService")
public class ApkConfigServiceImpl extends ServiceImpl<ApkConfigDao, ApkConfigEntity> implements ApkConfigService {
@Override
public Map<String, Object> getConfig() {
HashMap<String, Object> flag = new HashMap<>();
List<ApkConfigEntity> apkConfigEntities = this.baseMapper.selectList(null);
flag.put("configs",apkConfigEntities);
return flag;
}
}

View File

@@ -0,0 +1,37 @@
package com.peanut.modules.master.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.peanut.common.utils.R;
import com.peanut.modules.common.entity.ApkConfigEntity;
import com.peanut.modules.common.service.ApkConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@Slf4j
@RestController("masterApkConfig")
@RequestMapping("master/apkConfig")
public class ApkConfigController {
@Autowired
private ApkConfigService apkConfigService;
@RequestMapping("/getConfig")
public R getConfig(){
Map<String, Object> config = apkConfigService.getConfig();
return R.ok().put("list",config);
}
@RequestMapping("/setConfig")
public R setConfig(@RequestBody Map<String,Object> map){
int type = Integer.valueOf(map.get("type").toString());
String Url = map.get("url").toString();
ApkConfigEntity apkConfigEntity = apkConfigService.getBaseMapper().selectOne(new LambdaQueryWrapper<ApkConfigEntity>().eq(ApkConfigEntity::getType, type));
apkConfigEntity.setUrl(Url);
apkConfigService.updateById(apkConfigEntity);
return R.ok().put("result",apkConfigEntity);
}
}