| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.whyc.dto.ApplicationConfigDTO; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.ApplicationConfigMapper; |
| | | import com.whyc.mapper.ApplicationMapper; |
| | | import com.whyc.pojo.Application; |
| | | import com.whyc.pojo.ApplicationConfig; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | |
| | | @Resource |
| | | private ApplicationMapper mapper; |
| | | |
| | | @Resource |
| | | private ApplicationConfigMapper configMapper; |
| | | |
| | | public Response insert(Application app) { |
| | | int res = mapper.insert(app); |
| | | if(res==1){ |
| | | return new Response<>().setMsg(1,"创建成功"); |
| | | }else{ |
| | | return new Response<>().setMsg(0,"创建失败"); |
| | | } |
| | | //TODO:id返回获取异常,需要修复 |
| | | int id = mapper.insertApp(app); |
| | | return new Response<>().set(1,id,"创建成功"); |
| | | } |
| | | |
| | | public Response getAll() { |
| | |
| | | return new Response<>().setMsg(0,"更新失败"); |
| | | } |
| | | } |
| | | |
| | | /*======应用配置======*/ |
| | | |
| | | public Response saveConfig(ApplicationConfigDTO configDTO) { |
| | | try { |
| | | configMapper.saveConfig(configDTO); |
| | | }catch (Exception e){ |
| | | return new Response<>().setMsg(0,"保存失败"); |
| | | } |
| | | return new Response<>().setCode(1); |
| | | } |
| | | |
| | | public Response getAllConfig(int appId) { |
| | | QueryWrapper<ApplicationConfig> query = Wrappers.query(); |
| | | query.eq("app_id",appId); |
| | | List<ApplicationConfig> applicationConfigs = configMapper.selectList(query); |
| | | return new Response<>().set(1,applicationConfigs); |
| | | } |
| | | } |