14 changed files with 550 additions and 14 deletions
@ -0,0 +1,54 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.dto; |
||||
|
|
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.Date; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 用户标签表 |
||||
|
* |
||||
|
* @author Mark sunlightcs@gmail.com |
||||
|
* @since v1.0.0 2019-09-02 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class UserTagDTO implements Serializable { |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
private String id; |
||||
|
|
||||
|
private String tagName; |
||||
|
|
||||
|
private String tagDesc; |
||||
|
|
||||
|
private Integer revision; |
||||
|
|
||||
|
private String createdBy; |
||||
|
|
||||
|
private Date createdTime; |
||||
|
|
||||
|
private String updatedBy; |
||||
|
|
||||
|
private Date updatedTime; |
||||
|
|
||||
|
private String delFlag; |
||||
|
|
||||
|
} |
@ -0,0 +1,102 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.controller; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.ExcelUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.AssertUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; |
||||
|
import com.elink.esua.epdc.dto.UserTagDTO; |
||||
|
import com.elink.esua.epdc.excel.UserTagExcel; |
||||
|
import com.elink.esua.epdc.service.UserTagService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import javax.servlet.http.HttpServletResponse; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 用户标签表 |
||||
|
* |
||||
|
* @author Mark sunlightcs@gmail.com |
||||
|
* @since v1.0.0 2019-09-02 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("/usertag") |
||||
|
public class UserTagController { |
||||
|
@Autowired |
||||
|
private UserTagService userTagService; |
||||
|
|
||||
|
@GetMapping("page") |
||||
|
public Result<PageData<UserTagDTO>> page(@RequestParam Map<String, Object> params){ |
||||
|
PageData<UserTagDTO> page = userTagService.page(params); |
||||
|
|
||||
|
return new Result<PageData<UserTagDTO>>().ok(page); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("{id}") |
||||
|
public Result<UserTagDTO> get(@PathVariable("id") String id){ |
||||
|
UserTagDTO data = userTagService.get(id); |
||||
|
|
||||
|
return new Result<UserTagDTO>().ok(data); |
||||
|
} |
||||
|
|
||||
|
@PostMapping |
||||
|
public Result save(@RequestBody UserTagDTO dto){ |
||||
|
//效验数据
|
||||
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
||||
|
|
||||
|
userTagService.save(dto); |
||||
|
|
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@PutMapping |
||||
|
public Result update(@RequestBody UserTagDTO dto){ |
||||
|
//效验数据
|
||||
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
||||
|
|
||||
|
userTagService.update(dto); |
||||
|
|
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@DeleteMapping |
||||
|
public Result delete(@RequestBody String[] ids){ |
||||
|
//效验数据
|
||||
|
AssertUtils.isArrayEmpty(ids, "id"); |
||||
|
|
||||
|
userTagService.delete(ids); |
||||
|
|
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("export") |
||||
|
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
||||
|
List<UserTagDTO> list = userTagService.list(params); |
||||
|
|
||||
|
ExcelUtils.exportExcelToTarget(response, null, list, UserTagExcel.class); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.dao; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; |
||||
|
import com.elink.esua.epdc.entity.UserTagEntity; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
/** |
||||
|
* 用户标签表 |
||||
|
* |
||||
|
* @author Mark sunlightcs@gmail.com |
||||
|
* @since v1.0.0 2019-09-02 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface UserTagDao extends BaseDao<UserTagEntity> { |
||||
|
|
||||
|
} |
@ -0,0 +1,53 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.entity; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||
|
import com.baomidou.mybatisplus.annotation.FieldFill; |
||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.mybatis.entity.BaseEntity; |
||||
|
import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* 用户标签表 |
||||
|
* |
||||
|
* @author Mark sunlightcs@gmail.com |
||||
|
* @since v1.0.0 2019-09-02 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper=false) |
||||
|
@TableName("epdc_user_tag") |
||||
|
public class UserTagEntity extends BaseEpdcEntity { |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 标签名 |
||||
|
*/ |
||||
|
private String tagName; |
||||
|
/** |
||||
|
* 标签描述 |
||||
|
*/ |
||||
|
private String tagDesc; |
||||
|
|
||||
|
} |
@ -0,0 +1,52 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.excel; |
||||
|
|
||||
|
import cn.afterturn.easypoi.excel.annotation.Excel; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* 用户标签表 |
||||
|
* |
||||
|
* @author Mark sunlightcs@gmail.com |
||||
|
* @since v1.0.0 2019-09-02 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class UserTagExcel { |
||||
|
@Excel(name = "主键") |
||||
|
private String id; |
||||
|
@Excel(name = "标签名") |
||||
|
private String tagName; |
||||
|
@Excel(name = "标签描述") |
||||
|
private String tagDesc; |
||||
|
@Excel(name = "乐观锁") |
||||
|
private Integer revision; |
||||
|
@Excel(name = "创建人") |
||||
|
private String createdBy; |
||||
|
@Excel(name = "创建时间") |
||||
|
private Date createdTime; |
||||
|
@Excel(name = "更新人") |
||||
|
private String updatedBy; |
||||
|
@Excel(name = "更新时间") |
||||
|
private Date updatedTime; |
||||
|
@Excel(name = "删除标记") |
||||
|
private String delFlag; |
||||
|
|
||||
|
} |
@ -0,0 +1,47 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.redis; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.tools.redis.RedisUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* 用户标签表 |
||||
|
* |
||||
|
* @author Mark sunlightcs@gmail.com |
||||
|
* @since v1.0.0 2019-09-02 |
||||
|
*/ |
||||
|
@Component |
||||
|
public class UserTagRedis { |
||||
|
@Autowired |
||||
|
private RedisUtils redisUtils; |
||||
|
|
||||
|
public void delete(Object[] ids) { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public void set(){ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public String get(String id){ |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,47 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.service; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.mybatis.service.BaseService; |
||||
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
||||
|
import com.elink.esua.epdc.dto.UserTagDTO; |
||||
|
import com.elink.esua.epdc.entity.UserTagEntity; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 用户标签表 |
||||
|
* |
||||
|
* @author Mark sunlightcs@gmail.com |
||||
|
* @since v1.0.0 2019-09-02 |
||||
|
*/ |
||||
|
public interface UserTagService extends BaseService<UserTagEntity> { |
||||
|
|
||||
|
PageData<UserTagDTO> page(Map<String, Object> params); |
||||
|
|
||||
|
List<UserTagDTO> list(Map<String, Object> params); |
||||
|
|
||||
|
UserTagDTO get(String id); |
||||
|
|
||||
|
void save(UserTagDTO dto); |
||||
|
|
||||
|
void update(UserTagDTO dto); |
||||
|
|
||||
|
void delete(String[] ids); |
||||
|
} |
@ -0,0 +1,113 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.elink.esua.epdc.commons.mybatis.enums.DelFlagEnum; |
||||
|
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
||||
|
import com.elink.esua.epdc.commons.tools.constant.Constant; |
||||
|
import com.elink.esua.epdc.commons.tools.exception.RenException; |
||||
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
||||
|
import com.elink.esua.epdc.dao.UserTagDao; |
||||
|
import com.elink.esua.epdc.dto.UserTagDTO; |
||||
|
import com.elink.esua.epdc.entity.UserTagEntity; |
||||
|
import com.elink.esua.epdc.redis.UserTagRedis; |
||||
|
import com.elink.esua.epdc.service.UserTagService; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.Arrays; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 用户标签表 |
||||
|
* |
||||
|
* @author Mark sunlightcs@gmail.com |
||||
|
* @since v1.0.0 2019-09-02 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class UserTagServiceImpl extends BaseServiceImpl<UserTagDao, UserTagEntity> implements UserTagService { |
||||
|
@Autowired |
||||
|
private UserTagRedis userTagRedis; |
||||
|
|
||||
|
@Override |
||||
|
public PageData<UserTagDTO> page(Map<String, Object> params) { |
||||
|
IPage<UserTagEntity> page = baseDao.selectPage( |
||||
|
getPage(params, Constant.CREATED_TIME, false), |
||||
|
getWrapper(params) |
||||
|
); |
||||
|
|
||||
|
return getPageData(page, UserTagDTO.class); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<UserTagDTO> list(Map<String, Object> params) { |
||||
|
List<UserTagEntity> entityList = baseDao.selectList(getWrapper(params)); |
||||
|
|
||||
|
return ConvertUtils.sourceToTarget(entityList, UserTagDTO.class); |
||||
|
} |
||||
|
|
||||
|
private QueryWrapper<UserTagEntity> getWrapper(Map<String, Object> params){ |
||||
|
String id = (String)params.get("id"); |
||||
|
|
||||
|
QueryWrapper<UserTagEntity> wrapper = new QueryWrapper<>(); |
||||
|
wrapper.eq(StringUtils.isNotBlank(id), "id", id); |
||||
|
//wrapper.eq(Constant.DEL_FLAG, DelFlagEnum.NORMAL.value());
|
||||
|
|
||||
|
return wrapper; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public UserTagDTO get(String id) { |
||||
|
UserTagEntity entity = baseDao.selectById(id); |
||||
|
|
||||
|
return ConvertUtils.sourceToTarget(entity, UserTagDTO.class); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void save(UserTagDTO dto) { |
||||
|
UserTagEntity entity = ConvertUtils.sourceToTarget(dto, UserTagEntity.class); |
||||
|
|
||||
|
insert(entity); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void update(UserTagDTO dto) { |
||||
|
UserTagEntity entity = ConvertUtils.sourceToTarget(dto, UserTagEntity.class); |
||||
|
|
||||
|
updateById(entity); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void delete(String[] ids) { |
||||
|
//逻辑删除
|
||||
|
//logicDelete(ids, UserTagEntity.class);
|
||||
|
|
||||
|
//物理删除
|
||||
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,19 @@ |
|||||
|
<?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.elink.esua.epdc.dao.UserTagDao"> |
||||
|
|
||||
|
<resultMap type="com.elink.esua.epdc.entity.UserTagEntity" id="userTagMap"> |
||||
|
<result property="id" column="ID"/> |
||||
|
<result property="tagName" column="TAG_NAME"/> |
||||
|
<result property="tagDesc" column="TAG_DESC"/> |
||||
|
<result property="revision" column="REVISION"/> |
||||
|
<result property="createdBy" column="CREATED_BY"/> |
||||
|
<result property="createdTime" column="CREATED_TIME"/> |
||||
|
<result property="updatedBy" column="UPDATED_BY"/> |
||||
|
<result property="updatedTime" column="UPDATED_TIME"/> |
||||
|
<result property="delFlag" column="DEL_FLAG"/> |
||||
|
</resultMap> |
||||
|
|
||||
|
|
||||
|
</mapper> |
Loading…
Reference in new issue