增加平台列表
parent
7718543a43
commit
c9ea3b470e
@ -0,0 +1,70 @@
|
||||
package com.glxp.udi.admin.controller.info;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.glxp.udi.admin.annotation.AuthRuleAnnotation;
|
||||
import com.glxp.udi.admin.entity.info.PlatformEntity;
|
||||
import com.glxp.udi.admin.exception.JsonException;
|
||||
import com.glxp.udi.admin.res.PageSimpleResponse;
|
||||
import com.glxp.udi.admin.service.info.PlatformService;
|
||||
import com.glxp.udi.admin.util.UuidUtils;
|
||||
import com.glxp.udi.common.enums.ResultEnum;
|
||||
import com.glxp.udi.common.res.BaseResponse;
|
||||
import com.glxp.udi.common.util.ResultVOUtils;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@Slf4j
|
||||
public class PlatformController {
|
||||
|
||||
@Resource
|
||||
private PlatformService platformService;
|
||||
|
||||
@AuthRuleAnnotation("")
|
||||
@PostMapping("/udims/platform/remove")
|
||||
public BaseResponse remove(@RequestBody PlatformEntity platformEntity) {
|
||||
if(platformService.remove(platformEntity.getId())>0)
|
||||
ResultVOUtils.success("删除成功");
|
||||
return ResultVOUtils.error(500, "删除失败");
|
||||
}
|
||||
|
||||
|
||||
@AuthRuleAnnotation("")
|
||||
@PostMapping("/udims/platform/update")
|
||||
public BaseResponse update(@RequestBody PlatformEntity platformEntity) {
|
||||
if(platformService.update(platformEntity)>0)
|
||||
ResultVOUtils.success("修改成功");
|
||||
|
||||
return ResultVOUtils.success("修改失败");
|
||||
}
|
||||
|
||||
@AuthRuleAnnotation("")
|
||||
@GetMapping("/udims/platform/list")
|
||||
public BaseResponse list(@RequestParam Map<String, Object> params) {
|
||||
List<PlatformEntity> list = platformService.list(params);
|
||||
if(params.get("page")!=null&¶ms.get("limit")!=null) {
|
||||
params.put("offset",(Integer.valueOf(params.get("page").toString()) -1) *(Integer.valueOf(params.get("limit").toString())));
|
||||
}
|
||||
int total = platformService.count(params);
|
||||
PageSimpleResponse<PlatformEntity> pageSimpleResponse = new PageSimpleResponse<>();
|
||||
pageSimpleResponse.setTotal(Long.valueOf(String.valueOf(total)));
|
||||
pageSimpleResponse.setList(list);
|
||||
|
||||
return ResultVOUtils.success(pageSimpleResponse);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.glxp.udi.admin.dao.info;
|
||||
|
||||
import com.glxp.udi.admin.entity.info.PlatformEntity;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface PlatformDao {
|
||||
|
||||
int save(PlatformEntity platformEntity);
|
||||
|
||||
int batchSave(List<PlatformEntity> list);
|
||||
|
||||
int remove(String id);
|
||||
|
||||
int update(PlatformEntity platformEntity);
|
||||
|
||||
List<PlatformEntity> list(Map<String, Object> map);
|
||||
|
||||
int count(Map<String, Object> map);
|
||||
|
||||
PlatformEntity get(String id);
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.glxp.udi.admin.entity.info;
|
||||
|
||||
public class PlatformEntity {
|
||||
|
||||
private String id;
|
||||
private String name; //平台名称
|
||||
private String host; //平台地址
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.glxp.udi.admin.service.info;
|
||||
|
||||
import com.glxp.udi.admin.entity.info.PlatformEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface PlatformService {
|
||||
|
||||
int save(PlatformEntity platformEntity);
|
||||
|
||||
int batchSave(List<PlatformEntity> list);
|
||||
|
||||
int remove(String id);
|
||||
|
||||
int update(PlatformEntity platformEntity);
|
||||
|
||||
List<PlatformEntity> list(Map<String, Object> map);
|
||||
int count(Map<String, Object> map);
|
||||
PlatformEntity get(String id);
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package com.glxp.udi.admin.service.info.impl;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.glxp.udi.admin.dao.info.PlatformDao;
|
||||
import com.glxp.udi.admin.entity.info.PlatformEntity;
|
||||
import com.glxp.udi.admin.service.info.PlatformService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Resource;
|
||||
import com.glxp.udi.admin.util.UuidUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@Service
|
||||
@Slf4j
|
||||
public class PlatformServiceImpl implements PlatformService {
|
||||
|
||||
@Resource
|
||||
PlatformDao platformDao;
|
||||
|
||||
@Override
|
||||
public int save(PlatformEntity platformEntity){
|
||||
if(StringUtils.isEmpty(platformEntity.getId()))
|
||||
platformEntity.setId(UuidUtils.getUUId());
|
||||
return platformDao.save(platformEntity);
|
||||
}
|
||||
@Override
|
||||
public int batchSave(List<PlatformEntity> list){
|
||||
return platformDao.batchSave(list);
|
||||
}
|
||||
@Override
|
||||
public int remove(String id){
|
||||
return platformDao.remove(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(PlatformEntity platformEntity){
|
||||
if(StringUtils.isEmpty(platformEntity.getId()))
|
||||
return save(platformEntity);
|
||||
return platformDao.update(platformEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlatformEntity> list(Map<String, Object> map){
|
||||
return platformDao.list(map);
|
||||
}
|
||||
@Override
|
||||
public int count(Map<String, Object> map) {
|
||||
return platformDao.count(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlatformEntity get(String id) {
|
||||
return platformDao.get(id);
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
<?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.glxp.udi.admin.dao.info.PlatformDao">
|
||||
|
||||
|
||||
<insert id="save" parameterType="com.glxp.udi.admin.entity.info.PlatformEntity"
|
||||
>
|
||||
insert into auth_platform
|
||||
( id,name,host )
|
||||
values
|
||||
(
|
||||
#{id},#{name,jdbcType=VARCHAR},#{host,jdbcType=VARCHAR}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="batchSave" parameterType="java.util.List">
|
||||
replace into auth_platform
|
||||
( id,name,host )
|
||||
values
|
||||
<foreach item="item" index="index" collection="list"
|
||||
separator=",">
|
||||
(
|
||||
#{item.id},#{item.name,jdbcType=VARCHAR},#{item.host,jdbcType=VARCHAR}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="remove" >
|
||||
delete from auth_platform where id = #{value}
|
||||
</delete>
|
||||
|
||||
<update id="update" parameterType="com.glxp.udi.admin.entity.info.PlatformEntity">
|
||||
update auth_platform
|
||||
<set>
|
||||
<if test="name != null">name=#{name},</if>
|
||||
<if test="host != null">host=#{host},</if>
|
||||
</set>
|
||||
where id=#{id}
|
||||
</update>
|
||||
|
||||
<select id="get" resultType="com.glxp.udi.admin.entity.info.PlatformEntity">
|
||||
select * from auth_platform where id = #{value}
|
||||
</select>
|
||||
<select id="list" resultType="com.glxp.udi.admin.entity.info.PlatformEntity">
|
||||
select * from auth_platform
|
||||
<where>
|
||||
<if test="id != null and id != ''">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
and instr(name,#{name})
|
||||
</if>
|
||||
<if test="host != null and host != ''">
|
||||
and instr(host,#{host})
|
||||
</if>
|
||||
</where>
|
||||
<if test="offset != null and limit != null">
|
||||
limit #{offset}, #{limit}
|
||||
</if>
|
||||
</select>
|
||||
<select id="count" resultType="int">
|
||||
select count(*) from auth_platform
|
||||
<where>
|
||||
<if test="id != null and id != ''">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
and instr(name,#{name})
|
||||
</if>
|
||||
<if test="host != null and host != ''">
|
||||
and instr(host,#{host})
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue