| | |
| | | package com.whyc.dto; |
| | | |
| | | import com.whyc.pojo.ApplicationConfig; |
| | | import org.apache.ibatis.type.Alias; |
| | | |
| | | import java.beans.Transient; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 应用内模块配置DTO |
| | | */ |
| | | @Alias("ApplicationConfigDTO") |
| | | public class ApplicationConfigDTO { |
| | | |
| | | private Integer appId; |
| | | private String appName; |
| | | private String headPic; |
| | | private String bgPic; |
| | | private List<ApplicationConfig> children; |
| | | |
| | | public Integer getAppId() { |
| | |
| | | public void setChildren(List<ApplicationConfig> children) { |
| | | this.children = children; |
| | | } |
| | | |
| | | public String getHeadPic() { |
| | | return headPic; |
| | | } |
| | | |
| | | public void setHeadPic(String headPic) { |
| | | this.headPic = headPic; |
| | | } |
| | | |
| | | public String getBgPic() { |
| | | return bgPic; |
| | | } |
| | | |
| | | public void setBgPic(String bgPic) { |
| | | this.bgPic = bgPic; |
| | | } |
| | | |
| | | public String getAppName() { |
| | | return appName; |
| | | } |
| | | |
| | | public void setAppName(String appName) { |
| | | this.appName = appName; |
| | | } |
| | | } |
| | |
| | | import com.whyc.pojo.ApplicationConfig; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface ApplicationConfigMapper extends CustomMapper<ApplicationConfig> { |
| | | int saveConfig(@Param("configDTO") ApplicationConfigDTO configDTO); |
| | | |
| | | ApplicationConfigDTO getAllConfig(int appId); |
| | | } |
| | |
| | | |
| | | private Integer id; |
| | | private String name; |
| | | /**头部图片*/ |
| | | private String headPic; |
| | | /**背景图片*/ |
| | | private String bgImg; |
| | | private String bgPic; |
| | | /**应用的缩略图*/ |
| | | private String screenshot; |
| | | |
| | | public Integer getId() { |
| | | return id; |
| | |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getBgImg() { |
| | | return bgImg; |
| | | public String getScreenshot() { |
| | | return screenshot; |
| | | } |
| | | |
| | | public void setBgImg(String bgImg) { |
| | | this.bgImg = bgImg; |
| | | public void setScreenshot(String screenshot) { |
| | | this.screenshot = screenshot; |
| | | } |
| | | |
| | | public String getHeadPic() { |
| | | return headPic; |
| | | } |
| | | |
| | | public void setHeadPic(String headPic) { |
| | | this.headPic = headPic; |
| | | } |
| | | |
| | | public String getBgPic() { |
| | | return bgPic; |
| | | } |
| | | |
| | | public void setBgPic(String bgPic) { |
| | | this.bgPic = bgPic; |
| | | } |
| | | } |
| | |
| | | private ApplicationConfigMapper configMapper; |
| | | |
| | | public Response insert(Application app) { |
| | | //TODO:id返回获取异常,需要修复 |
| | | int id = mapper.insertApp(app); |
| | | return new Response<>().set(1,id,"创建成功"); |
| | | mapper.insertApp(app); |
| | | return new Response<>().set(1,app,"创建成功"); |
| | | } |
| | | |
| | | public Response getAll() { |
| | |
| | | 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); |
| | | ApplicationConfigDTO applicationConfigDTO = configMapper.getAllConfig(appId); |
| | | return new Response<>().set(1,applicationConfigDTO); |
| | | } |
| | | } |
| | |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.whyc.mapper.ApplicationConfigMapper" > |
| | | |
| | | <resultMap id="Map_ApplicationConfigDTO" type="com.whyc.dto.ApplicationConfigDTO"> |
| | | <id column="appId" property="appId" /> |
| | | <result column="appName" property="appName"/> |
| | | <result column="head_pic" property="headPic"/> |
| | | <result column="bg_pic" property="bgPic"/> |
| | | <collection property="children" ofType="ApplicationConfig" resultMap="configResult" /> |
| | | </resultMap> |
| | | |
| | | <resultMap id="configResult" type="ApplicationConfig"> |
| | | <id column="id" property="id"/> |
| | | <result column="name" property="name"/> |
| | | <result column="w" property="w"/> |
| | | <result column="h" property="h"/> |
| | | <result column="x" property="x"/> |
| | | <result column="y" property="y"/> |
| | | <result column="type" property="type"/> |
| | | </resultMap> |
| | | |
| | | <insert id="saveConfig"> |
| | | insert into db_app_sys.tb_application_config(id,app_id,name,w,h,x,y,type) values |
| | |
| | | (#{module.id},#{configDTO.appId},#{module.name},#{module.w},#{module.h},#{module.x},#{module.y},#{module.type}) |
| | | </foreach> |
| | | </insert> |
| | | <select id="getAllConfig" resultMap="Map_ApplicationConfigDTO"> |
| | | SELECT |
| | | app.id as appId, |
| | | app.NAME as appName, |
| | | app.head_pic, |
| | | app.bg_pic, |
| | | config.id, |
| | | config.NAME, |
| | | config.w, |
| | | config.h, |
| | | config.x, |
| | | config.y, |
| | | config.type |
| | | FROM |
| | | db_app_sys.tb_application_config config, |
| | | db_app_sys.tb_application app |
| | | WHERE |
| | | config.app_id = app.id |
| | | AND config.app_id =#{appId} |
| | | </select> |
| | | </mapper> |