Commit bbc3902b by Java-张振楠

①轮播图接口

②首页滚动信息、弹出信息接口
③完善框架内容
parent 01a2e078
package com.thinkgem.jeesite.common.baseBean; package com.thinkgem.jeesite.common.baseBean;
import com.alibaba.fastjson.annotation.JSONField; import com.fasterxml.jackson.annotation.JsonIgnore;
public class BaseEntity implements java.io.Serializable { public class BaseEntity implements java.io.Serializable {
private String id; // 主键 private String id; // 主键
private String code; // 唯一编码 private String code; // 唯一编码
@JSONField(deserialize = false, serialize = false) @JsonIgnore
private String created; //创建时间 private String created; //创建时间
@JSONField(deserialize = false, serialize = false) @JsonIgnore
private String createdUser; //创建人 private String createdUser; //创建人
@JSONField(deserialize = false, serialize = false) @JsonIgnore
private String modified; //修改时间 private String modified; //修改时间
@JSONField(deserialize = false, serialize = false) @JsonIgnore
private String modifiedUser; //修改人 private String modifiedUser; //修改人
public String getId() { public String getId() {
......
...@@ -10,8 +10,8 @@ public class Response implements java.io.Serializable { ...@@ -10,8 +10,8 @@ public class Response implements java.io.Serializable {
private String status; private String status;
private String message; private String message;
private String error; private String error;
private String current;//FORMAT.format(System.currentTimeMillis()); private String current;
private Long currentTimeMillis;//FORMAT.format(System.currentTimeMillis()); private Long currentTimeMillis;
public Response() { public Response() {
this.setStatus(ComCode.STATUS_CODE_2000); this.setStatus(ComCode.STATUS_CODE_2000);
......
...@@ -15,5 +15,7 @@ public class ComCode { ...@@ -15,5 +15,7 @@ public class ComCode {
public static final String STATUS_CODE_2000_DESC = "成功"; public static final String STATUS_CODE_2000_DESC = "成功";
public static final String STATUS_CODE_9999 = "9999"; public static final String STATUS_CODE_9999 = "9999";
public static final String STATUS_CODE_9999_DESC = "验证SIGN失败"; public static final String STATUS_CODE_9999_DESC = "验证SIGN失败";
public static final String STATUS_CODE_9998 = "9998";
public static final String STATUS_CODE_9998_DESC = "通用异常";
} }
...@@ -11,7 +11,7 @@ import java.io.IOException; ...@@ -11,7 +11,7 @@ import java.io.IOException;
/** /**
* 验证sign * 验证sign
*/ */
@WebFilter(filterName = "validationFilter", urlPatterns = "/api/*") //@WebFilter(filterName = "validationFilter", urlPatterns = "/api/*")
public class ValidationFilter implements Filter { public class ValidationFilter implements Filter {
@Override @Override
public void init(FilterConfig filterConfig) throws ServletException { public void init(FilterConfig filterConfig) throws ServletException {
......
...@@ -32,230 +32,235 @@ import com.google.common.collect.Maps; ...@@ -32,230 +32,235 @@ import com.google.common.collect.Maps;
/** /**
* 简单封装Jackson,实现JSON String<->Java Object的Mapper. * 简单封装Jackson,实现JSON String<->Java Object的Mapper.
* 封装不同的输出风格, 使用不同的builder函数创建实例. * 封装不同的输出风格, 使用不同的builder函数创建实例.
*
* @author ThinkGem * @author ThinkGem
* @version 2013-11-15 * @version 2013-11-15
*/ */
public class JsonMapper extends ObjectMapper { public class JsonMapper extends ObjectMapper {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static Logger logger = LoggerFactory.getLogger(JsonMapper.class); private static Logger logger = LoggerFactory.getLogger(JsonMapper.class);
private static JsonMapper mapper; private static JsonMapper mapper;
public JsonMapper() { public JsonMapper() {
this(Include.NON_EMPTY); this(Include.ALWAYS);
} }
public JsonMapper(Include include) { public JsonMapper(Include include) {
// 设置输出时包含属性的风格 // 设置输出时包含属性的风格
if (include != null) { if (include != null) {
this.setSerializationInclusion(include); this.setSerializationInclusion(include);
} }
// 允许单引号、允许不带引号的字段名称 // 允许单引号、允许不带引号的字段名称
this.enableSimple(); this.enableSimple();
// 设置输入时忽略在JSON字符串中存在但Java对象实际没有的属性 // 设置输入时忽略在JSON字符串中存在但Java对象实际没有的属性
this.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); this.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
// 空值处理为空串 // 空值处理为空串
this.getSerializerProvider().setNullValueSerializer(new JsonSerializer<Object>(){ this.getSerializerProvider().setNullValueSerializer(new JsonSerializer<Object>() {
@Override @Override
public void serialize(Object value, JsonGenerator jgen, public void serialize(Object value, JsonGenerator jgen,
SerializerProvider provider) throws IOException, SerializerProvider provider) throws IOException,
JsonProcessingException { JsonProcessingException {
jgen.writeString(""); jgen.writeString("");
} }
}); });
// 进行HTML解码。 // 进行HTML解码。
this.registerModule(new SimpleModule().addSerializer(String.class, new JsonSerializer<String>(){ this.registerModule(new SimpleModule().addSerializer(String.class, new JsonSerializer<String>() {
@Override @Override
public void serialize(String value, JsonGenerator jgen, public void serialize(String value, JsonGenerator jgen,
SerializerProvider provider) throws IOException, SerializerProvider provider) throws IOException,
JsonProcessingException { JsonProcessingException {
jgen.writeString(StringEscapeUtils.unescapeHtml4(value)); jgen.writeString(StringEscapeUtils.unescapeHtml4(value));
} }
})); }));
// 设置时区 // 设置时区
this.setTimeZone(TimeZone.getDefault());//getTimeZone("GMT+8:00") this.setTimeZone(TimeZone.getDefault());//getTimeZone("GMT+8:00")
} }
/** /**
* 创建只输出非Null且非Empty(如List.isEmpty)的属性到Json字符串的Mapper,建议在外部接口中使用. * 创建只输出非Null且非Empty(如List.isEmpty)的属性到Json字符串的Mapper,建议在外部接口中使用.
*/ */
public static JsonMapper getInstance() { public static JsonMapper getInstance() {
if (mapper == null){ if (mapper == null) {
mapper = new JsonMapper().enableSimple(); mapper = new JsonMapper().enableSimple();
} }
return mapper; return mapper;
} }
/** /**
* 创建只输出初始值被改变的属性到Json字符串的Mapper, 最节约的存储方式,建议在内部接口中使用。 * 创建只输出初始值被改变的属性到Json字符串的Mapper, 最节约的存储方式,建议在内部接口中使用。
*/ */
public static JsonMapper nonDefaultMapper() { public static JsonMapper nonDefaultMapper() {
if (mapper == null){ if (mapper == null) {
mapper = new JsonMapper(Include.NON_DEFAULT); mapper = new JsonMapper(Include.NON_DEFAULT);
} }
return mapper; return mapper;
} }
/**
* Object可以是POJO,也可以是Collection或数组。
* 如果对象为Null, 返回"null".
* 如果集合为空集合, 返回"[]".
*/
public String toJson(Object object) {
try {
return this.writeValueAsString(object);
} catch (IOException e) {
logger.warn("write to json string error:" + object, e);
return null;
}
}
/** /**
* 反序列化POJO或简单Collection如List<String>. * Object可以是POJO,也可以是Collection或数组。
* * 如果对象为Null, 返回"null".
* 如果JSON字符串为Null或"null"字符串, 返回Null. * 如果集合为空集合, 返回"[]".
* 如果JSON字符串为"[]", 返回空集合. */
* public String toJson(Object object) {
* 如需反序列化复杂Collection如List<MyBean>, 请使用fromJson(String,JavaType) try {
* @see #fromJson(String, JavaType) return this.writeValueAsString(object);
*/ } catch (IOException e) {
public <T> T fromJson(String jsonString, Class<T> clazz) { logger.warn("write to json string error:" + object, e);
if (StringUtils.isEmpty(jsonString)) { return null;
return null; }
} }
try {
return this.readValue(jsonString, clazz);
} catch (IOException e) {
logger.warn("parse json string error:" + jsonString, e);
return null;
}
}
/** /**
* 反序列化复杂Collection如List<Bean>, 先使用函數createCollectionType构造类型,然后调用本函数. * 反序列化POJO或简单Collection如List<String>.
* @see #createCollectionType(Class, Class...) * <p>
*/ * 如果JSON字符串为Null或"null"字符串, 返回Null.
@SuppressWarnings("unchecked") * 如果JSON字符串为"[]", 返回空集合.
public <T> T fromJson(String jsonString, JavaType javaType) { * <p>
if (StringUtils.isEmpty(jsonString)) { * 如需反序列化复杂Collection如List<MyBean>, 请使用fromJson(String,JavaType)
return null; *
} * @see #fromJson(String, JavaType)
try { */
return (T) this.readValue(jsonString, javaType); public <T> T fromJson(String jsonString, Class<T> clazz) {
} catch (IOException e) { if (StringUtils.isEmpty(jsonString)) {
logger.warn("parse json string error:" + jsonString, e); return null;
return null; }
} try {
} return this.readValue(jsonString, clazz);
} catch (IOException e) {
logger.warn("parse json string error:" + jsonString, e);
return null;
}
}
/** /**
* 構造泛型的Collection Type如: * 反序列化复杂Collection如List<Bean>, 先使用函數createCollectionType构造类型,然后调用本函数.
* ArrayList<MyBean>, 则调用constructCollectionType(ArrayList.class,MyBean.class) *
* HashMap<String,MyBean>, 则调用(HashMap.class,String.class, MyBean.class) * @see #createCollectionType(Class, Class...)
*/ */
public JavaType createCollectionType(Class<?> collectionClass, Class<?>... elementClasses) { @SuppressWarnings("unchecked")
return this.getTypeFactory().constructParametricType(collectionClass, elementClasses); public <T> T fromJson(String jsonString, JavaType javaType) {
} if (StringUtils.isEmpty(jsonString)) {
return null;
}
try {
return (T) this.readValue(jsonString, javaType);
} catch (IOException e) {
logger.warn("parse json string error:" + jsonString, e);
return null;
}
}
/** /**
* 當JSON裡只含有Bean的部分屬性時,更新一個已存在Bean,只覆蓋該部分的屬性. * 構造泛型的Collection Type如:
*/ * ArrayList<MyBean>, 则调用constructCollectionType(ArrayList.class,MyBean.class)
@SuppressWarnings("unchecked") * HashMap<String,MyBean>, 则调用(HashMap.class,String.class, MyBean.class)
public <T> T update(String jsonString, T object) { */
try { public JavaType createCollectionType(Class<?> collectionClass, Class<?>... elementClasses) {
return (T) this.readerForUpdating(object).readValue(jsonString); return this.getTypeFactory().constructParametricType(collectionClass, elementClasses);
} catch (JsonProcessingException e) { }
logger.warn("update json string:" + jsonString + " to object:" + object + " error.", e);
} catch (IOException e) {
logger.warn("update json string:" + jsonString + " to object:" + object + " error.", e);
}
return null;
}
/** /**
* 輸出JSONP格式數據. * 當JSON裡只含有Bean的部分屬性時,更新一個已存在Bean,只覆蓋該部分的屬性.
*/ */
public String toJsonP(String functionName, Object object) { @SuppressWarnings("unchecked")
return toJson(new JSONPObject(functionName, object)); public <T> T update(String jsonString, T object) {
} try {
return (T) this.readerForUpdating(object).readValue(jsonString);
} catch (JsonProcessingException e) {
logger.warn("update json string:" + jsonString + " to object:" + object + " error.", e);
} catch (IOException e) {
logger.warn("update json string:" + jsonString + " to object:" + object + " error.", e);
}
return null;
}
/** /**
* 設定是否使用Enum的toString函數來讀寫Enum, * 輸出JSONP格式數據.
* 為False時時使用Enum的name()函數來讀寫Enum, 默認為False. */
* 注意本函數一定要在Mapper創建後, 所有的讀寫動作之前調用. public String toJsonP(String functionName, Object object) {
*/ return toJson(new JSONPObject(functionName, object));
public JsonMapper enableEnumUseToString() { }
this.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
this.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
return this;
}
/** /**
* 支持使用Jaxb的Annotation,使得POJO上的annotation不用与Jackson耦合。 * 設定是否使用Enum的toString函數來讀寫Enum,
* 默认会先查找jaxb的annotation,如果找不到再找jackson的。 * 為False時時使用Enum的name()函數來讀寫Enum, 默認為False.
*/ * 注意本函數一定要在Mapper創建後, 所有的讀寫動作之前調用.
public JsonMapper enableJaxbAnnotation() { */
JaxbAnnotationModule module = new JaxbAnnotationModule(); public JsonMapper enableEnumUseToString() {
this.registerModule(module); this.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
return this; this.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
} return this;
}
/** /**
* 允许单引号 * 支持使用Jaxb的Annotation,使得POJO上的annotation不用与Jackson耦合。
* 允许不带引号的字段名称 * 默认会先查找jaxb的annotation,如果找不到再找jackson的。
*/ */
public JsonMapper enableSimple() { public JsonMapper enableJaxbAnnotation() {
this.configure(Feature.ALLOW_SINGLE_QUOTES, true); JaxbAnnotationModule module = new JaxbAnnotationModule();
this.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); this.registerModule(module);
return this; return this;
} }
/** /**
* 取出Mapper做进一步的设置或使用其他序列化API. * 允许单引号
*/ * 允许不带引号的字段名称
public ObjectMapper getMapper() { */
return this; public JsonMapper enableSimple() {
} this.configure(Feature.ALLOW_SINGLE_QUOTES, true);
this.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
return this;
}
/**
* 取出Mapper做进一步的设置或使用其他序列化API.
*/
public ObjectMapper getMapper() {
return this;
}
/**
* 对象转换为JSON字符串
*
* @param object
* @return
*/
public static String toJsonString(Object object) {
return JsonMapper.getInstance().toJson(object);
}
/**
* JSON字符串转换为对象
*
* @param jsonString
* @param clazz
* @return
*/
public static Object fromJsonString(String jsonString, Class<?> clazz) {
return JsonMapper.getInstance().fromJson(jsonString, clazz);
}
/**
* 测试
*/
public static void main(String[] args) {
List<Map<String, Object>> list = Lists.newArrayList();
Map<String, Object> map = Maps.newHashMap();
map.put("id", 1);
map.put("pId", -1);
map.put("name", "根节点");
list.add(map);
map = Maps.newHashMap();
map.put("id", 2);
map.put("pId", 1);
map.put("name", "你好");
map.put("open", true);
list.add(map);
String json = JsonMapper.getInstance().toJson(list);
System.out.println(json);
}
/**
* 对象转换为JSON字符串
* @param object
* @return
*/
public static String toJsonString(Object object){
return JsonMapper.getInstance().toJson(object);
}
/**
* JSON字符串转换为对象
* @param jsonString
* @param clazz
* @return
*/
public static Object fromJsonString(String jsonString, Class<?> clazz){
return JsonMapper.getInstance().fromJson(jsonString, clazz);
}
/**
* 测试
*/
public static void main(String[] args) {
List<Map<String, Object>> list = Lists.newArrayList();
Map<String, Object> map = Maps.newHashMap();
map.put("id", 1);
map.put("pId", -1);
map.put("name", "根节点");
list.add(map);
map = Maps.newHashMap();
map.put("id", 2);
map.put("pId", 1);
map.put("name", "你好");
map.put("open", true);
list.add(map);
String json = JsonMapper.getInstance().toJson(list);
System.out.println(json);
}
} }
...@@ -19,9 +19,15 @@ public class AdvController { ...@@ -19,9 +19,15 @@ public class AdvController {
@PostMapping("/getAdvList") @PostMapping("/getAdvList")
public Response getAdvList(AdvRequest request) { public Response getAdvList(AdvRequest request) {
Response resp = new Response(); Response resp = new Response();
resp.setData(advService.getAdvList(request)); try {
resp.setStatus(ComCode.STATUS_CODE_2000); resp.setData(advService.getAdvList(request));
resp.setMessage(ComCode.STATUS_CODE_2000_DESC); resp.setStatus(ComCode.STATUS_CODE_2000);
resp.setMessage(ComCode.STATUS_CODE_2000_DESC);
} catch (Exception e) {
resp.setStatus(ComCode.STATUS_CODE_9998);
resp.setMessage(ComCode.STATUS_CODE_9998_DESC);
resp.setError(e.getMessage());
}
return resp; return resp;
} }
......
package com.thinkgem.jeesite.modules.homepage.api;
import com.thinkgem.jeesite.common.baseBean.Response;
import com.thinkgem.jeesite.common.constant.ComCode;
import com.thinkgem.jeesite.modules.homepage.bean.AdvRequest;
import com.thinkgem.jeesite.modules.homepage.bean.NoticeRequest;
import com.thinkgem.jeesite.modules.homepage.service.AdvService;
import com.thinkgem.jeesite.modules.homepage.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 验证失败返回
*/
@RestController
@RequestMapping("/api/home")
public class NoticeController {
@Autowired
private NoticeService noticeService;
@PostMapping("/getNotices")
public Response getNotices(NoticeRequest request) {
Response resp = new Response();
try {
resp.setData(noticeService.getNotice(request));
resp.setStatus(ComCode.STATUS_CODE_2000);
resp.setMessage(ComCode.STATUS_CODE_2000_DESC);
} catch (Exception e) {
resp.setStatus(ComCode.STATUS_CODE_9998);
resp.setMessage(ComCode.STATUS_CODE_9998_DESC);
resp.setError(e.getMessage());
}
return resp;
}
}
package com.thinkgem.jeesite.modules.homepage.bean;
import com.thinkgem.jeesite.common.baseBean.Request;
public class NoticeRequest extends Request {
private String noticeType; // 通知类型,F首页滚动通知 T首页弹窗
public String getNoticeType() {
return noticeType;
}
public void setNoticeType(String noticeType) {
this.noticeType = noticeType;
}
}
package com.thinkgem.jeesite.modules.homepage.dao;
import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
import com.thinkgem.jeesite.modules.homepage.bean.AdvRequest;
import com.thinkgem.jeesite.modules.homepage.bean.NoticeRequest;
import com.thinkgem.jeesite.modules.homepage.entity.AdvEntity;
import com.thinkgem.jeesite.modules.homepage.entity.NoticeEntity;
import java.util.List;
@MyBatisDao
public interface NoticeDao {
List<NoticeEntity> getNotice(NoticeRequest request);
}
package com.thinkgem.jeesite.modules.homepage.entity; package com.thinkgem.jeesite.modules.homepage.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.thinkgem.jeesite.common.baseBean.BaseEntity; import com.thinkgem.jeesite.common.baseBean.BaseEntity;
import java.io.Serializable; import java.io.Serializable;
...@@ -11,9 +12,15 @@ public class AdvEntity extends BaseEntity implements Serializable { ...@@ -11,9 +12,15 @@ public class AdvEntity extends BaseEntity implements Serializable {
private String href; //链接地址 private String href; //链接地址
private String target; //打开目标 private String target; //打开目标
private String picture; //图片地址 private String picture; //图片地址
@JsonIgnore
private String weight; //权重 private String weight; //权重
@JsonIgnore
private String status; //状态 private String status; //状态
private String clicks; //点击次数 private String clicks; //点击次数
@JsonIgnore
private String expireTime; //过期时间
@JsonIgnore
private String beginTime; //生效时间
public String getType() { public String getType() {
return type; return type;
...@@ -78,4 +85,20 @@ public class AdvEntity extends BaseEntity implements Serializable { ...@@ -78,4 +85,20 @@ public class AdvEntity extends BaseEntity implements Serializable {
public void setClicks(String clicks) { public void setClicks(String clicks) {
this.clicks = clicks; this.clicks = clicks;
} }
public String getExpireTime() {
return expireTime;
}
public void setExpireTime(String expireTime) {
this.expireTime = expireTime;
}
public String getBeginTime() {
return beginTime;
}
public void setBeginTime(String beginTime) {
this.beginTime = beginTime;
}
} }
package com.thinkgem.jeesite.modules.homepage.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.thinkgem.jeesite.common.baseBean.BaseEntity;
import java.io.Serializable;
public class NoticeEntity extends BaseEntity implements Serializable {
private String title; // 标题
private String image; // 图片
private String keywords; // 关键字
private String description; // 摘要
@JsonIgnore
private String weight; // 权重
@JsonIgnore
private String hits; // 点击数
@JsonIgnore
private String is_flow; // 是否滚动通知
@JsonIgnore
private String is_tip; // 是否弹窗通知
private String content; // 内容
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
public String getKeywords() {
return keywords;
}
public void setKeywords(String keywords) {
this.keywords = keywords;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getWeight() {
return weight;
}
public void setWeight(String weight) {
this.weight = weight;
}
public String getHits() {
return hits;
}
public void setHits(String hits) {
this.hits = hits;
}
public String getIs_flow() {
return is_flow;
}
public void setIs_flow(String is_flow) {
this.is_flow = is_flow;
}
public String getIs_tip() {
return is_tip;
}
public void setIs_tip(String is_tip) {
this.is_tip = is_tip;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}
...@@ -19,7 +19,7 @@ public class AdvService { ...@@ -19,7 +19,7 @@ public class AdvService {
@Autowired @Autowired
private AdvDao advDao; private AdvDao advDao;
public List<AdvEntity> getAdvList(AdvRequest request) { public List<AdvEntity> getAdvList(AdvRequest request) throws Exception {
return advDao.getAdvList(request); return advDao.getAdvList(request);
} }
} }
package com.thinkgem.jeesite.modules.homepage.service;
import com.thinkgem.jeesite.modules.homepage.bean.AdvRequest;
import com.thinkgem.jeesite.modules.homepage.bean.NoticeRequest;
import com.thinkgem.jeesite.modules.homepage.dao.AdvDao;
import com.thinkgem.jeesite.modules.homepage.dao.NoticeDao;
import com.thinkgem.jeesite.modules.homepage.entity.AdvEntity;
import com.thinkgem.jeesite.modules.homepage.entity.NoticeEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* 轮播图
*/
@Service
@Transactional(readOnly = true)
public class NoticeService {
@Autowired
private NoticeDao noticeDao;
public List<NoticeEntity> getNotice(NoticeRequest request) throws Exception {
return noticeDao.getNotice(request);
}
}
...@@ -3,22 +3,23 @@ ...@@ -3,22 +3,23 @@
<mapper namespace="com.thinkgem.jeesite.modules.homepage.dao.AdvDao"> <mapper namespace="com.thinkgem.jeesite.modules.homepage.dao.AdvDao">
<select id="getAdvList" resultType="com.thinkgem.jeesite.modules.homepage.entity.AdvEntity"> <select id="getAdvList" resultType="com.thinkgem.jeesite.modules.homepage.entity.AdvEntity">
SELECT a.id, SELECT
a.code, a.id,
a.type, a.code,
a.title, a.type,
a.href, a.title,
a.target, a.href,
a.picture, a.target,
a.weight, a.picture,
a.status, a.weight,
a.clicks, a.status,
a.expire_time, a.clicks,
a.begin_time, a.expire_time AS expireTime,
a.created, a.begin_time AS beginTime,
a.created_user, a.create_date AS created,
a.modified, a.create_by AS createdUser,
a.modified_user a.update_date AS modified,
a.update_by AS modifiedUser
FROM youka_adv a FROM youka_adv a
WHERE a.status = 1 WHERE a.status = 1
<![CDATA[ AND (a.begin_time <= NOW() OR a.begin_time IS NULL)]]> <![CDATA[ AND (a.begin_time <= NOW() OR a.begin_time IS NULL)]]>
......
<?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.thinkgem.jeesite.modules.homepage.dao.NoticeDao">
<select id="getNotice" resultType="com.thinkgem.jeesite.modules.homepage.entity.NoticeEntity" parameterType="com.thinkgem.jeesite.modules.homepage.bean.NoticeRequest">
SELECT
a.id,
a.title,
a.image,
a.keywords,
a.description,
a.weight,
a.hits,
a.is_flow,
a.is_tip,
a.create_by,
a.create_date,
a.update_by,
a.update_date,
b.content
FROM
cms_article a
LEFT JOIN cms_article_data b ON a.id = b.id
WHERE
<if test='noticeType=="F"'>
a.is_flow = 'Y'
</if>
<if test='noticeType=="T"'>
a.is_tip = 'Y'
</if>
<if test='noticeType!="T" and noticeType!="F"'>
1=2
</if>
ORDER BY
a.weight DESC
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment