yujian
2019-03-20 4d51ffeaf4ed8ac00697fc80a1437319110aab8e
Merge branch 'div'
1个文件已修改
7个文件已添加
999 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/FloatADAdminController.java 189 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/ConfigController.java 39 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/homemodule/FloatADMapper.java 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/homemodule/FloatAD.java 207 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/exception/FloatADException.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/homemodule/FloatADMapper.xml 148 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/FloatADServiceImpl.java 257 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/homemodule/FloatADService.java 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/FloatADAdminController.java
New file
@@ -0,0 +1,189 @@
package com.yeshi.fanli.controller.admin.homemodule;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.yeshi.utils.JsonUtil;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.yeshi.fanli.entity.bus.homemodule.FloatAD;
import com.yeshi.fanli.exception.FloatADException;
import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
import com.yeshi.fanli.service.inter.homemodule.FloatADService;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import net.sf.json.JSONObject;
@Controller
@RequestMapping("admin/new/api/v1/floatad")
public class FloatADAdminController {
    @Resource
    private FloatADService floatADervice;
    @Resource
    private JumpDetailV2Service jumpDetailV2Service;
    /**
     * 保存信息
     *
     * @param callback
     * @param special
     * @param out
     */
    @RequestMapping(value = "save")
    public void save(String callback, FloatAD floatAD, String jumpType, HttpServletRequest request,PrintWriter out) {
        try {
            // 1. 先判断httpRequest 是否含有文件类型
            if (request instanceof MultipartHttpServletRequest) {
                MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request;
                floatADervice.saveObject(fileRequest.getFile("file"), floatAD, jumpType);
            }else{
                floatADervice.saveObject(null, floatAD, jumpType);
            }
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
        } catch (FloatADException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("保存失败"));
            e.printStackTrace();
        }
    }
