删除RecommendBannerDao与SuperRecommendBannerDao
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.homemodule; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.bus.recommend.RecommendBanner; |
| | | |
| | | public interface RecommendBannerMapper extends BaseMapper<RecommendBanner> { |
| | | |
| | | /** |
| | | * 按照OrderBy排序 |
| | | * |
| | | * @return |
| | | */ |
| | | List<RecommendBanner> listAllOrderByOrderby(); |
| | | |
| | | List<RecommendBanner> listSearchBy(); |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.homemodule; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.bus.su.recommend.SuperRecommendBanner; |
| | | |
| | | public interface SuperRecommendBannerMapper extends BaseMapper<SuperRecommendBanner> { |
| | | |
| | | /** |
| | | * 根据系统ID获取Banner |
| | | * |
| | | * @param systemId |
| | | * @return |
| | | */ |
| | | List<SuperRecommendBanner> listBySystem(Long systemId); |
| | | } |
| | |
| | |
|
| | | import java.io.Serializable;
|
| | |
|
| | | import javax.persistence.Column;
|
| | | import javax.persistence.Entity;
|
| | | import javax.persistence.FetchType;
|
| | | import javax.persistence.GeneratedValue;
|
| | | import javax.persistence.GenerationType;
|
| | | import javax.persistence.Id;
|
| | | import javax.persistence.JoinColumn;
|
| | | import javax.persistence.ManyToOne;
|
| | | import javax.persistence.Table;
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | import com.yeshi.fanli.entity.common.JumpDetail;
|
| | |
|
| | | //推荐Banner
|
| | | @Entity
|
| | | @Table(name = "yeshi_ec_recommend_banner")
|
| | | public class RecommendBanner implements Serializable{
|
| | | @Table("yeshi_ec_recommend_banner")
|
| | | public class RecommendBanner implements Serializable {
|
| | | /**
|
| | | *
|
| | | */
|
| | | private static final long serialVersionUID = 1L;
|
| | | |
| | | @Id
|
| | | @GeneratedValue(strategy = GenerationType.AUTO)
|
| | |
|
| | |
|
| | | @Column(name = "id")
|
| | | private long id;
|
| | | // @ManyToOne(fetch = FetchType.EAGER)
|
| | | // @JoinColumn(name = "jumpid")
|
| | | private Long id;
|
| | | // @ManyToOne(fetch = FetchType.EAGER)
|
| | | // @JoinColumn(name = "jumpid")
|
| | | @Column(name="jumpid")
|
| | | private JumpDetail jumpDetail;// 跳转详情
|
| | | @Column(length = 256)
|
| | | @Column(name = "params")
|
| | | private String params;// 跳转参数
|
| | | @Column(length = 256)
|
| | | @Column(name = "picture")
|
| | | private String picture;// 图片链接
|
| | | private long createtime;
|
| | | private int orderby;// 值越小越�? |
| | | @Column(name = "createtime")
|
| | | private Long createtime;
|
| | | @Column(name = "orderby")
|
| | | private Integer orderby;// 值越小越�?
|
| | | @Column(name = "`show`")
|
| | | private boolean show;// 是否显示
|
| | | private Boolean show;// 是否显示
|
| | | @Column(name = "`name`")
|
| | | private String name;
|
| | |
|
| | | public RecommendBanner() {
|
| | | }
|
| | | |
| | | public RecommendBanner(JumpDetail jumpDetail, String params,
|
| | | String picture, long createtime, int orderby, boolean show) {
|
| | |
|
| | | public RecommendBanner(JumpDetail jumpDetail, String params, String picture, Long createtime, Integer orderby,
|
| | | Boolean show) {
|
| | | super();
|
| | | this.jumpDetail = jumpDetail;
|
| | | this.params = params;
|
| | |
| | | this.name = name;
|
| | | }
|
| | |
|
| | | public boolean isShow() {
|
| | | public Boolean isShow() {
|
| | | return show;
|
| | | }
|
| | |
|
| | | public void setShow(boolean show) {
|
| | | public void setShow(Boolean show) {
|
| | | this.show = show;
|
| | | }
|
| | |
|
| | | public long getId() {
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(long id) {
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | |
| | | this.picture = picture;
|
| | | }
|
| | |
|
| | | public long getCreatetime() {
|
| | | public Long getCreatetime() {
|
| | | return createtime;
|
| | | }
|
| | |
|
| | | public void setCreatetime(long createtime) {
|
| | | public void setCreatetime(Long createtime) {
|
| | | this.createtime = createtime;
|
| | | }
|
| | |
|
| | | public int getOrderby() {
|
| | | public Integer getOrderby() {
|
| | | return orderby;
|
| | | }
|
| | |
|
| | | public void setOrderby(int orderby) {
|
| | | public void setOrderby(Integer orderby) {
|
| | | this.orderby = orderby;
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | import java.io.Serializable;
|
| | |
|
| | | import javax.persistence.Column;
|
| | | import javax.persistence.Entity;
|
| | | import javax.persistence.FetchType;
|
| | | import javax.persistence.GeneratedValue;
|
| | | import javax.persistence.GenerationType;
|
| | | import javax.persistence.Id;
|
| | | import javax.persistence.JoinColumn;
|
| | | import javax.persistence.ManyToOne;
|
| | | import javax.persistence.Table;
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.recommend.RecommendBanner;
|
| | | import com.yeshi.fanli.entity.system.BusinessSystem;
|
| | |
|
| | | @Entity
|
| | | @Table(name = "yeshi_ec_super_recommendbanner")
|
| | | public class SuperRecommendBanner implements Serializable{
|
| | | @Table("yeshi_ec_super_recommendbanner")
|
| | | public class SuperRecommendBanner implements Serializable {
|
| | | /**
|
| | | *
|
| | | */
|
| | | private static final long serialVersionUID = 1L;
|
| | | |
| | | @Id
|
| | | @GeneratedValue(strategy = GenerationType.AUTO)
|
| | | private static final Long serialVersionUID = 1L;
|
| | |
|
| | | @Column(name = "id")
|
| | | private long id;
|
| | | @ManyToOne(fetch = FetchType.EAGER)
|
| | | @JoinColumn(name = "recommendbanner_id")
|
| | | private Long id;
|
| | | @Column(name = "recommendbanner_id")
|
| | | private RecommendBanner recommendBanner;
|
| | | @ManyToOne(fetch = FetchType.EAGER)
|
| | | @JoinColumn(name = "system_id")
|
| | | @Column(name = "system_id")
|
| | | private BusinessSystem system;
|
| | |
|
| | | public SuperRecommendBanner() {
|
| | | }
|
| | | |
| | |
|
| | | public SuperRecommendBanner(RecommendBanner recommendBanner, BusinessSystem system) {
|
| | | super();
|
| | | this.recommendBanner = recommendBanner;
|
| | | this.system = system;
|
| | | }
|
| | |
|
| | | public long getId() {
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(long id) {
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
New file |
| | |
| | | <?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.yeshi.fanli.dao.mybatis.homemodule.RecommendBannerMapper"> |
| | | <resultMap id="BaseResultMap" |
| | | type="com.yeshi.fanli.entity.bus.recommend.RecommendBanner"> |
| | | <id column="id" property="id" jdbcType="BIGINT" /> |
| | | <result column="params" property="params" jdbcType="VARCHAR" /> |
| | | <result column="picture" property="picture" jdbcType="VARCHAR" /> |
| | | <result column="createtime" property="createtime" jdbcType="BIGINT" /> |
| | | <result column="orderby" property="orderby" jdbcType="INTEGER" /> |
| | | <result column="`show`" property="show" jdbcType="BOOLEAN" /> |
| | | <result column="`name`" property="name" jdbcType="VARCHAR" /> |
| | | <association property="jumpDetail" column="jumpid" |
| | | javaType="com.yeshi.fanli.entity.common.JumpDetail" |
| | | select="com.yeshi.fanli.dao.mybatis.common.JumpDetailMapper.selectByPrimaryKey"> |
| | | </association> |
| | | </resultMap> |
| | | <sql id="Base_Column_List">id,jumpid,params,picture,createtime,orderby,`show`,`name` |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_recommend_banner where id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_recommend_banner where id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" |
| | | parameterType="com.yeshi.fanli.entity.bus.recommend.RecommendBanner" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_recommend_banner |
| | | (id,jumpid,params,picture,createtime,orderby,`show`,`name`) values |
| | | (#{id,jdbcType=BIGINT},#{jumpDetail.id,jdbcType=BIGINT},#{params,jdbcType=VARCHAR},#{picture,jdbcType=VARCHAR},#{createtime,jdbcType=BIGINT},#{orderby,jdbcType=INTEGER},#{show,jdbcType=BOOLEAN},#{name,jdbcType=VARCHAR}) |
| | | </insert> |
| | | <insert id="insertSelective" |
| | | parameterType="com.yeshi.fanli.entity.bus.recommend.RecommendBanner" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | | insert into yeshi_ec_recommend_banner |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">id,</if> |
| | | <if test="jumpDetail != null">jumpid,</if> |
| | | <if test="params != null">params,</if> |
| | | <if test="picture != null">picture,</if> |
| | | <if test="createtime != null">createtime,</if> |
| | | <if test="orderby != null">orderby,</if> |
| | | <if test="show != null">`show`,</if> |
| | | <if test="name != null">`name`,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="jumpDetail != null">#{jumpDetail.id,jdbcType=BIGINT},</if> |
| | | <if test="params != null">#{params,jdbcType=VARCHAR},</if> |
| | | <if test="picture != null">#{picture,jdbcType=VARCHAR},</if> |
| | | <if test="createtime != null">#{createtime,jdbcType=BIGINT},</if> |
| | | <if test="orderby != null">#{orderby,jdbcType=INTEGER},</if> |
| | | <if test="show != null">#{show,jdbcType=BOOLEAN},</if> |
| | | <if test="name != null">#{name,jdbcType=VARCHAR},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" |
| | | parameterType="com.yeshi.fanli.entity.bus.recommend.RecommendBanner">update yeshi_ec_recommend_banner set jumpid = |
| | | #{jumpDetail.id,jdbcType=BIGINT},params = |
| | | #{params,jdbcType=VARCHAR},picture = |
| | | #{picture,jdbcType=VARCHAR},createtime = |
| | | #{createtime,jdbcType=BIGINT},orderby = |
| | | #{orderby,jdbcType=INTEGER},`show` = #{show,jdbcType=BOOLEAN},`name` = |
| | | #{name,jdbcType=VARCHAR} where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" |
| | | parameterType="com.yeshi.fanli.entity.bus.recommend.RecommendBanner"> |
| | | update yeshi_ec_recommend_banner |
| | | <set> |
| | | <if test="jumpDetail != null">jumpid=#{jumpDetail.id,jdbcType=BIGINT},</if> |
| | | <if test="params != null">params=#{params,jdbcType=VARCHAR},</if> |
| | | <if test="picture != null">picture=#{picture,jdbcType=VARCHAR},</if> |
| | | <if test="createtime != null">createtime=#{createtime,jdbcType=BIGINT},</if> |
| | | <if test="orderby != null">orderby=#{orderby,jdbcType=INTEGER},</if> |
| | | <if test="show != null">`show`=#{show,jdbcType=BOOLEAN},</if> |
| | | <if test="name != null">`name`=#{name,jdbcType=VARCHAR},</if> |
| | | </set> |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | </mapper> |
New file |
| | |
| | | <?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.yeshi.fanli.dao.mybatis.homemodule.SuperRecommendBannerMapper"> |
| | | <resultMap id="BaseResultMap" |
| | | type="com.yeshi.fanli.entity.bus.su.recommend.SuperRecommendBanner"> |
| | | <id column="id" property="id" jdbcType="BIGINT" /> |
| | | <association property="recommendBanner" column="recommendbanner_id" |
| | | javaType="com.yeshi.fanli.entity.bus.recommend.RecommendBanner" |
| | | select="com.yeshi.fanli.dao.mybatis.homemodule.RecommendBannerMapper.selectByPrimaryKey"></association> |
| | | |
| | | <association property="system" column="system_id" |
| | | javaType="com.yeshi.fanli.entity.system.BusinessSystem"> |
| | | <id column="system_id" property="id" jdbcType="BIGINT" /> |
| | | </association> |
| | | |
| | | </resultMap> |
| | | <sql id="Base_Column_List">id,recommendbanner_id,system_id</sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_super_recommendbanner where id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | |
| | | |
| | | <select id="listBySystem" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from yeshi_ec_super_recommendbanner left join |
| | | yeshi_ec_recommend_banner b on recommendbanner_id=b.id where system_id |
| | | = #{0} order by b.orderby |
| | | </select> |
| | | |
| | | |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_super_recommendbanner where id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" |
| | | parameterType="com.yeshi.fanli.entity.bus.su.recommend.SuperRecommendBanner" |
| | | useGeneratedKeys="true" keyProperty="id">insert into |
| | | yeshi_ec_super_recommendbanner (id,recommendbanner_id,system_id) |
| | | values |
| | | (#{id,jdbcType=BIGINT},#{recommendBanner.id,jdbcType=BIGINT},#{system.id,jdbcType=BIGINT}) |
| | | </insert> |
| | | <insert id="insertSelective" |
| | | parameterType="com.yeshi.fanli.entity.bus.su.recommend.SuperRecommendBanner" |
| | | useGeneratedKeys="true" keyProperty="id"> |
| | | insert into yeshi_ec_super_recommendbanner |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">id,</if> |
| | | <if test="recommendBanner != null">recommendbanner_id,</if> |
| | | <if test="system != null">system_id,</if> |
| | | </trim> |
| | | values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="recommendBanner != null">#{recommendBanner.id,jdbcType=BIGINT},</if> |
| | | <if test="system != null">#{system.id,jdbcType=BIGINT},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" |
| | | parameterType="com.yeshi.fanli.entity.bus.su.recommend.SuperRecommendBanner">update yeshi_ec_super_recommendbanner set |
| | | recommendbanner_id = #{recommendBanner.id,jdbcType=BIGINT},system_id = |
| | | #{system.id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKeySelective" |
| | | parameterType="com.yeshi.fanli.entity.bus.su.recommend.SuperRecommendBanner"> |
| | | update yeshi_ec_super_recommendbanner |
| | | <set> |
| | | <if test="recommendBanner != null">recommendbanner_id=#{recommendBanner.id,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="system != null">system_id=#{system.id,jdbcType=BIGINT},</if> |
| | | </set> |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | </mapper> |
| | |
| | | package com.yeshi.fanli.service.impl.goods;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Collection;
|
| | | import java.util.HashMap;
|
| | | import java.util.LinkedHashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.transaction.Transactional;
|
| | |
|
| | | import org.hibernate.HibernateException;
|
| | | import org.hibernate.Query;
|
| | | import org.hibernate.Session;
|
| | | import org.springframework.orm.hibernate4.HibernateCallback;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.goods.RecommendBannerDao;
|
| | | import com.yeshi.fanli.entity.admin.RecommendBannerAdmin;
|
| | | import com.yeshi.fanli.dao.mybatis.homemodule.RecommendBannerMapper;
|
| | | import com.yeshi.fanli.entity.bus.recommend.RecommendBanner;
|
| | | import com.yeshi.fanli.entity.bus.su.recommend.SuperRecommendBanner;
|
| | | import com.yeshi.fanli.entity.system.BusinessSystem;
|
| | | import com.yeshi.fanli.service.inter.config.BusinessSystemService;
|
| | | import com.yeshi.fanli.service.inter.goods.RecommendBannerService;
|
| | | import com.yeshi.fanli.service.inter.goods.SuperRecommendBannerService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.Utils;
|
| | |
|
| | | @Service
|
| | | public class RecommendBannerServiceImpl implements RecommendBannerService {
|
| | |
|
| | | @Resource
|
| | | private RecommendBannerDao recommendBannerDao;
|
| | | private RecommendBannerMapper recommendBannerMapper;
|
| | |
|
| | | @Resource
|
| | | private SuperRecommendBannerService superRecommendBannerService;
|
| | |
|
| | | @Resource
|
| | | private BusinessSystemService businessSystemService;
|
| | | |
| | |
|
| | | public List<RecommendBanner> getRecommendBanners() {
|
| | |
|
| | | return recommendBannerDao.list("from RecommendBanner rb order by rb.orderby");
|
| | |
|
| | | }
|
| | |
|
| | | public void addRecommendBanner(RecommendBanner banner) {
|
| | | banner.setCreatetime(java.lang.System.currentTimeMillis());
|
| | | recommendBannerDao.create(banner);
|
| | | }
|
| | |
|
| | | @SuppressWarnings("unchecked")
|
| | | public List<RecommendBannerAdmin> getRecommendBanners(int pageIndex,
|
| | | String platform, String packages, String key) {
|
| | | final int strat = pageIndex * Constant.PAGE_SIZE;
|
| | | platform = Utils.getMap().get(platform);
|
| | | com.yeshi.fanli.entity.system.BusinessSystem system = businessSystemService.getBusinessSystem(platform, packages);
|
| | | List<RecommendBanner> recommendBannerList=null;
|
| | | List<SuperRecommendBanner> superRecommendBannerList=null;
|
| | | Map<Long,RecommendBannerAdmin> recommendBannerAdminMap=new HashMap<Long, RecommendBannerAdmin>();
|
| | | List<RecommendBannerAdmin> recommendBannerAdmin=new ArrayList<RecommendBannerAdmin>();
|
| | | if(system == null){
|
| | | if("".equals(key.trim())){
|
| | | recommendBannerList = (List<RecommendBanner>) recommendBannerDao.excute(new HibernateCallback<List<RecommendBanner>>(){
|
| | | public List<RecommendBanner> doInHibernate(Session session)
|
| | | throws HibernateException {
|
| | | Query query = session.createQuery(" from RecommendBanner rb order by rb.orderby ");
|
| | | query.setFirstResult(strat);
|
| | | query.setMaxResults(Constant.PAGE_SIZE);
|
| | | return query.list();
|
| | | }
|
| | | });
|
| | | }else{
|
| | | final String likekey = "%"+key+"%";
|
| | | recommendBannerList= (List<RecommendBanner>) recommendBannerDao.excute(new HibernateCallback<List<RecommendBanner>>(){
|
| | | public List<RecommendBanner> doInHibernate(Session session)
|
| | | throws HibernateException {
|
| | | Query query = session.createQuery(" from RecommendBanner rs where rs.name like ? order by rs.orderby ");
|
| | | query.setFirstResult(strat);
|
| | | query.setMaxResults(Constant.PAGE_SIZE);
|
| | | query.setParameter(0, likekey);
|
| | | return query.list();
|
| | | }
|
| | | });
|
| | | }
|
| | | List<Long> rsIdList = new ArrayList<Long>();
|
| | | for (RecommendBanner rs : recommendBannerList) {
|
| | | rsIdList.add(rs.getId());
|
| | | }
|
| | | superRecommendBannerList = superRecommendBannerService.getSuperRecommendBannersByBanners(rsIdList);
|
| | | Map<Long,List<BusinessSystem>> superMap = new HashMap<Long, List<BusinessSystem>>();
|
| | | Long rsId=null;
|
| | | List<BusinessSystem> systemList=null;
|
| | | for (SuperRecommendBanner srs : superRecommendBannerList) {
|
| | | rsId = srs.getRecommendBanner().getId();
|
| | | systemList = superMap.get(rsId);
|
| | | if(systemList==null){
|
| | | systemList=new ArrayList<BusinessSystem>();
|
| | | }
|
| | | systemList.add(srs.getSystem());
|
| | | superMap.put(rsId,systemList);
|
| | | }
|
| | | RecommendBannerAdmin rsa=null;
|
| | | for (RecommendBanner recommendBanner : recommendBannerList) {
|
| | | long id = recommendBanner.getId();
|
| | | rsa = recommendBannerAdminMap.get(id);
|
| | | if(rsa==null){
|
| | | rsa=new RecommendBannerAdmin();
|
| | | }
|
| | | List<BusinessSystem> list = superMap.get(id);
|
| | | if(list != null){
|
| | | rsa.getSystemList().addAll(superMap.get(id));
|
| | | }
|
| | | rsa.setRecommendBanner(recommendBanner);
|
| | | recommendBannerAdminMap.put(id, rsa);
|
| | | } |
| | | }else if(system != null){
|
| | | if("".equals(key.trim())){
|
| | | superRecommendBannerList = superRecommendBannerService.getSuperRecommendBannerBySystemId(system.getId(),strat, Constant.PAGE_SIZE);
|
| | | }else{
|
| | | String likekey = "%"+key+"%";
|
| | | superRecommendBannerList = superRecommendBannerService.getSuperRecommendBannerBySystemId(system.getId(),strat, Constant.PAGE_SIZE,likekey);
|
| | | }
|
| | | List<Long> rsIdList =new ArrayList<Long>();
|
| | | for (SuperRecommendBanner superRecommendBanner : superRecommendBannerList) {
|
| | | RecommendBanner recommendBanner = superRecommendBanner.getRecommendBanner();
|
| | | rsIdList.add(recommendBanner.getId());
|
| | | }
|
| | | superRecommendBannerList = superRecommendBannerService.getSuperRecommendBannersByBanners(rsIdList);
|
| | | RecommendBannerAdmin rsa=null;
|
| | | for (SuperRecommendBanner superRecommendBanner : superRecommendBannerList) {
|
| | | RecommendBanner recommendBanner = superRecommendBanner.getRecommendBanner();
|
| | | rsa = recommendBannerAdminMap.get(recommendBanner.getId());
|
| | | if(rsa==null){
|
| | | rsa=new RecommendBannerAdmin(recommendBanner);
|
| | | }
|
| | | rsa.getSystemList().add(superRecommendBanner.getSystem());
|
| | | recommendBannerAdminMap.put(recommendBanner.getId(), rsa);
|
| | | }
|
| | | }
|
| | | Map<Long, RecommendBannerAdmin> obMap = (LinkedHashMap<Long, RecommendBannerAdmin>) Utils.orderBy(recommendBannerAdminMap);
|
| | | Collection<RecommendBannerAdmin> values = obMap.values();
|
| | | recommendBannerAdmin.addAll(values);
|
| | | return recommendBannerAdmin;
|
| | | |
| | | }
|
| | |
|
| | | public long getCount() {
|
| | | return recommendBannerDao
|
| | | .getCount("select count(*) from RecommendBanner");
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | public void deleteBanners(final long[] rbids) {
|
| | | superRecommendBannerService.deleteSuperRecommendBanners(rbids);
|
| | | recommendBannerDao.excute(new HibernateCallback() {
|
| | | public Object doInHibernate(Session session)
|
| | | throws HibernateException {
|
| | |
|
| | | StringBuffer sb = new
|
| | | // StringBuffer("delete b,j from yeshi_ec_recommend_banner b left join yeshi_ec_action_jumpdetail j on b.jumpid=j.id ");
|
| | | StringBuffer("delete b from yeshi_ec_recommend_banner b ");
|
| | | for (int i = 0; i < rbids.length; i++) {
|
| | | if(i==0){
|
| | | sb.append(" where b.id=? ");
|
| | | }else{
|
| | | sb.append(" or b.id=?");
|
| | | }
|
| | | }
|
| | | Query query = session.createSQLQuery(sb.toString());
|
| | | for (int i = 0; i < rbids.length; i++) {
|
| | | query.setLong(i, rbids[i]);
|
| | | }
|
| | | query.executeUpdate();
|
| | | return null;
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | public RecommendBanner getRecommendBanner(long id) {
|
| | | RecommendBanner banner = recommendBannerDao.find(RecommendBanner.class, id);
|
| | | return banner;
|
| | | return recommendBannerMapper.listAllOrderByOrderby();
|
| | | }
|
| | |
|
| | | public void updateBanner(RecommendBanner banner) {
|
| | | recommendBannerDao.update(banner);
|
| | | }
|
| | | |
| | | public int getCount(String platform, String packages, final String key) {
|
| | | platform = Utils.getMap().get(platform);
|
| | | final BusinessSystem system = businessSystemService.getBusinessSystem(platform, packages);
|
| | | return (Integer) recommendBannerDao.excute(new HibernateCallback<Integer>() {
|
| | | |
| | | public Integer doInHibernate(Session session)
|
| | | throws HibernateException {
|
| | | String k = "%"+key+"%";
|
| | | Query query;
|
| | | if(system==null){
|
| | | // query = session.createSQLQuery("select count(a.name) from (select name from yeshi_ec_recommend_banner where `name` like ?) a");
|
| | | query=session.createQuery("select count(rb.id) from RecommendBanner rb where rb.name like ? ");
|
| | | query.setParameter(0, k);
|
| | | }else{
|
| | | // query =session.createSQLQuery("select count(a.name) from (select hs.name from yeshi_ec_super_recommendbanner shs left join yeshi_ec_recommend_banner hs on shs.recommendbanner_id=hs.id where shs.system_id=? and hs.name like ?) a");
|
| | | query=session.createQuery("select count(srb.id) from SuperRecommendBanner srb where srb.system.id = ? and srb.recommendBanner.name like ?");
|
| | | query.setParameter(0, system.getId());
|
| | | query.setParameter(1, k);
|
| | | }
|
| | | Long result = (Long) query.uniqueResult();
|
| | | int intValue = result.intValue();
|
| | | return intValue;
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | public void updateBannerJumpDetail(final long id) {
|
| | | recommendBannerDao.excute(new HibernateCallback() {
|
| | |
|
| | | public Object doInHibernate(Session session)
|
| | | throws HibernateException {
|
| | | Query query = session.createQuery("update RecommendBanner rb set rb.jumpDetail.id = NULL where rb.jumpDetail.id = ?");
|
| | | query.setParameter(0, id);
|
| | | return query.executeUpdate();
|
| | | }
|
| | | });
|
| | | recommendBannerMapper.updateByPrimaryKeySelective(banner);
|
| | | }
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.impl.goods;
|
| | |
|
| | | import java.io.Serializable;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.hibernate.HibernateException;
|
| | | import org.hibernate.Query;
|
| | | import org.hibernate.Session;
|
| | | import org.hibernate.Transaction;
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.orm.hibernate4.HibernateCallback;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.goods.SuperRecommendBannerDao;
|
| | | import com.yeshi.fanli.entity.bus.recommend.RecommendBanner;
|
| | | import com.yeshi.fanli.dao.mybatis.homemodule.SuperRecommendBannerMapper;
|
| | | import com.yeshi.fanli.entity.bus.su.recommend.SuperRecommendBanner;
|
| | | import com.yeshi.fanli.entity.system.BusinessSystem;
|
| | | import com.yeshi.fanli.service.inter.config.BusinessSystemService;
|
| | | import com.yeshi.fanli.service.inter.goods.SuperRecommendBannerService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
|
| | | @Service
|
| | | public class SuperRecommendBannerServiceImpl implements
|
| | | SuperRecommendBannerService {
|
| | | public class SuperRecommendBannerServiceImpl implements SuperRecommendBannerService {
|
| | |
|
| | | @Resource
|
| | | private SuperRecommendBannerDao superRecommendBannerDao;
|
| | | |
| | | private SuperRecommendBannerMapper superRecommendBannerMapper;
|
| | |
|
| | | @Resource
|
| | | private BusinessSystemService businessSystemService;
|
| | | |
| | | |
| | | @Cacheable(value={"bannerCache"}, key="#root.methodName+#system.id")
|
| | | public List<SuperRecommendBanner> getSuperRecommendBannersBySystem(
|
| | | final BusinessSystem system) {
|
| | | List<SuperRecommendBanner> list = superRecommendBannerDao.list(
|
| | | "from SuperRecommendBanner srb where srb.system.id=? order by srb.recommendBanner.orderby",
|
| | | new Serializable[] { system.getId() });
|
| | |
|
| | | @Cacheable(value = { "bannerCache" }, key = "#root.methodName+#system.id")
|
| | | public List<SuperRecommendBanner> getSuperRecommendBannersBySystem(final BusinessSystem system) {
|
| | | List<SuperRecommendBanner> list = superRecommendBannerMapper.listBySystem(system.getId());
|
| | | return list;
|
| | | }
|
| | |
|
| | | public List<SuperRecommendBanner> getSuperRecommendBanners(int pageIndex) {
|
| | |
|
| | | int start = pageIndex * Constant.PAGE_SIZE;
|
| | |
|
| | | List<SuperRecommendBanner> list = superRecommendBannerDao.list(
|
| | | "from SuperRecommendBanner srb order by srb.recommendBanner.orderby", start, Constant.PAGE_SIZE,
|
| | | new Serializable[] {});
|
| | |
|
| | | return list;
|
| | | }
|
| | |
|
| | | public List<SuperRecommendBanner> getSuperRecommendBannersByBanners(
|
| | | List<Long> rbIdList) {
|
| | | if (rbIdList.size() == 0) {
|
| | | return new ArrayList<SuperRecommendBanner>();
|
| | | }
|
| | | StringBuffer sb = new StringBuffer(" from SuperRecommendBanner srb ");
|
| | | Serializable[] serArr = new Serializable[rbIdList.size()];
|
| | | for (int i = 0; i < rbIdList.size(); i++) {
|
| | | if (i == 0) {
|
| | | sb.append(" where srb.recommendBanner.id=? ");
|
| | | } else {
|
| | | sb.append(" or srb.recommendBanner.id=? ");
|
| | | }
|
| | | serArr[i] = rbIdList.get(i);
|
| | | }
|
| | | sb.append(" order by srb.recommendBanner.orderby ");
|
| | | String hql = sb.toString();
|
| | |
|
| | | return superRecommendBannerDao.list(hql, serArr);
|
| | |
|
| | | }
|
| | |
|
| | | public Integer deleteSuperRecommendBanner(final long rbid, final String platform,final String packageName) {
|
| | | return (Integer) superRecommendBannerDao.excute(new HibernateCallback<Integer>() {
|
| | |
|
| | | public Integer doInHibernate(Session session)
|
| | | throws HibernateException {
|
| | | BusinessSystem system = businessSystemService.getBusinessSystem(platform, packageName);
|
| | | Transaction transaction = session.beginTransaction();
|
| | | Query query = session.createQuery("delete SuperRecommendBanner srb "
|
| | | + " where srb.recommendBanner.id=? and srb.system.id=?");
|
| | | query.setLong(0, rbid);
|
| | | query.setLong(1, system.getId());
|
| | | int i = query.executeUpdate();
|
| | | transaction.commit();
|
| | | return i ;
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | public void addSuperRecommendBanner(long rbid, String platform,String packageName) {
|
| | | BusinessSystem system = businessSystemService.getBusinessSystem(platform,packageName);
|
| | | SuperRecommendBanner superRecommendBanner = new SuperRecommendBanner();
|
| | | RecommendBanner recommendBanner = new RecommendBanner();
|
| | | recommendBanner.setId(rbid);
|
| | | superRecommendBanner.setRecommendBanner(recommendBanner);
|
| | | superRecommendBanner.setSystem(system);
|
| | | superRecommendBannerDao.create(superRecommendBanner);
|
| | | }
|
| | |
|
| | | public void deleteSuperRecommendBanners(final long[] rbids) {
|
| | | superRecommendBannerDao.excute(new HibernateCallback() {
|
| | |
|
| | | public Object doInHibernate(Session session) throws HibernateException {
|
| | | |
| | | StringBuffer sb = new StringBuffer("delete from SuperRecommendBanner s ");
|
| | | for (int i = 0; i < rbids.length; i++) {
|
| | | if(i==0){
|
| | | sb.append(" where s.recommendBanner.id=? ");
|
| | | }else{
|
| | | sb.append(" or s.recommendBanner.id=?");
|
| | | }
|
| | | }
|
| | | Query query = session.createQuery(sb.toString());
|
| | | for (int i = 0; i < rbids.length; i++) {
|
| | | query.setLong(i, rbids[i]);
|
| | | }
|
| | | query.executeUpdate();
|
| | | return null;
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | public List<SuperRecommendBanner> getSuperRecommendBannerBySystemId(
|
| | | long id, int strat, int count) {
|
| | | return superRecommendBannerDao.list("from SuperRecommendBanner srs where srs.system.id=? order by srs.recommendBanner.orderby ",strat,count,new Serializable[]{id});
|
| | | |
| | | }
|
| | |
|
| | |
|
| | | public List<SuperRecommendBanner> getSuperRecommendBannerBySystemId(
|
| | | long id, int strat, int count, String key) {
|
| | | return superRecommendBannerDao.list("from SuperRecommendBanner srs where srs.system.id=? and srs.recommendBanner.name like ?",strat,count,new Serializable[]{id, key});
|
| | | |
| | | }
|
| | |
|
| | | |
| | | }
|
| | |
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.admin.RecommendBannerAdmin;
|
| | | import com.yeshi.fanli.entity.bus.recommend.RecommendBanner;
|
| | |
|
| | | public interface RecommendBannerService {
|
| | |
|
| | | public List<RecommendBanner> getRecommendBanners();
|
| | |
|
| | | public void addRecommendBanner(RecommendBanner banner);
|
| | |
|
| | | public List<RecommendBannerAdmin> getRecommendBanners(int pageIndex, String platform, String packages, String key);
|
| | |
|
| | | public long getCount();
|
| | |
|
| | | public void deleteBanners(long[] rbids);
|
| | |
|
| | | public RecommendBanner getRecommendBanner(long id);
|
| | |
|
| | | public void updateBanner(RecommendBanner banner);
|
| | |
|
| | | public int getCount(String platform, String packages, String key);
|
| | |
|
| | | public void updateBannerJumpDetail(long id);
|
| | | |
| | | }
|
| | |
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import org.springframework.cache.annotation.CacheEvict;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.su.recommend.SuperRecommendBanner;
|
| | | import com.yeshi.fanli.entity.system.BusinessSystem;
|
| | |
|
| | | public interface SuperRecommendBannerService {
|
| | | |
| | | public List<SuperRecommendBanner> getSuperRecommendBannersBySystem(BusinessSystem system);
|
| | |
|
| | | public List<SuperRecommendBanner> getSuperRecommendBannersByBanners(
|
| | | List<Long> rbIdList);
|
| | | @CacheEvict(value={"bannerCache"},allEntries=true)
|
| | | public Integer deleteSuperRecommendBanner(long rbid, String platform, String packageName);
|
| | | |
| | | @CacheEvict(value={"bannerCache"},allEntries=true)
|
| | | public void addSuperRecommendBanner(long rbid, String platform,String packageName);
|
| | | @CacheEvict(value={"bannerCache"},allEntries=true)
|
| | | public void deleteSuperRecommendBanners(long[] rbids);
|
| | |
|
| | | public List<SuperRecommendBanner> getSuperRecommendBannerBySystemId(
|
| | | long id, int strat, int count);
|
| | |
|
| | | public List<SuperRecommendBanner> getSuperRecommendBannerBySystemId(
|
| | | long id, int strat, int pAGE_SIZE, String likekey);
|
| | |
|
| | | }
|