| @@ -1,10 +1,9 @@ | |||||
| package com.iformall.controller.sys; | package com.iformall.controller.sys; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.po.MallUserAction; | |||||
| import com.iformall.domain.vo.MallUserActionVo; | |||||
| import com.iformall.service.MallUserActionService; | import com.iformall.service.MallUserActionService; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| @@ -26,10 +25,10 @@ public class MallUserActionController extends BaseController { | |||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | ||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | ||||
| public ResultData list(@ModelAttribute MallUserAction userAction, Integer pageNum, Integer pageSize) { | |||||
| public ResultData list(@ModelAttribute MallUserActionVo userAction, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] MallUserActionController::list"); | logger.debug("[" + getIpAddr() + "] MallUserActionController::list"); | ||||
| if (null == userAction) userAction = new MallUserAction(); | |||||
| final PageInfo<MallUserAction> page = mallUserActionService.listAsPage(userAction, pageNum, pageSize); | |||||
| if (null == userAction) userAction = new MallUserActionVo(); | |||||
| final PageInfo<MallUserActionVo> page = mallUserActionService.listAsPage(userAction, pageNum, pageSize); | |||||
| return new ResultData(page); | return new ResultData(page); | ||||
| } | } | ||||
| @@ -1,18 +1,18 @@ | |||||
| package com.iformall.domain.po; | package com.iformall.domain.po; | ||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | |||||
| import javax.persistence.*; | import javax.persistence.*; | ||||
| import java.util.*; | import java.util.*; | ||||
| import java.math.*; | |||||
| import javax.persistence.Transient; | import javax.persistence.Transient; | ||||
| import java.util.List; | import java.util.List; | ||||
| import javax.persistence.Id; | import javax.persistence.Id; | ||||
| import java.io.Serializable; | |||||
| @Table(name = "mall_user_action") | @Table(name = "mall_user_action") | ||||
| @Data | @Data | ||||
| public class MallUserAction implements Serializable { | |||||
| private static final long serialVersionUID = 1L; | |||||
| @EqualsAndHashCode(callSuper = true) | |||||
| public class MallUserAction extends BaseEntity { | |||||
| @Id | @Id | ||||
| protected Long id; | protected Long id; | ||||
| @@ -28,7 +28,7 @@ public class MallUserAction implements Serializable { | |||||
| private Long userId; | private Long userId; | ||||
| @io.swagger.annotations.ApiModelProperty(value="类型 0-controller, 1-service",name="type") | @io.swagger.annotations.ApiModelProperty(value="类型 0-controller, 1-service",name="type") | ||||
| private Integer type; | private Integer type; | ||||
| @io.swagger.annotations.ApiModelProperty(value="",name="ip") | |||||
| @io.swagger.annotations.ApiModelProperty(value="ip地址",name="ip") | |||||
| private String ip; | private String ip; | ||||
| @io.swagger.annotations.ApiModelProperty(value="功能描述",name="actionDesc") | @io.swagger.annotations.ApiModelProperty(value="功能描述",name="actionDesc") | ||||
| private String actionDesc; | private String actionDesc; | ||||
| @@ -97,4 +97,10 @@ public class MallUserAction implements Serializable { | |||||
| this.setSortColumns(Field.valueOf(sortColumns)); | this.setSortColumns(Field.valueOf(sortColumns)); | ||||
| } | } | ||||
| } | } | ||||
| @Override | |||||
| public String getSortColumns() { | |||||
| super.setSortColumns(this.sortColumns); | |||||
| return super.getSortColumns(); | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,87 @@ | |||||
| package com.iformall.domain.vo; | |||||
| import com.iformall.domain.po.MallUserAction; | |||||
| import lombok.Data; | |||||
| import lombok.EqualsAndHashCode; | |||||
| import lombok.ToString; | |||||
| /** | |||||
| * Created by syf on 2018/8/30. | |||||
| */ | |||||
| @Data | |||||
| @ToString(callSuper = true) | |||||
| @EqualsAndHashCode(callSuper = true) | |||||
| public class MallUserActionVo extends MallUserAction { | |||||
| @io.swagger.annotations.ApiModelProperty(value="用户名称",name="name") | |||||
| private String name; | |||||
| public static enum Field | |||||
| { | |||||
| Id_ASC("mua.`id` ASC"),Id_DESC("mua.`id` DESC") | |||||
| ,TenantId_ASC("mua.`tenant_id` ASC"),TenantId_DESC("mua.`tenant_id` DESC") | |||||
| ,UserId_ASC("mua.`user_id` ASC"),UserId_DESC("mua.`user_id` DESC") | |||||
| ,Name_ASC("mui.`name` ASC"),Name_DESC("mui.`name` DESC") | |||||
| ,Type_ASC("mua.`type` ASC"),Type_DESC("mua.`type` DESC") | |||||
| ,Ip_ASC("mua.`ip` ASC"),Ip_DESC("mua.`ip` DESC") | |||||
| ,ActionDesc_ASC("mua.`action_desc` ASC"),ActionDesc_DESC("mua.`action_desc` DESC") | |||||
| ,ActionTime_ASC("mua.`action_time` ASC"),ActionTime_DESC("mua.`action_time` DESC") | |||||
| ; | |||||
| private String value; | |||||
| Field(String value){ | |||||
| this.value = value; | |||||
| } | |||||
| public String getValue() { | |||||
| return value; | |||||
| } | |||||
| public void setCol(String value) { | |||||
| this.value = value; | |||||
| } | |||||
| @Override | |||||
| public String toString() { | |||||
| return this.getValue(); | |||||
| } | |||||
| } | |||||
| public void setSortColumns(MallUserAction.Field... fields) | |||||
| { | |||||
| if (fields == null || fields.length == 0) { | |||||
| return; | |||||
| } | |||||
| for (int k = 0; k < fields.length; k++) { | |||||
| if (fields[k] == null) { | |||||
| return; | |||||
| } | |||||
| } | |||||
| StringBuilder sb = new StringBuilder(fields[0].toString()); | |||||
| for (int k = 1; k < fields.length; k++) { | |||||
| sb.append(","); | |||||
| sb.append(fields[k].toString()); | |||||
| } | |||||
| this.sortColumns = sb.toString(); | |||||
| } | |||||
| public void setSortColumns(String sortColumns) | |||||
| { | |||||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | |||||
| return; | |||||
| } | |||||
| if (sortColumns.contains(",")) { | |||||
| String[] cols = sortColumns.split(","); | |||||
| java.util.List<MallUserAction.Field> fList = new java.util.ArrayList(); | |||||
| for (int k = 0; k < cols.length; k++) { | |||||
| fList.add(MallUserAction.Field.valueOf(cols[k])); | |||||
| } | |||||
| this.setSortColumns(fList.toArray(new MallUserAction.Field[fList.size()])); | |||||
| } else { | |||||
| this.setSortColumns(MallUserAction.Field.valueOf(sortColumns)); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public String getSortColumns() { | |||||
| super.setSortColumns(this.sortColumns); | |||||
| return super.getSortColumns(); | |||||
| } | |||||
| } | |||||
| @@ -2,16 +2,15 @@ package com.iformall.mapper; | |||||
| import java.util.*; | import java.util.*; | ||||
| import com.iformall.common.CommonMapper; | import com.iformall.common.CommonMapper; | ||||
| import org.apache.ibatis.annotations.Param; | |||||
| import com.iformall.domain.vo.MallUserActionVo; | |||||
| import com.iformall.domain.po.MallUserAction; | import com.iformall.domain.po.MallUserAction; | ||||
| public interface MallUserActionMapper extends CommonMapper<MallUserAction, Long> { | public interface MallUserActionMapper extends CommonMapper<MallUserAction, Long> { | ||||
| List<MallUserAction> findList(MallUserAction mallUserAction); | List<MallUserAction> findList(MallUserAction mallUserAction); | ||||
| List<MallUserActionVo> findListVo(MallUserActionVo mallUserAction); | |||||
| } | } | ||||
| @@ -1,9 +1,8 @@ | |||||
| package com.iformall.service; | package com.iformall.service; | ||||
| import java.util.*; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.domain.po.MallUserAction; | import com.iformall.domain.po.MallUserAction; | ||||
| import com.iformall.domain.vo.MallUserActionVo; | |||||
| public interface MallUserActionService { | public interface MallUserActionService { | ||||
| @@ -15,7 +14,7 @@ public interface MallUserActionService { | |||||
| * @param pageSize | * @param pageSize | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| PageInfo<MallUserAction> listAsPage(MallUserAction record, Integer pageIndex, Integer pageSize); | |||||
| PageInfo<MallUserActionVo> listAsPage(MallUserActionVo record, Integer pageIndex, Integer pageSize); | |||||
| /** | /** | ||||
| * 根据Id获得实体 | * 根据Id获得实体 | ||||
| @@ -3,6 +3,7 @@ package com.iformall.service.impl; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.domain.po.MallUserAction; | import com.iformall.domain.po.MallUserAction; | ||||
| import com.iformall.domain.vo.MallUserActionVo; | |||||
| import com.iformall.mapper.MallUserActionMapper; | import com.iformall.mapper.MallUserActionMapper; | ||||
| import com.iformall.service.MallUserActionService; | import com.iformall.service.MallUserActionService; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -18,8 +19,8 @@ public class MallUserActionServiceImpl implements MallUserActionService { | |||||
| MallUserActionMapper mallUserActionMapper; | MallUserActionMapper mallUserActionMapper; | ||||
| @Override | @Override | ||||
| public PageInfo<MallUserAction> listAsPage(MallUserAction record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> mallUserActionMapper.findList(record)); | |||||
| public PageInfo<MallUserActionVo> listAsPage(MallUserActionVo record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> mallUserActionMapper.findListVo(record)); | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -15,14 +15,14 @@ | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| where 1 = 1 | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | <if test=" null != id "> | ||||
| and `id` = #{id} | and `id` = #{id} | ||||
| </if> | </if> | ||||
| <if test=" null != userId "> | <if test=" null != userId "> | ||||
| and `user_id` = #{userId} | and `user_id` = #{userId} | ||||
| </if> | |||||
| <if test=" null != type "> | |||||
| </if> | |||||
| <if test=" null != type "> | |||||
| and `type` = #{type} | and `type` = #{type} | ||||
| </if> | </if> | ||||
| <if test=" null != ip "> | <if test=" null != ip "> | ||||
| @@ -35,17 +35,71 @@ | |||||
| and `action_time` = #{actionTime} | and `action_time` = #{actionTime} | ||||
| </if> | </if> | ||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and id in | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | ||||
| #{idItem} | #{idItem} | ||||
| </foreach> | </foreach> | ||||
| </if> | </if> | ||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | <if test=" null != sortColumns"> order by ${sortColumns} </if> | ||||
| </sql> | </sql> | ||||
| <select id="findList" parameterType="com.iformall.domain.po.MallUserAction" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> | |||||
| from mall_user_action | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| <resultMap id="VoBaseResultMap" type="com.iformall.domain.vo.MallUserActionVo"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="user_id" jdbcType="BIGINT" property="userId" /> | |||||
| <result column="type" jdbcType="INTEGER" property="type" /> | |||||
| <result column="ip" jdbcType="VARCHAR" property="ip" /> | |||||
| <result column="action_desc" jdbcType="VARCHAR" property="actionDesc" /> | |||||
| <result column="action_time" jdbcType="TIMESTAMP" property="actionTime" /> | |||||
| <result column="name" jdbcType="VARCHAR" property="name" /> | |||||
| </resultMap> | |||||
| <sql id="allVoColumns"> | |||||
| mua.`id`,mua.`user_id`,mua.`type`,mua.`ip`,mua.`action_desc`,mua.`action_time`,mui.`name` | |||||
| </sql> | |||||
| <sql id="dynamicVoWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and mua.`id` = #{id} | |||||
| </if> | |||||
| <if test=" null != userId "> | |||||
| and mua.`user_id` = #{userId} | |||||
| </if> | |||||
| <if test=" null != name "> | |||||
| and mui.`name` like concat('%', #{name},'%') | |||||
| </if> | |||||
| <if test=" null != type "> | |||||
| and mua.`type` = #{type} | |||||
| </if> | |||||
| <if test=" null != ip "> | |||||
| and mua.`ip` like concat('%', #{ip},'%') | |||||
| </if> | |||||
| <if test=" null != actionDesc "> | |||||
| and mua.`action_desc` like concat('%', #{actionDesc},'%') | |||||
| </if> | |||||
| <if test=" null != actionTime "> | |||||
| and mua.`action_time` = #{actionTime} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and mua.id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.MallUserAction" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from mall_user_action | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| <select id="findListVo" parameterType="com.iformall.domain.vo.MallUserActionVo" resultMap="VoBaseResultMap"> | |||||
| select <include refid="allVoColumns" /> | |||||
| from mall_user_action mua | |||||
| left join mall_user_info mui on mua.user_id = mui.id | |||||
| <include refid="dynamicVoWhereConditions" /> | |||||
| </select> | </select> | ||||