//    /**
//     * 保存信息
//     *
//     * @param callback
//     * @param special
//     * @param out
//     */
//    @RequestMapping(value = "save")
//    public void save(String callback, @RequestParam("file") CommonsMultipartFile[] file, FloatAD floatAD,
//            String jumpType, PrintWriter out) {
//        try {
//            floatADervice.saveObject(file, floatAD, jumpType);
//            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
//        } catch (FloatADException e) {
//            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
//        } catch (Exception e) {
//            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("保存失败"));
//            e.printStackTrace();
//        }
//    }
    /**
     * 修改排序
     *
     * @param callback
     * @param goodsClass
     * @param out
     */
    @RequestMapping(value = "updateOrder")
    public void updateOrder(String callback, Long id, Integer moveType, PrintWriter out) {
        try {
            floatADervice.updateOrder(id, moveType);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
        } catch (FloatADException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作失败"));
            e.printStackTrace();
        }
    }
    /**
     * 删除
     *
     * @param callback
     * @param idArray
     * @param out
     */
    @RequestMapping(value = "delete")
    public void delete(String callback, String idArray, PrintWriter out) {
        try {
            if (StringUtil.isNullOrEmpty(idArray)) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择操作的数据"));
                return;
            }
            Gson gson = new Gson();
            List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {
            }.getType());
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检测到删除的数据"));
                return;
            }
            int count = floatADervice.deleteByPrimaryKeyList(list);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("成功删除[" + count + "]条数据"));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("删除失败"));
            e.printStackTrace();
        }
    }
    /**
     * 查询
     *
     * @param callback
     * @param pageIndex
     * @param pageSize
     * @param out
     */
    @RequestMapping(value = "query")
    public void query(String callback, Integer pageIndex, Integer pageSize, String key, Integer state,
            PrintWriter out) {
        if (pageIndex == null || pageIndex < 1) {
            pageIndex = 1;
        }
        if (pageSize == null || pageSize < 1) {
            pageSize = Constant.PAGE_SIZE;
        }
        try {
            List<FloatAD> list = floatADervice.listQuery((pageIndex - 1) * pageSize, pageSize, key, state);
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            long count = floatADervice.countQuery(key, state);
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
            GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.serializeNulls();
            Gson gson = gsonBuilder.setDateFormat("yyyy-MM-dd'T'HH:mm").create();
            JSONObject data = new JSONObject();
            data.put("pe", pe);
            data.put("result_list", gson.toJson(list));
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
            e.printStackTrace();
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/client/ConfigController.java
@@ -11,12 +11,14 @@
import org.yeshi.utils.encrypt.DESUtil;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.homemodule.FloatAD;
import com.yeshi.fanli.entity.config.AppHomeFloatImg;
import com.yeshi.fanli.entity.taobao.ClientTBPid;
import com.yeshi.fanli.entity.taobao.PidUser;
import com.yeshi.fanli.entity.taobao.TBPid;
import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.homemodule.FloatADService;
import com.yeshi.fanli.service.inter.order.CommonOrderCountService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
import com.yeshi.fanli.service.inter.user.TBPidService;
@@ -47,6 +49,10 @@
    @Resource
    private CommonOrderCountService commonOrderCountService;
    @Resource
    private FloatADService floatADService;
    /**
     * 首页配置信息
     * 
@@ -56,24 +62,37 @@
    @RequestMapping(value = "getHomeConfig", method = RequestMethod.POST)
    public void getHomeConfig(AcceptData acceptData, Long uid, PrintWriter out) {
        AppHomeFloatImg appHomeFloatImg = configService.getAppHomeFloatImg();
        if ("ios".equalsIgnoreCase(acceptData.getPlatform()) && !Constant.IS_TEST)
        if ("ios".equalsIgnoreCase(acceptData.getPlatform()) && !Constant.IS_TEST) {
            appHomeFloatImg = null;
        }
        JSONObject data = new JSONObject();
        if (appHomeFloatImg != null)
        if (appHomeFloatImg != null) {
            data.put("floatImg", appHomeFloatImg);
        }
        String notifyImg = configService.getAppHomeFloatNotifyImg();
        if (!StringUtil.isNullOrEmpty(notifyImg)) {
            data.put("floatNotifyImg", notifyImg);
        }
        //
        String config = configService.get("home_float_img_new");
        if (!StringUtil.isNullOrEmpty(config)) {
            if (uid != null) {
                if (!commonOrderCountService.hasRebateAndShareOrder(uid))
                    data.put("floatImgDetail", config);
            } else
                data.put("floatImgDetail", config);
        // 悬浮大图 1.5.2  -2019.3.20
        FloatAD floatAD = floatADService.getEffectiveFloatAD(FloatAD.POSITION_INDEX);
        if (floatAD != null) {
            JSONObject detail = new JSONObject();
            detail.put("img", floatAD.getPicture());
            detail.put("jumpDetail", floatAD.getJumpDetail());
            detail.put("params", floatAD.getParams());
            detail.put("showTime", floatAD.getShowMode());
            detail.put("accountLogin", floatAD.isJumpNeedLogin());
            if (uid != null && !commonOrderCountService.hasRebateAndShareOrder(uid)) {
                data.put("floatImgDetail", detail);
            } else {
                data.put("floatImgDetail", detail);
        }
        }
        // 领券帮助链接,1.5.2后生效
        String couponHelp = configService.get("taobao_coupon_help");
        data.put("couponHelpUrl", couponHelp);
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/homemodule/FloatADMapper.java
New file
@@ -0,0 +1,65 @@
package com.yeshi.fanli.dao.mybatis.homemodule;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.bus.homemodule.FloatAD;
public interface FloatADMapper extends BaseMapper<FloatAD>{
    /**
     * 批量删除
     * @param list
     * @return
     */
    int deleteByPrimaryKeyList(List<Long> list);
    /**
     * 根据主键查询
     * @param list
     * @return
     */
    List<FloatAD> ListByPrimaryKey(List<Long> list);
   /**
           *  后端列表查询
    * @param start
    * @param count
    * @param key
    * @param state
    * @return
    */
    List<FloatAD> listQuery(@Param("start") long start, @Param("count") int count, @Param("key") String key,
            @Param("state") Integer state);
    long countQuery(@Param("key") String key, @Param("state") Integer state);
    /**
     * 获取相邻序号
     * @param position
     * @param type
     * @return
     */
    FloatAD getByAdjoinOrder(@Param("position") String position, @Param("order") Integer order,
            @Param("type") Integer type);
    /**
     * 根据位置统计个数
     * @param position
     * @return
     */
    int countByPosition(@Param("position") String position);
    /**
     * 查询有效弹出框
     * @param position
     * @return
     */
    FloatAD getEffectiveFloatAD(@Param("position") String position);
}
fanli/src/main/java/com/yeshi/fanli/entity/bus/homemodule/FloatAD.java
New file
@@ -0,0 +1,207 @@
package com.yeshi.fanli.entity.bus.homemodule;
import java.util.Date;
import org.springframework.format.annotation.DateTimeFormat;
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
import com.google.gson.annotations.Expose;
import com.yeshi.fanli.entity.common.JumpDetailV2;
/**
 * 活动弹出框
 *
 * @author yj
 *
 */
@Table("yeshi_ec_float_ad")
public class FloatAD {
    // 每天展示一次
    public static String MODE_ONCE_DAY = "everyday";
    // 每次打开首页都展示
    public static String MODE_EVERY = "always";
    // 展示位置 -首页
    public static String POSITION_INDEX = "index";
    @Column(name = "fa_id")
    private Long id;
    // 名称
    @Expose
    @Column(name = "fa_name")
    private String name;
    // 图片
    @Expose
    @Column(name = "fa_picture")
    private String picture;
    // 显示方式
    @Expose
    @Column(name = "fa_show_mode")
    private String showMode;
    // 跳转方式
    @Expose
    @Column(name = "fa_jumpid")
    private JumpDetailV2 jumpDetail;
    // 跳转参数
    @Expose
    @Column(name = "fa_params")
    private String params;
    // 跳转界面是否需要登陆
    @Column(name = "fa_jump_need_login")
    private boolean jumpNeedLogin;
    // 起始时间
    @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm")
    @Column(name = "fa_start_time")
    private Date startTime;
    // 结束日期
    @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm")
    @Column(name = "fa_end_time")
    private Date endTime;
    // 使用位置
    @Column(name = "fa_position")
    private String position;
    // 排序-优先权
    @Column(name = "fa_order")
    private Integer order;
    // 启用状态
    @Column(name = "fa_state")
    private Integer state;
    // 创建时间
    @Column(name = "fa_create_time")
    private Date createTime;
    // 更新时间
    @Column(name = "fa_update_time")
    private Date updateTime;
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getPicture() {
        return picture;
    }
    public void setPicture(String picture) {
        this.picture = picture;
    }
    public JumpDetailV2 getJumpDetail() {
        return jumpDetail;
    }
    public void setJumpDetail(JumpDetailV2 jumpDetail) {
        this.jumpDetail = jumpDetail;
    }
    public String getParams() {
        return params;
    }
    public void setParams(String params) {
        this.params = params;
    }
    public boolean isJumpNeedLogin() {
        return jumpNeedLogin;
    }
    public void setJumpNeedLogin(boolean jumpNeedLogin) {
        this.jumpNeedLogin = jumpNeedLogin;
    }
    public Date getStartTime() {
        return startTime;
    }
    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }
    public Date getEndTime() {
        return endTime;
    }
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
    public String getPosition() {
        return position;
    }
    public void setPosition(String position) {
        this.position = position;
    }
    public Integer getOrder() {
        return order;
    }
    public void setOrder(Integer order) {
        this.order = order;
    }
    public Integer getState() {
        return state;
    }
    public void setState(Integer state) {
        this.state = state;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public String getShowMode() {
        return showMode;
    }
    public void setShowMode(String showMode) {
        this.showMode = showMode;
    }
}
fanli/src/main/java/com/yeshi/fanli/exception/FloatADException.java
New file
@@ -0,0 +1,32 @@
package com.yeshi.fanli.exception;
public class FloatADException extends Exception {
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    private int code;
    private String msg;
    public int getCode() {
        return code;
    }
    public String getMsg() {
        return msg;
    }
    public FloatADException(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    public FloatADException() {
    }
    @Override
    public String getMessage() {
        return this.msg;
    }
}
fanli/src/main/java/com/yeshi/fanli/mapping/homemodule/FloatADMapper.xml
New file
@@ -0,0 +1,148 @@
<?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.FloatADMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.homemodule.FloatAD">
    <id column="fa_id" property="id" jdbcType="BIGINT"/>
    <result column="fa_name" property="name" jdbcType="VARCHAR"/>
    <result column="fa_picture" property="picture" jdbcType="VARCHAR"/>
    <result column="fa_show_mode" property="showMode" jdbcType="VARCHAR"/>
    <result column="fa_params" property="params" jdbcType="VARCHAR"/>
    <result column="fa_jump_need_login" property="jumpNeedLogin" jdbcType="VARCHAR"/>
    <result column="fa_start_time" property="startTime" jdbcType="TIMESTAMP"/>
    <result column="fa_end_time" property="endTime" jdbcType="TIMESTAMP"/>
    <result column="fa_position" property="position" jdbcType="VARCHAR"/>
    <result column="fa_order" property="order" jdbcType="INTEGER"/>
    <result column="fa_state" property="state" jdbcType="INTEGER"/>
    <result column="fa_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="fa_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    <association property="jumpDetail"  column="fa_jumpid" javaType="com.yeshi.fanli.entity.common.JumpDetailV2">
            <id column="fa_jumpid" property="id" jdbcType="BIGINT" />
    </association>
  </resultMap>
  <sql id="Base_Column_List">fa_id,fa_name,fa_picture,fa_show_mode,fa_jumpid,fa_params,fa_jump_need_login,fa_start_time,fa_end_time,fa_position,fa_order,fa_state,fa_create_time,fa_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_float_ad where fa_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_float_ad where fa_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.homemodule.FloatAD" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_float_ad (fa_id,fa_name,fa_picture,fa_show_mode,fa_jumpid,fa_params,fa_jump_need_login,fa_start_time,fa_end_time,fa_position,fa_order,fa_state,fa_create_time,fa_update_time) values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{picture,jdbcType=VARCHAR},#{showMode,jdbcType=VARCHAR},#{jumpDetail.id,jdbcType=BIGINT},#{params,jdbcType=VARCHAR},#{jumpNeedLogin,jdbcType=VARCHAR},#{startTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{position,jdbcType=VARCHAR},#{order,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.homemodule.FloatAD" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_float_ad
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">fa_id,</if>
      <if test="name != null">fa_name,</if>
      <if test="picture != null">fa_picture,</if>
      <if test="showMode != null">fa_show_mode,</if>
      <if test="jumpDetail != null">fa_jumpid,</if>
      <if test="params != null">fa_params,</if>
      <if test="jumpNeedLogin != null">fa_jump_need_login,</if>
      <if test="startTime != null">fa_start_time,</if>
      <if test="endTime != null">fa_end_time,</if>
      <if test="position != null">fa_position,</if>
      <if test="order != null">fa_order,</if>
      <if test="state != null">fa_state,</if>
      <if test="createTime != null">fa_create_time,</if>
      <if test="updateTime != null">fa_update_time,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="name != null">#{name,jdbcType=VARCHAR},</if>
      <if test="picture != null">#{picture,jdbcType=VARCHAR},</if>
      <if test="showMode != null">#{showMode,jdbcType=VARCHAR},</if>
      <if test="jumpDetail != null">#{jumpDetail.id,jdbcType=BIGINT},</if>
      <if test="params != null">#{params,jdbcType=VARCHAR},</if>
      <if test="jumpNeedLogin != null">#{jumpNeedLogin,jdbcType=VARCHAR},</if>
      <if test="startTime != null">#{startTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="position != null">#{position,jdbcType=VARCHAR},</if>
      <if test="order != null">#{order,jdbcType=INTEGER},</if>
      <if test="state != null">#{state,jdbcType=INTEGER},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.homemodule.FloatAD">update yeshi_ec_float_ad set fa_name = #{name,jdbcType=VARCHAR},fa_picture = #{picture,jdbcType=VARCHAR},fa_show_mode = #{showMode,jdbcType=VARCHAR},fa_jumpid = #{jumpDetail.id,jdbcType=BIGINT},fa_params = #{params,jdbcType=VARCHAR},fa_jump_need_login = #{jumpNeedLogin,jdbcType=VARCHAR},fa_start_time = #{startTime,jdbcType=TIMESTAMP},fa_end_time = #{endTime,jdbcType=TIMESTAMP},fa_position = #{position,jdbcType=VARCHAR},fa_order = #{order,jdbcType=INTEGER},fa_state = #{state,jdbcType=INTEGER},fa_create_time = #{createTime,jdbcType=TIMESTAMP},fa_update_time = #{updateTime,jdbcType=TIMESTAMP} where fa_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.homemodule.FloatAD">update yeshi_ec_float_ad
    <set>
      <if test="name != null">fa_name=#{name,jdbcType=VARCHAR},</if>
      <if test="picture != null">fa_picture=#{picture,jdbcType=VARCHAR},</if>
      <if test="showMode != null">fa_show_mode=#{showMode,jdbcType=VARCHAR},</if>
      <if test="jumpDetail != null">fa_jumpid=#{jumpDetail.id,jdbcType=BIGINT},</if>
      <if test="params != null">fa_params=#{params,jdbcType=VARCHAR},</if>
      <if test="jumpNeedLogin != null">fa_jump_need_login=#{jumpNeedLogin,jdbcType=VARCHAR},</if>
      <if test="startTime != null">fa_start_time=#{startTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">fa_end_time=#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="position != null">fa_position=#{position,jdbcType=VARCHAR},</if>
      <if test="order != null">fa_order=#{order,jdbcType=INTEGER},</if>
      <if test="state != null">fa_state=#{state,jdbcType=INTEGER},</if>
      <if test="createTime != null">fa_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">fa_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where fa_id = #{id,jdbcType=BIGINT}
  </update>
  <delete id="deleteByPrimaryKeyList" parameterType="java.util.List">
    delete from yeshi_ec_float_ad
    WHERE fa_id in <foreach collection="list" item="item" open="(" separator="," close=")">#{item}</foreach>
  </delete>
  <select id="listQuery" resultMap="BaseResultMap">
      SELECT <include refid="Base_Column_List" /> FROM yeshi_ec_float_ad fd
      WHERE 1=1
          <if test="key != null and key !='' ">
              AND fd.`fa_name` LIKE '%${key}%'
          </if>
          <if test="state != null">
               AND fd.`fa_state` =  #{state}
          </if>
      ORDER BY fd.`fa_position`,fd.`fa_order`
      LIMIT ${start},${count}
  </select>
  <select id="countQuery" resultType="java.lang.Long">
      SELECT IFNULL(COUNT(fd.`fa_id`),0) FROM yeshi_ec_float_ad fd
      WHERE 1=1
          <if test="key != null and key !='' ">
              AND fd.`fa_name` LIKE '%${key}%'
          </if>
          <if test="state != null">
               AND fd.`fa_state` =  #{state}
          </if>
  </select>
   <select id="getByAdjoinOrder" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" /> FROM yeshi_ec_float_ad fd
        WHERE  fd.`fa_position` = #{position}
        <if test="type == -1">
            AND fd.`fa_order` <![CDATA[<]]> #{order}
            ORDER BY fd.`fa_order` desc
        </if>
        <if test="type == 1">
            AND fd.`fa_order` <![CDATA[>]]> #{order}
            ORDER BY fd.`fa_order`
        </if>
        LIMIT 1
   </select>
    <select id="countByPosition" resultType="java.lang.Integer">
         SELECT IFNULL(COUNT(fd.`fa_id`),0) FROM yeshi_ec_float_ad fd
         WHERE fd.`fa_position` = #{position}
   </select>
   <select id="ListByPrimaryKey" parameterType="java.util.List" resultMap="BaseResultMap">
       SELECT <include refid="Base_Column_List" />  FROM yeshi_ec_float_ad
       WHERE fa_id in <foreach collection="list" item="item" open="(" separator="," close=")">#{item}</foreach>
   </select>
       <select id="getEffectiveFloatAD" resultMap="BaseResultMap">
           SELECT * FROM yeshi_ec_float_ad fd
        WHERE fd.`fa_position` = 'index' AND fd.`fa_state` = 1
               AND IF(fd.`fa_start_time` IS NULL,TRUE,fd.`fa_start_time` <![CDATA[<=]]> NOW())
               AND IF(fd.`fa_end_time` IS NULL,TRUE,fd.`fa_end_time` <![CDATA[>=]]> NOW())
        ORDER BY fd.`fa_order`
        LIMIT 1
       </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/FloatADServiceImpl.java
New file
@@ -0,0 +1,257 @@
package com.yeshi.fanli.service.impl.homemodule;
import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import javax.annotation.Resource;
import javax.transaction.Transactional;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.yeshi.utils.tencentcloud.COSManager;
import com.yeshi.fanli.dao.mybatis.homemodule.FloatADMapper;
import com.yeshi.fanli.entity.bus.homemodule.FloatAD;
import com.yeshi.fanli.entity.common.JumpDetailV2;
import com.yeshi.fanli.exception.FloatADException;
import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
import com.yeshi.fanli.service.inter.homemodule.FloatADService;
import com.yeshi.fanli.util.StringUtil;
@Service
public class FloatADServiceImpl implements FloatADService {
    @Resource
    private FloatADMapper floatADMapper;
    @Resource
    private JumpDetailV2Service jumpDetailV2Service;
    @Override
    public void saveObject(MultipartFile file, FloatAD record, String jumpType) throws FloatADException, Exception{
        String position = record.getPosition();
        if (position == null || position.trim().length() == 0) {
            throw new FloatADException(1, "使用位置不能为空");
        }
        String showMode = record.getShowMode();
        if (showMode == null || showMode.trim().length() == 0) {
            throw new FloatADException(1, "显示方式不能为空");
        }
        String params = record.getParams();
        if ((params != null && params.trim().length() == 0) || "null".equalsIgnoreCase(params) ) {
            record.setParams(null);
        }
        if (!StringUtil.isNullOrEmpty(jumpType)) {
            List<JumpDetailV2> listByType = jumpDetailV2Service.listByType(jumpType);
            if (listByType !=null && listByType.size() > 0) {
                record.setJumpDetail(listByType.get(0));
            }
        }
        try {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date startTime = record.getStartTime();
            if (startTime != null) {
                record.setStartTime(format.parse(format.format(startTime)));
            }
            Date endTime = record.getEndTime();
            if (endTime != null) {
                record.setEndTime(format.parse(format.format(endTime)));
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
        String picture = null;
        if (file != null) {
            picture = uploadPicture(file);
        }
        Long id = record.getId();
        if (id == null) {
            int maxOrder = floatADMapper.countByPosition(position);
            record.setPicture(picture);
            record.setState(0);
            record.setOrder(maxOrder + 1);
            record.setJumpNeedLogin(false);
            record.setCreateTime(new Date());
            record.setUpdateTime(new Date());
            floatADMapper.insert(record);
        } else {
            // 修改
            FloatAD resultObj = floatADMapper.selectByPrimaryKey(id);
            if (resultObj == null) {
                throw new FloatADException(1, "修改内容已不存在");
            }
            if (picture != null && picture.trim().length() > 0) {
                record.setPicture(picture);
                // 删除已存在图片
                removePicture(resultObj);
            } else {
                record.setPicture(resultObj.getPicture());
            }
            record.setOrder(resultObj.getOrder());
            record.setCreateTime(resultObj.getCreateTime());
            record.setUpdateTime(new Date());
            floatADMapper.updateByPrimaryKey(record);
        }
    }
    @Override
    @Transactional
    public void updateOrder(Long id, Integer moveType) throws FloatADException {
        if (id == null || moveType == null || (!moveType.equals(1) && !moveType.equals(-1))) {
            throw new FloatADException(1, "请传递正确参数");
        }
        FloatAD resultObj = floatADMapper.selectByPrimaryKey(id);
        if (resultObj == null) {
            throw new FloatADException(1, "此内容已不存在");
        }
        Integer order = resultObj.getOrder();
        String position = resultObj.getPosition();
        // 获取交换对象
        FloatAD exchangeObject = floatADMapper.getByAdjoinOrder(position, order, moveType);
        if (exchangeObject == null) {
            if (moveType == 1) {
                throw new FloatADException(1, "在相同使用地方中优先级已经最低了");
            } else {
                throw new FloatADException(1, "在相同使用地方中优先级已经最高了");
            }
        }
        resultObj.setOrder(exchangeObject.getOrder());
        exchangeObject.setOrder(order);
        floatADMapper.updateByPrimaryKey(resultObj);
        floatADMapper.updateByPrimaryKey(exchangeObject);
    }
    @Override
    @Transactional
    public int deleteByPrimaryKeyList(List<Long> list) throws Exception{
        List<FloatAD> listSwiper = floatADMapper.ListByPrimaryKey(list);
        if (listSwiper == null || listSwiper.size() == 0) {
            return 0;
        }
        // 删除已存在图片
        for (FloatAD floatAD: listSwiper) {
            removePicture(floatAD);
        }
        return floatADMapper.deleteByPrimaryKeyList(list);
    }
    /**
     * 上传图片
     * @param file
     * @return
     * @throws Exception
     */
    public String uploadPicture(MultipartFile file) throws Exception {
        // 文件解析
        InputStream inputStream = file.getInputStream();
        String contentType = file.getContentType();
        String type = contentType.substring(contentType.indexOf("/") + 1);
        // 文件路径
        String filePath="/img/FloatAD/"+UUID.randomUUID().toString().replace("-", "") + "." + type;
        // 执行上传
        String fileLink= COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
        return fileLink;
    }
    /**
     * 删除图片-不更新数据库
     * @param record
     * @throws Exception
     */
    public void removePicture(FloatAD record) throws Exception {
        String picture = record.getPicture();
        if (picture != null && picture.trim().length() > 0) {
            COSManager.getInstance().deleteFile(picture);
        }
    }
    @Override
    public List<FloatAD> listQuery(long start, int count, String key, Integer state) throws FloatADException {
        List<FloatAD> listQuery = floatADMapper.listQuery(start, count, key, state);
        if (listQuery == null || listQuery.size() == 0) {
            return listQuery;
        }
        for (FloatAD floatAD : listQuery) {
            String params = floatAD.getParams();
            if (params == null) {
                floatAD.setParams("");
            }
            JumpDetailV2 jumpDetail = floatAD.getJumpDetail();
            if (jumpDetail == null) {
                // 默认未选择
                jumpDetail = new JumpDetailV2();
                jumpDetail.setName("-未选择-");
                jumpDetail.setType("default");
            } else {
                jumpDetail = jumpDetailV2Service.selectByPrimaryKey(jumpDetail.getId());
            }
            floatAD.setJumpDetail(jumpDetail);
        }
        return listQuery;
    }
    @Override
    public long countQuery(String key, Integer state) {
        return floatADMapper.countQuery(key, state);
    }
    @Override
    public FloatAD getEffectiveFloatAD(String position) {
        FloatAD floatAD = floatADMapper.getEffectiveFloatAD(position);
        if (floatAD != null) {
            JumpDetailV2 jumpDetail = floatAD.getJumpDetail();
            // 查询JumpDetailV2
            if (jumpDetail != null) {
                jumpDetail = jumpDetailV2Service.selectByPrimaryKey(jumpDetail.getId());
                if (jumpDetail != null) {
                    // 跳转界面是否需要登录
                    jumpDetail.setNeedLogin(floatAD.isJumpNeedLogin());
                }
            }
            floatAD.setJumpDetail(jumpDetail);
        }
        return floatAD;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/inter/homemodule/FloatADService.java
New file
@@ -0,0 +1,62 @@
package com.yeshi.fanli.service.inter.homemodule;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.multipart.MultipartFile;
import com.yeshi.fanli.entity.bus.homemodule.FloatAD;
import com.yeshi.fanli.exception.FloatADException;
import com.yeshi.fanli.exception.banner.SwiperPictureException;
public interface FloatADService {
    /**
     * 保存
     * @param record
     * @throws FloatADException
     */
    public void saveObject(MultipartFile file, FloatAD record, String jumpType) throws FloatADException, Exception;
    /**
     * 修改排序
     * @param id
     * @param moveType
     * @throws FloatADException
     */
    public void updateOrder(Long id, Integer moveType) throws FloatADException;
    /**
     * 批量删除
     *
     * @param list 管理id
     * @return
     * @throws SwiperPictureException
     */
    public int deleteByPrimaryKeyList(List<Long> list) throws Exception;
    /**
     * 后端列表查询
     *
     * @param start
     * @param count
     * @param key
     * @param state
     * @return
     */
    public List<FloatAD> listQuery(@Param("start") long start, @Param("count") int count, @Param("key") String key,
            @Param("state") Integer state) throws FloatADException;
    public long countQuery(@Param("key") String key, @Param("state") Integer state);
    /**
     * 查询有效的悬浮大图
     * @return
     */
    public FloatAD getEffectiveFloatAD(String position);
}